How to modulate light intensity?

Requests regarding how to set up experiments in ARGoS.
Romina
Posts: 3
Joined: Mon Sep 21, 2020 7:01 pm

How to modulate light intensity?

Postby Romina » Mon Sep 21, 2020 7:37 pm

Hello! Is it possible to change the leds light intensity through time? The idea is to modify the constant value of the intensity each simulation step.

<light id="l0"
position="0,0,0.5"
orientation="0,0,0"
color="yellow"
intensity="0.0" (i want to modulate the intensity, ex: sine wave)
medium="leds"/>

I thought about getting the light entity in a loop function and then changing the value in the PostStep() but I don't know how to use SetIntensity() command.

I would appreciate your help :D :D :D :D

Best regards

Romina and Tomás

pincy
Site Admin
Posts: 550
Joined: Thu Mar 08, 2012 8:04 pm
Location: Boston, MA
Contact:

Re: How to modulate light intensity?

Postby pincy » Tue Sep 22, 2020 5:01 am

In your loop functions you can write the following:

Code: Select all

/* HEADER FILE */ class CMyLoopFunctions : public CLoopFunctions { protected: CLightEntity* m_pcLight; }; /* IMPLEMENTATION FILE */ CMyLoopFunctions::Init() { // Get the light added in the .argos file m_pcLight = &dynamic_cast<CLightEntity&>(GetSpace().GetEntity("l0")); } void CMyLoopFunctions::PostStep() { Real fIntensity; // calculate intensity... m_pcLight->SetIntensity(fIntensity); }
I made ARGoS.

Romina
Posts: 3
Joined: Mon Sep 21, 2020 7:01 pm

Re: How to modulate light intensity?

Postby Romina » Wed Sep 23, 2020 7:16 pm

Thank you so much! I will try to make it work :D

Romina
Posts: 3
Joined: Mon Sep 21, 2020 7:01 pm

Re: How to modulate light intensity?

Postby Romina » Sat Oct 24, 2020 8:49 pm

Hello again! Fortunately we were able to run your code, unfortunately we are having troubles with the intensity measurements.

When the Kilobot is just below the light source, its photosensor shows a minimum instead of a maximum as we expect because the robot is closer to the light entity.

We send you the codes, the plot (x vs I) and the link to Youtube so you can see the simulation.

https://youtu.be/yewjvH-H75M

THANK YOU! :D :D

Tomás and Romina
Attachments
intensidad.png
intensidad.png (29.86 KiB) Viewed 6064 times
fotosensor.xml
(2.02 KiB) Downloaded 135 times
luz_loop_functions.cpp
(2.3 KiB) Downloaded 123 times

pincy
Site Admin
Posts: 550
Joined: Thu Mar 08, 2012 8:04 pm
Location: Boston, MA
Contact:

Re: How to modulate light intensity?

Postby pincy » Wed Oct 28, 2020 3:01 am

The code that calculates the light sensor reading is here:

https://github.com/ilpincy/argos3-kilob ... or.cpp#L29

and that function is called from here:

https://github.com/ilpincy/argos3-kilob ... r.cpp#L146

You'll notice that we calculate an angle of optimal light reception, which is calculated here:

https://github.com/ilpincy/argos3-kilob ... r.cpp#L138

It seems that there might be a bug when the robot is directly under the light source. Do you have time to fix the code to match what you expect?
I made ARGoS.


Return to “How to... ?”



cron