Skip to content

Visual Line Following (Gazebo)

Hint

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

  • PC:Ubuntu (≥20.04) + ROS2 (≥Foxy)

Make sure that you have completed the configuration of the Gazebo virtual simulation environment,and then try to perform a 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 launched, you can see the yellow guide line, and the simulated robot is at the beginning of the guide line.

image-20230624012441856

View 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 patrols

There is also another more complex patrol map in the code repository, and you are welcome to try to rewrite the patrol code yourself.

Copy the line patrol model

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

image-20230624014733362

Modify the patrol map

Modify the originbot_follow_line_gazebo.launch.py in the launch folder of the originbot_gazebo feature pack and modify the simulation environment file to the following values:

image-20230624014931172

Save and close when the modifications are complete.

Start the line patrol environment

Recompile the workspace in the root directory of the workspace to ensure that the above configurations take effect:

$ colcon build

Run the following command on the PC:

$ ros2 launch originbot_gazebo originbot_follow_line_gazebo.launch.py

After the launch is successful, you can see a more complex map, you can try it yourself, welcome to share the effect of successful operation to the Guyueju community

image-20230624014120181

图片1