Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor fixes to light sensor: wrong id bug. #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

vivek-shankar
Copy link

Dear Carlo,

During our course "Swarm Intelligence", we had an exercise to use the light sensor of the kheperaIV robots. One of the students reported to me that the sensor is reporting false readings. As an approach to fix it, I made some minor changes, kindly look into it and merge them, if they make sense.

Thank you

With best regards,
Vivek

@ilpincy
Copy link
Owner

ilpincy commented Apr 13, 2020

Thanks! Can you explain to me what the problem is?

@vivek-shankar
Copy link
Author

vivek-shankar commented Apr 13, 2020

When the robot is directly facing the light source, it is reporting the right values, but when the light source is either in the left or right of the robot. The sensor is reporting the wrong values. From what I understood, It is basically associating the wrong sensor beam id, when the light source is either on the right or left.

@ilpincy
Copy link
Owner

ilpincy commented Apr 13, 2020

I'm sorry, can you be more precise? The changes you made do not fix the issue you mention. More specifically:

  1. Instead of taking 2 rays around the current sensor (which is the correct approach), you took 6. That's not correct. It would mean that basically all the sensors read a light, even if they point on the opposite side of the robot.
  2. I don't understand that half spacing offset you added. The front sensor has no offset, to the best of my knowledge.

@vivek-shankar
Copy link
Author

Okay, the problem is that the sensor rays that are considered for checking during the current step are not right all the time. More precisely, the logic behind the current implementation is that it takes into consideration the rays that are 180 degrees (90 deg before and after) around the point of the incident of the light on the robot (i.e the center ray). The way the center ray for checking is computed (https://github.com/ilpincy/argos3-kheperaiv/blob/master/src/plugins/robots/kheperaiv/simulator/kheperaiv_light_rotzonly_sensor.cpp#L161) results in the wrong set of rays when the light source is either in the right of the robot or left.
For example, when the current angle to the light source is -4.36 rad WRT the robot, the rays that are chosen to check are -2.3, -1.5, -0.78, 0, and 0.78, even though the closest rays that are directly in between the point of the incident are the rays at 1.5 and 2.3 rad. Now the rays that are checked for are directly behind the light source, the "ScaleReading" function makes the readings of this ray to be zero. However, the sensor rays to be checked are omitted and hence the right rays that should be detecting the light are not computed at all and hence the sensor doesn't work in this scenario.

That is why I did the fix that you are referring to in your first comment. Instead of just checking for a few selections of rays that are relevant based on the current position of the light source, I take into consideration all the rays, since the "ScaleReading" function (https://github.com/ilpincy/argos3-kheperaiv/blob/master/src/plugins/robots/kheperaiv/simulator/kheperaiv_light_rotzonly_sensor.cpp#L177) return zeros for all the rays that are not relevant.
I made an error, I shouldn't be taking 6 rays, I should be taking rays -4 to 4 ( to consider all the rays, that is my error, I thought there were 12 rays but there are only 8.

If you feel that it has to be fixed in other ways, I don't mind. Please feel free to fix it the right way, it was just my way of fixing it :-)

For the second change, I added the half spacing offset because the foot-bot light sensor is using such an offset. I thought the sensors are identical, I just realized it is using different number of rays. So, you can neglect that change and it might not be necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants