← Back to search

For robotics teachers: ROS2 Basic Motion — Speed Ramping in C++ | #12

The Construct Robotics Institute 32:28

241 views · 10 likes Watch on YouTube ↗

Abrupt velocity commands stress actuators, cause wheel slip, and make motion feel jerky — production robots always shape their velocity profiles smoothly.

This robotics project shows you how to write a ROS 2 C++ node that drives a robot (FastBot Pro from BotBox) through a three-phase RAMP_UP to CRUISE to RAMP_DOWN cycle, stepping linear.x by a fixed increment on every tick of a 20 Hz wall-timer until it hits MAX_SPEED, holding for a fixed cruise window, then symmetrically decelerating back to zero before shutting down the node. Velocity is published as geometry_msgs/msg/Twist on /fastbot_1/cmd_vel while /fastbot_1/scan is continuously monitored — if any reading inside the forward ±30° window falls below 0.35 m, the node transitions straight to EMERGENCY_STOP, zeroes the Twist, and exits safely.

You will learn:

✅ Building a finite state machine in C++ with RAMP_UP, CRUISE, RAMP_DOWN, EMERGENCY_STOP, and DONE states driven by a 20 Hz wall-timer
✅ Implementing time-based linear velocity stepping with clamping to prevent overshoot at either end of the ramp
✅ Using std::chrono::steady_clock to time the cruise phase against a fixed CRUISE_SECS duration
✅ Extracting the forward ±30° window from a 360° sensor_msgs/msg/LaserScan — handling the angular wrap-around at 0 / 2π — and using the minimum range to trigger reactive emergency stops

📁 *ROS project link: https://app.theconstruct.ai/l/729a6518/
🤖️ *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

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