ROS 2 Humble project for a TurtleBot3-style robot that follows a dark line and avoids obstacles in Gazebo Classic using camera and LiDAR data.
The project combines three ROS 2 nodes:
line_detector: processes/camera/image_rawand publishes lateral line error on/line_errorobstacle_detector: processes/scanand publishes obstacle state and distance topicscontroller: uses PID line following plus a finite-state obstacle avoidance routine to publish/cmd_vel
.
├── README.md
└── mars_anti2/
├── run.txt
└── src/
└── line_tracker/
├── line_tracker/
│ ├── controller.py
│ ├── line_detector.py
│ └── obstacle_detector.py
├── launch/
│ └── simulation.launch.py
├── worlds/
│ └── line_world.world
├── urdf/
│ └── turtlebot3_burger.urdf
├── config/
│ └── rviz_config.rviz
├── package.xml
├── setup.py
└── README.md
- Ubuntu 22.04
- ROS 2 Humble
- Gazebo Classic
colcon
cd mars_anti2
source /opt/ros/humble/setup.bash
colcon build --packages-select line_tracker
source install/setup.bashcd mars_anti2
source /opt/ros/humble/setup.bash
source install/setup.bash
ros2 launch line_tracker simulation.launch.pyros2 topic echo /line_error
ros2 topic echo /obstacle/detected
ros2 topic echo /obstacle/min_distance
ros2 topic echo /cmd_velThe main controller and perception parameters are defined in:
mars_anti2/src/line_tracker/launch/simulation.launch.py
Important parameters include:
Kp,Ki,Kdlinear_speedmax_angularobstacle_distance_thresholdphase1_turn_durationphase2_forward_durationphase3_turn_durationphase4_forward_duration
- The package-level documentation is also available at
mars_anti2/src/line_tracker/README.md. mars_anti2/run.txtcontains a one-line command sequence for building and launching the project.