move footbot based on light intensity

Requests regarding how to set up experiments in ARGoS.
ahyoussef
Posts: 13
Joined: Sat Sep 03, 2016 3:15 pm

move footbot based on light intensity

Postby ahyoussef » Mon Sep 19, 2016 11:23 pm

Dear All,

i'm trying to move a set of footbots in the arena based on a single light source, in other words, i want the footbots to goto the light source (pretty much similar to what is in flocking) however im using the loopfunctions and the MoveEntity to move the robots and not the differential steering actuator as in the examples.

I've been trying to add the accumulation of the sensory information to the robot current location, since both are vectors and it could lead to be nearer to the light source with every iteration, yet it is not really working.

any help is appreciated.

thanks

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

Re: move footbot based on light intensity

Postby pincy » Tue Sep 20, 2016 12:00 am

Hi,
i'm trying to move a set of footbots in the arena based on a single light source, in other words, i want the footbots to goto the light source (pretty much similar to what is in flocking) however im using the loopfunctions and the MoveEntity to move the robots and not the differential steering actuator as in the examples.
This is not the way ARGoS is intended to be used. If you want a robot to move, you must do it in the controller. Why are you using the loop functions instead?
I've been trying to add the accumulation of the sensory information to the robot current location, since both are vectors and it could lead to be nearer to the light source with every iteration, yet it is not really working.
The information you provide is not sufficient to understand the problem. If you post the code you sent, it might be easier to help you. However, consider putting your code in an ARGoS controller as shown in the examples.

Cheers,
Carlo
I made ARGoS.

ahyoussef
Posts: 13
Joined: Sat Sep 03, 2016 3:15 pm

Re: move footbot based on light intensity

Postby ahyoussef » Fri Sep 23, 2016 4:41 pm

Dear Carlo,

Thank you, Helpful as always.

The reason why am using the loop functions, is because i need at every step/iteration/loop to reevaluate the global maxima and the local maxima, which are the potentiometers to my PSO algorithm, also the cost function is the light intensity that is being calculated from within the controller of the footbot.

is there a way in the footbot controller to control and re-evaluate the motion at every step/tick of the logic or should i add a function into the controller model and call it at the loop-function Pre/Post step for every footbot controller instance? (NB: i need to know the current position of the footbot at every step as well)

Regarding the accumulation vector, the light sensors within the footbot are i believe 24 (0-23 indices) and each yields the amount of light read by that sensor, in the examples (flocking, foraging) the code shows that there's an accumulator vector cAccum that adds all the lengths and angles of each sensor of the 24, then use this vector to direct the motion to the actuators and hence the robot moves towards or away from the light source (phototaxis or anti-phototaxis).

in my case, what i am trying to do is a little different, since am doing an optimization function, im trying to minimize the distance between the robot and the light source, based on the sensory information received.

So my conclusion was to use the heading vector (the cAccum vector) and add it to the current position of the footbot, which logically should put the footbot in the correct place (closer to the light source if the sensors picked up any light). However, this is not happening with me currently, ill try to post the code later on.

Thank you very much Carlo.

ahyoussef
Posts: 13
Joined: Sat Sep 03, 2016 3:15 pm

Re: move footbot based on light intensity

Postby ahyoussef » Mon Oct 03, 2016 9:40 pm

Hello All,

Below is my code, it needs pretty much cleaning up, since i've been moving it from the LoopFunctions to the FootBot controller.

My issue currently is that im not able to move the robot the new X,Y coordinates and i have to reach there via the linear velocity approach, which is a heading and length towards the target position (similar to calculateVectorToLight function). while using the loop functions enables me to know and set the location of the footbot and hence get the PSO algorithm to actually run as required.

Side Question that might help me out, is there a way to know the location of the light relative to each FootBot from the sensors? if yes, How so?

attached is the code files for both the controller and the loopfunction, and please excuse the massive comments inside the code it is not the cleanest i admit.

