A Rapidly-exploring Random Tree (RRT) implementation in ROS1 for planning a collision-free path from a start position to a goal position in a 2D occupancy grid map.
RRT.Demo.mov
- Publishes planned path using
nav_msgs/Path - Visualization of tree growth and path in OpenCV window
- Map loading via
map_server - Customizable parameters via YAML config
- Easily integrates with RViz for visualization
- ROS1 (Melodic or Noetic recommended)
map_server,rviz,cv_bridge,OpenCV- Properly sourced ROS workspace with the
rrt_plannerpackage
cd ~/catkin_ws
catkin_make
source devel/setup.bashroslaunch rrt_planner rrt_planner.launchThis will:
- Start
map_serverto publish the map - Start
rvizwith the given config - Start
rrt_planner_nodeto begin planning
Make sure your map.yaml file and corresponding image (JPG/PGM/PNG) are correctly placed under cfg/. The launch file will load it automatically.
To run the planner again, kill the ROS Node and repeat steps 1 - 3
Use RViz tools:
- Click
2D Pose Estimateto set the start position - Click
2D Nav Goalto set the goal position
All tunable parameters can be set in cfg/config.yaml:
map_topic: "/map"
init_pose_topic: "/initialpose"
goal_topic: "/move_base_simple/goal"
path_topic: "/path"
max_iterations: 2000
step_size: 30
threshold_distance: 40
draw_tree_delay: 100
enable_visualization: trueYou can adjust these values to influence the RRT behavior and visualization.
max_iterations: The number of iterations the algorithm runs for before terminationstep_size: The maximum incremental distance that a new, random point is placed away from the nearest node in the existing treedraw_tree_delay: The delay in milliseconds between each tree update during visualisationenable_visualisation: Boolean that toggles whether each step of the RRT algorithm is shown when running. Setting to 'true' shows each step.
- If
enable_visualization: true, tree growth and path are shown in an OpenCV window. - Tree is drawn in blue, path from start to goal in orange, goal in red, start in green.
-
Subscribed:
/map(nav_msgs/OccupancyGrid)/initialpose(geometry_msgs/PoseWithCovarianceStamped)/move_base_simple/goal(geometry_msgs/PoseStamped)
-
Published:
/path(nav_msgs/Path)
- Use
rqt_graphto inspect topic connections - Add
ROS_INFO_STREAMlogs for runtime data - Confirm
map_serveris correctly loading the map
Shawn Chan