Page 1 of 1

Kilobot brightness sensor.

Posted: Sat Oct 30, 2021 12:17 pm
by AntonioC
632 / 5000
Risultati della traduzione
In the simulation the Kilobot, while detecting the light intensity I noticed this:
The further the Kilobot is from the light source, the higher the value.
The closer the kilobot is from the light source, the lower the value.
However, during the experimentation, a very low value appeared to me even if the kilobot was far from the light source. Does this depend on a simulator error or is it a method of simulating noise? How can I possibly exclude the noise?
1 - Light: 394
1 - Light: 595
1 - Light: 601
1 - Light: 688
1 - Light: 488
1 - Light: 575
1 - Light: 365
1 - Light: 337
1 - Light: 41

Re: Kilobot brightness sensor.

Posted: Tue Nov 02, 2021 5:44 pm
by pincy
This is the function used to simulated the light sensor, given the distance to a specific light source. For distances beyond 2.5 the returned reading is 0. For closer distances, the readings follow an exponential that decays with the distance.

I am not sure how you got the values you show, but I guess they depend on where the light is located in the environment. If you share your experiment files, I might try to guess what is going on.

Re: Kilobot brightness sensor.

Posted: Tue Nov 02, 2021 5:56 pm
by AntonioC

Code: Select all

#include<kilolib.h> #include<stdio.h> #include<math.h> #include<stdlib.h> #define LIGHTMAX 50 int randomAngle; int randomForewadr; message_t message; void stopKilobot(){ set_motors(0, 0); set_color(RGB(3, 3, 3)); delay(60000); } void setup(){} void loop(){ //Turn left. set_color(RGB(3, 0, 0)); spinup_motors(); set_motors(kilo_turn_left, 0); randomAngle = rand() % 1000 + 5000; delay(randomAngle); //Move foreward. set_color(RGB(0, 3, 0)); spinup_motors(); set_motors(kilo_straight_left, kilo_straight_right); randomForewadr = rand() % 1000 + 5000; delay(randomForewadr); printf("%d - %d\n", kilo_uid, get_ambientlight()); if(get_ambientlight() <= LIGHTMAX){ stopKilobot(); } } int main(){ kilo_init(); kilo_start(setup, loop); return 0; }

Code: Select all

<?xml version = "1.0"?> <argos-configuration> <framework> <system threads = "0"/> <experiment length="0" ticks_per_second="10" random_seed="124" /> </framework> <controllers> <kilobot_controller id="kbc"> <actuators> <differential_steering implementation="default" /> <kilobot_led implementation="default" /> </actuators> <sensors> <kilobot_light implementation="rot_z_only" show_rays="true" /> </sensors> <params behavior="build/examples/behaviors/simple_movement" /> </kilobot_controller> </controllers> <arena size = "2, 2, 1" center = "0, 0, 0.5"> <light id="l0" position="0,-0.2,0" orientation="0,0,0" color="yellow" intensity="5.0" medium="leds"/> <box id = "W0" size = "0.2, 0.05, 0.05" movable = "false"> <body position = "0, 0.35, 0" orientation = "0, 0, 0"/> </box> <box id = "W1" size = "0.05, 0.65, 0.05" movable = "false"> <body position = "0.125, 0.05, 0" orientation = "0, 0, 0"/> </box> <box id = "W2" size = "0.05, 0.65, 0.05" movable = "false"> <body position = "-0.125, 0.05, 0" orientation = "0, 0, 0"/> </box> <kilobot id = "Kb1"> <body position = "0, 0.2, 0" orientation = "0, 0, 0"/> <controller config = "kbc"/> </kilobot> <kilobot id = "Kb2"> <body position = "0, 0.1, 0" orientation = "0, 0, 0"/> <controller config = "kbc"/> </kilobot> <!-- <light id="l0" position="0,0,0.5" orientation="0,0,0" color="yellow" intensity="10.0" medium="leds"/> --> </arena> <physics_engines> <dynamics2d id = "dyn2d"/> </physics_engines> <media> <led id="leds" /> </media> <visualization> <qt-opengl> <camera> <placements> <placement index="0" position="0,0,8.14689" look_at="0,0,0" up="1,0,0" lens_focal_length="210"/> </placements> </camera> </qt-opengl> </visualization> <loop-functions> </loop-functions> </argos-configuration>

Re: Kilobot brightness sensor.

Posted: Tue Nov 02, 2021 6:00 pm
by pincy
Did you check the code I linked? The function takes two arguments – one related to the linear distance, one related to angular offset. Is the robot keeping the same angular offset throughout the experiment?

Re: Kilobot brightness sensor.

Posted: Tue Nov 02, 2021 6:06 pm
by AntonioC
What do you mean by angular offset?

Re: Kilobot brightness sensor.

Posted: Tue Nov 02, 2021 6:53 pm
by pincy
Please make sure to read the original kilobot paper, as well the paper we wrote on how we modeled it. Most of the questions you've been asking lately are covered in these two papers. Also, please check the code I linked – this way you can see exactly how things are implemented and calculated.

The kilobot has a light sensor that is positioned off-center with respect to the body of the robot. If the sensor is located "in front" of the robot and the light is straight ahead, that's the optimal case – you get the maximum reading for a certain distance. If the robot keeps that distance, say rotating on the spot, as the sensor rotates it also gets a worse angle of reception and the reading value gets lower.