Page 1 of 1

Kilobot and collision detection

Posted: Sun Oct 10, 2021 3:07 pm
by AntonioC
My kilobots move randomly in the simulator thanks to a random time for advancement and rotation. By means of the advancement and rotation time I can calculate the distance traveled together with the direction. I have a problem. Given a random advance time, if the kilobot encounters another kilobot or a wall it will not travel the full set distance but travel a shorter distance. How can I solve this problem?

Code: Select all

void loop(){ flag = rand() % 1 if(flag == 0){ set_color(RGB(1, 0, 0)); spinup_motors(kilo_turn_left, 0); randomAngle = rand() % 100 //To be defined. delay(randomAngle); }else{ set_color(RGB(1, 0, 0)); spinup_motors(kilo_turn_left, 0); randomAngle = rand() % 100 //To be defined. delay(randomAngle); } set_color(RGB(0, 1, 0)); spinup_motors(); set_motors(kilo_straighy_left, kilo_straight_right); randomTime = rand() % 8000 + 1000 distanceM = randomTimeToM(randomTime); delay(randomTime); set_color(RGB(1,0,1)); set_motors(0,0); delay(800); }

Re: Kilobot and collision detection

Posted: Sun Oct 10, 2021 5:43 pm
by pincy
The Kilobot has no means to detect collisions (it has no proximity sensor nor wheel encoders), so there really isn't anything you can do with it.

These limitations are pretty much the entire point of using a robot like the Kilobot. If you want a smarter robot, use the foot-bot – it has proximity sensors, encoders, and a distance scanner. If you want a commercial robot, the Khepera IV is also available as a plug-in.