A ROS-based consensus protocol for multiple robots to converge towards the centroid of their positions.
Prerequisite • Compile • Execute • Use • Screenshots
- ROS - An open-source, meta-operating system for your robots. The repository has been tested using ROS Kinetic.
-
Move the package folder (
consensus
) to thesrc
directory of your ROS workspace, for example~/catkin_ws/src/
. -
Open a terminal window and navigate to your ROS workspace directory:
cd ~/catkin_ws/
-
Build the package using the
catkin_make
command:catkin_make
This will compile the package and generate the necessary files for running the ROS nodes.
-
Open a terminal window.
-
Navigate to your ROS workspace directory.
-
Launch the package using the following command:
roslaunch consensus consensus.launch
This will launch the ROS nodes required to run the package.
- Adjust the
x
,y
, andtheta
variables inconsensus.launch
(starting from line 13) to set the initial positions of the additional robots (the first robot is spawned at the center of the workspace). Ensure thatNUM_TURTLES
inconsensus.cpp
is updated to reflect the total number of robots, including the first robot and any additional robots. - Each robot will communicate its position with every other robot in the network.
- The consensus protocol will be executed on each robot in order to determine the centroid(s), which may slightly differ from the theoretical centroid.
- Upon completion, the robots will simultaneously move toward the calculated centroid(s).
- While the protocol is running, various types of information will be printed on the terminal. Wait until the consensus node is shut down or press
ESC
to exit the program at any time.
- Initial positions:
- Turtles move toward the centroid(s):
- Turtles reach the centroid pose(s):