Any help would be very much appreciated, ive been stuck in this for weeks and im incapable of figuring it out on my own
Attachments
dpso_loop_functions.h
(1.83 KiB) Downloaded 519 times
dpso_loop_functions.cpp
(8.74 KiB) Downloaded 506 times
footbot_dpso.h
(6.69 KiB) Downloaded 502 times
footbot_dpso.cpp
(11.19 KiB) Downloaded 564 times

ahyoussef
Posts: 13
Joined: Sat Sep 03, 2016 3:15 pm

Re: move footbot based on light intensity

Postby ahyoussef » Tue Oct 04, 2016 7:15 pm

Dears,

Thanks for the responses, naming Professor Carlo.

I've figured that the problem is in the cartesian coordinate system translation to the polar system that the footbot uses. a FootBot only knows the magnitude and angle respect to its own direction/heading, not the global in contrast to what i was originally thinking, which lead the footbots to be running in circles all the time or rotating around their axis.

i should use a translation-rotation matrix for each footbot to make sure the robot is aligned to the global universe (where the light is located), hence i can be able to use the Euclidean distance as a cost function between the light and the robot.

ahyoussef
Posts: 13
Joined: Sat Sep 03, 2016 3:15 pm

Re: move footbot based on light intensity

Postby ahyoussef » Wed Oct 05, 2016 8:59 pm

speaking too fast without sleep is not the best of ideas.

the accumulator is accumulating the light intensity and the sensor angle (from the heading and placed on the footbot) which are 24 sensors over 360 degrees, giving angles of 15 degrees to each sensor.

my question to professor Carlo now would be if there's any way to know where the light was placed on the map from the sensors (even if relative to the global origin) so that i can calculate the euclidean distance between the footbot and the light source and based on the result decide if this is the best direction to move or not?

any help would be much appreciated

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

Re: move footbot based on light intensity

Postby pincy » Sun Oct 09, 2016 3:02 am

The reason why am using the loop functions, is because i need at every step/iteration/loop to reevaluate the global maxima and the local maxima, which are the potentiometers to my PSO algorithm,
You do this in the loop functions PreStep() method. The idea is that you add a method to your controller that allows the loop functions to add this magically calculated information, and then use the information in the controller. Something like this:

Code: Select all

/* * In the controller * 1. Add a method to set the global best * 2. Use the positioning sensor to know your global position * 3. Calculate the relative vector from to the global */ #include <argos3/plugins/robots/generic/control_interface/ci_positioning_sensor.h> class CMyController : public CCI_Controller { public: ... void SetGlobalBest(const CVector2& c_best); private: ... /* The positioning sensor, don't forget to initialize it in Init() */ CCI_PositioningSensor* m_pcPosition; ... /* Relative vector from me to the global best */ CVector2 m_cMeToBest; }; CMyController::SetGlobalBest(const CVector2& c_best) { /* Calculate relative vector from me to the global best in 3D */ CVector3 cMeToBest3 = c_best - m_pcPosition->GetReading().Position; cMeToBest3.Rotate(m_pcPosition->GetReading().Orientation.Inverse()); /* Keep the 2D coordinates */ m_cMeToBest.Set(cMeToBest3.GetX(), cMeToBest3.GetY()); } /* * In the loop functions * */ // TODO: set the right path here // TODO: don't forget to link the loop functions library to the controller library! #include "my_controller.h" ... CMyLoopFunctions::PreStep() { CVector2 cGlobalBest; // TODO: calculate the position of the global best ... /* Tell the robots about the global best */ CSpace::TMapPerType& m_cFootbots = GetSpace().GetEntitiesByType("foot-bot"); for(CSpace::TMapPerType::iterator it = m_cFootbots.begin(); it != m_cFootbots.end(); ++it) { /* Get handle to foot-bot entity and controller */ CFootBotEntity& cFootBot = *any_cast<CFootBotEntity*>(it->second); CMyController& cController = dynamic_cast<CMyController&>(cFootBot.GetControllableEntity().GetController()); /* Set global best for this robot */ cController.SetGlobalBest(cGlobalBest); } ... }
Cheers,
Carlo
I made ARGoS.

