Skip to content

Visual Line Following (Gazebo)

Hint

The operating environment and software and hardware configurations are as follows:

  • PC:Ubuntu (≥22.04) + ROS2 (≥humble)

Make sure that the configuration of the Gazebo virtual simulation environmentis complete. Next, try to perform visual line patrol in the simulation environment.

Start the virtual line patrol environment

Run the following command on the PC:

ros2 launch originbot_gazebo originbot_follow_line_gazebo.launch.py

After Gazebo is successfully started, you can see the yellow guide line and the simulated robot is at the starting point of the guide line.

image-20230624012441856

Viewing Camera Image Data

Start Rviz, add the Image display item, and you can see the real-time image data:

ros2 run rviz2 rviz2

2023-06-24 012755

Start the visual line patrol

Reopen a terminal and start the visual line patrol function:

ros2 run originbot_demo line_follower

After successful startup, the simulated robot starts to patrol the line, and at the same time, a real-time display of the patrol line detection result pops up.

ezgif-1-d9c11f024a

More complex visual line inspection

Another more complex line patrol map is also provided in the code repository. You are welcome to try to rewrite the line patrol code yourself.

Copy the line patrol model

Copy the "track2" model folder in the models file in the originbot_gazebo function package to the ~/.gazebo/models folder:

image-20230624014733362

Modify the patrol map

Modify originbot_follow_line_gazebo.launch.py ​​in the launch folder of the originbot_gazebo function package and modify the simulation environment file to:

image-20230624014931172

Save and close after modification.

Start the line patrol environment

Recompile the workspace in the root directory of the workspace to ensure that the above configuration takes effect:

colcon build

Run the following command on the PC:

ros2 launch originbot_gazebo originbot_follow_line_gazebo.launch.py

After successful startup, you can see a more complex map. You can try it yourself. You are welcome to share the successful results to the Guyuehome community

image-20230624014120181

图片1