← Back to search

For robotics teachers: ROS2 Basic Motion — Wall Following (Right) in C++ | Open Class #14

The Construct Robotics Institute 45:14

298 views · 8 likes Watch on YouTube ↗

Wall following is one of the most practical reactive behaviours in mobile robotics — it gives a robot the ability to explore unknown corridors and traverse warehouses with nothing more than a single LiDAR.

This robotics project shows you how to write a ROS 2 C++ node that drives FastBot (from BotBox robotics lab kit) parallel to the right-side wall at a target distance of 0.3 m, publishing geometry_msgs/msg/Twist commands on /fastbot_1/cmd_vel via a 20 Hz wall-timer. On every /fastbot_1/scan callback the node slices the 360° LiDAR into five angular segments — front, front-right, right, front-left, and left — and feeds the right and front-right minima into a proportional controller that produces the angular correction. A small state machine handles edge cases: FOLLOW_WALL when a right wall is within range, FIND_WALL gently turning right when contact is lost, and AVOID rotating left in place whenever the front segment drops below 0.35 m.

You will learn:

✅ Slicing a 360° sensor_msgs/msg/LaserScan into five named angular segments, including handling the wrap-around at 0° / 2π for the forward window
✅ Implementing a proportional controller that converts a distance error (right_dist − TARGET_DIST) into a clamped angular velocity, with a secondary correction from the front-right segment to anticipate approaching walls
✅ Building a FOLLOW_WALL / FIND_WALL / AVOID state machine whose transitions are driven entirely by the five segment minima
✅ Tuning KP, MAX_ANGULAR, and distance thresholds to balance responsiveness against oscillation while keeping forward motion smooth



📁 *ROS project link: https://app.theconstruct.ai/l/733d2c58/
🤖️ *Robot & Warehouse Environment Used: BotBot Robot Lab https://www.theconstruct.ai/botbox-warehouse-lab/

Related courses:
* C++ for Robotics (Free): https://app.theconstruct.ai/courses/c-for-robotics-59/
* ROS2 Basics in 5 Days (C++): https://app.theconstruct.ai/courses/ros2-basics-in-5-days-c-325/
* ROS2 Navigation: https://app.theconstruct.ai/courses/ros2-navigation-humble-148/


============================

[For Robotics Teachers Open Class], a weekly series of videos by The Construct Robotics Institute, aims to make robotics education easier by helping teachers teach a wide range of robotics topics through hands-on practice.

Each session provides a ROS-based project (referred to as ROSJECTs 🦾 📁) for all attendees, including notebooks, code, and robot simulations. Led by ROS expert Desire, you'll see how robotics teaching and hands-on practice come together in real time.

*Missed a session? Find recordings & ROSJECTs on https://app.theconstruct.ai/open-classes/*

We're excited to share this series with you! If you have questions or want to explore new topics, drop us a comment below.

Cheers.

*The Construct Robotics Institute | Where Your Robotics Career Happens*

============================

👨‍🏫 Class Creator: Desire (ROS Tutor @The Construct Robotics Institute )
👩‍💻 Class cover designer: Sonia/Ruojun Wang (Marketing @The Construct Robotics Institute )

--
#ai #Robotics #ros #robot #ros2

Category (YouTube): Science & Technology

Playback is via YouTube's official embedded player. Data from YouTube; Exumo is not affiliated with YouTube.