Collision Detection - TomHulme/306-Swarm-Robotics-Project GitHub Wiki

Overview

This is by using the current robots position and checking if it was in the same position during the previous cycle. If so, then the robot has collided with another robot. The design choice was made not to employ a similar method of wall detection used in the Sheep movement. Instead the more simple option was to use the nav_msgs::Odometry topic implemented in the example code provided during the 1st week of the project and extending it compare positions of previous states.

Getting Stuck

Once a robot is stuck (in the same position for more than one cycle), then the robot reverses and rotates at a random velocity for 1 cycle. A random number was chosen for the velocities because it reduces robots getting stuck in the same position if all of the reversing was using the same velocity.

As the position has changed from doing this movement, the robot continues moving forward normally. It is likely that it will collide a few times while it is trying to move to open space. This is normal behaviour, and it will eventually clear itself of the robot it has collided with and continue moving to open space.