Page 1 of 1

How to modulate light intensity?

Posted: Mon Sep 21, 2020 7:37 pm
by Romina
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

Re: How to modulate light intensity?

Posted: Tue Sep 22, 2020 5:01 am
by pincy
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); }

Re: How to modulate light intensity?

Posted: Wed Sep 23, 2020 7:16 pm
by Romina
Thank you so much! I will try to make it work :D

Re: How to modulate light intensity?

Posted: Sat Oct 24, 2020 8:49 pm
by Romina
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

Re: How to modulate light intensity?

Posted: Wed Oct 28, 2020 3:01 am
by pincy
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?