ahyoussef
Posts: 13
Joined: Sat Sep 03, 2016 3:15 pm

Re: move footbot based on light intensity

Postby ahyoussef » Sun Oct 09, 2016 7:05 pm

Professor Carlo,

Thank You so much, helpful as always.

i've figured what you explained out few days ago, and have been thinking that this is the right/better way to do it.

Let me elaborate a little more about my problem so that it is more clear, im sorry if my past attempts are not clear enough.

" i am using PSO to find the light source in the arena, based on light intensity received from the robots' sensors, and keep minimizing the distance (euclidean) between the robot and light source till the global minima is found. in case of no light was received the robots move randomly in the arena till the light is received by one of the robots. Next step would be that the robots starts to cascade the information using RAB sensors instead of my intervention to pass them from the loop function to the controllers"

to test validity of my approach i previously used the MoveEntity and assumed knowledge of the light source in the arena, and it was a success, so the initial PSO actually works in logic.

then i updated the code to be working from the loop function and the controller as you advised before and as you just mentioned above.

Now i am able to adjust the local heading towards the light source (using the linearSpeed function, and would try the rotation function you kindly mentioned above), and from the positioning sensor of the footbot i am able to know the new global heading and the global position.

however, i want to cease the moment and ask a question if you have the time and capacity to respond to it:
1) the light sensor uses the R = (I/X)^2 as the function, for every sensor, i guess i have both R and I (R as the reading from every sensor i've seen it from 0-1, and I is the reference Intensity of the light source that is set from the experiment XML file, Intensity attribute) from the equation and simple substitution should suffice to get the distance from the sensor to the light source, is this correct? if yes, what are the units returned cms/meters/cartesian delta? if not, how can i get the distance?

Another quick Quesiton: would the resulting value from Question 1 above yield the global location of the light source in cartesian coordinates if added to the calculating robot?

Thank You a lot for your kind help and support

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

Re: move footbot based on light intensity

Postby pincy » Thu Oct 13, 2016 4:41 am

Hello,
from the equation and simple substitution should suffice to get the distance from the sensor to the light source, is this correct?
Have a look at the way the reading is calculated at

https://github.com/ilpincy/argos3/blob/ ... r.cpp#L104

Each light adds something to the sensor readings. If you have only one light, there will be one sensor that gets the maximum exposure to the light (and thus will have the largest reading); the sensors around will get a little bit of light, with lower readings.

So, if you have only one light and you want to estimate the distance to that light, consider only the sensor with the highest reading.

The reading is calculated by the function at:

https://github.com/ilpincy/argos3/blob/ ... or.cpp#L33

which is a decreasing exponential. You can invert it pretty easily, but this would work well only if noise is not added to the sensor readings. Without noise, it's all pretty unrealistic.

If your problem is to have a sort of global maximum you give the robots to refer to, I think it would be better if you simply gave that global position to the robots "magically" and use the code I sent you above. The light would not be anyway particularly convincing in a paper, so I wouldn't bother making this extra effort.

Cheers,
Carlo
I made ARGoS.

ahyoussef
Posts: 13
Joined: Sat Sep 03, 2016 3:15 pm

Re: move footbot based on light intensity

Postby ahyoussef » Mon Oct 17, 2016 11:07 pm

Thank You Professor Carlo,

Sorry for the delayed response, i didnt get the notification from the forum that you replied.

My work is to study the difference between multiple starting points vs single starting point, implementing a search mechanism is not part of my work. however i'm trying to simulate the search parameters via the light-sensor following method. in a real scenario this could be replaced by heat sensor, CO sensor, XRay combined with Image Processing, etc....

Two important factors that would affect my work, the Search Technique and the cost function, currently i'd be testing Euclidean Distance and Mahalanobis Distance as cost functions, and the light sensor as the search for both


Return to “How to... ?”