This ROS package demonstrates a path planner for a multiple agents scenario. This package includes two nodes: Planner and Agent. The Planner nodes provides a path planning service that implements A* to find the shortest path between a given start and a given goal on a 11*11 grid. The Agent node publishes the agent's position as well as the found path returned by Planner. For multiple agents scenario, the path of one agent will not be considered by another agent to avoid collision.
This package has been tested under Ubuntu 16.04 and ROS Kinetic. C++ 11 is required for successful compilation.
This package depends only on ROS.
cd catkin_ws/src
git clone https://github.com/mzwang828/mz_wang_intern.git
catkin build
Source the workspace first:
source catkin_ws/devel/setup.bash
To run the 2 nodes individually:
# Start a roscre
roscore
# In a new terminal, run the planner
rosrun mz_wang_intern planner
# To run the agent, serial_ID and start_position are needed
roslaunch mz_wang_intern agent.launch serial_ID:="agent_1" start_position:=[0,0,0]
For the convinience of test, a test.launch file is provided
Run the test.launch file will automatically start 3 nodes: the planner, an agent_1 with start_position [0,0,0] and an agent_2 with start_position [5,5,0]. Rviz will also be started to show the map and path. To run the test case:
# run the test.launch
source catkin_ws/devel/setup.bash
roslaunch mz_wang_intern test.launch
To plan the path, one needs to call the service in a new terminal.
source catkin_ws/devel/setup.bash
# For agent 1
rosservice call /agent_1/update_goal "goal:
x: 5.0
y: 5.0
theta: 0.0"
# For agent 2
rosservice call /agent_2/update_goal "goal:
x: 10.0
y: 8.0
theta: 0.0"
Note: Once you source the workspace in the terminal, you can use TAB Completion to fill the service request automatically, and you only need to change those numbers, as shwon below.
Avoid another agent's path. The red agent is avoiding the path of the green agent:
Service list: