Optional Exploration
ROS2-Based Rotary Inverted Pendulum Platform
This page is provided for interested students who want to explore how a physical rotary inverted
pendulum can be organized as a ROS2 system. It is not required for the core course assessment,
but it offers a practical route from embedded control to distributed robotic software.
Code access.
Download the ROS2 package here or receive it through the course group.
Why ROS2?
In the basic RIP experiments, the STM32 board performs real-time sensing and low-level control.
ROS2 adds a higher-level software layer on the PC: serial communication, state publishing,
command management, visualization, and experiment logging can be separated into independent nodes.
System architecture
The platform follows a PC--STM32 structure. The STM32 sends sensor and controller data through
a high-speed serial link. The PC receives these logs, converts them into ROS2 messages, manages
commands, and displays real-time 2D/3D visual feedback.
Workspace structure
rip_interfaces
Defines RipState.msg and RipCommand.msg for state feedback and command transmission.
rip_serial_bridge
Reads STM32 serial logs, publishes /rip/state, and forwards start/stop commands to the board.
rip_manager
Provides a management layer for control modes, stable-control settings, and exported RL network headers.
rip_visualizer
Implements the ground-control interface with live angle display, PWM monitoring, plots, and 3D animation.
rip_bringup
Provides the launch file that starts the serial bridge, manager, and visualizer together.
ROS2 data flow
STM32 firmware
sensor logs / PWM / mode
→
rip_serial_bridge
serial to ROS2 messages
→
/rip/state
theta, alpha, velocities, PWM
→
rip_visualizer
GUI, plots, 3D view
Commands flow in the reverse direction through /rip/cmd or /rip/raw_cmd.
The bridge converts high-level commands such as GO and STOP into serial commands sent to the STM32.
Quick-start tutorial
-
Install ROS2 and Python dependencies.
The workspace was prepared for a ROS2 Python workflow. Students should install ROS2,
colcon,
pyserial, PyQt5, numpy, and matplotlib on the experiment PC.
-
Download and extract the ROS2 code package.
Download the ROS2 ZIP package
from this website or obtain it through the course group, then open the included workspace.
unzip RIP_ROS2_Optional_Platform_Code.zip
cd RIP_ROS2_Optional_Platform_Code/ros2/rip_ros2_ws
-
Build the ROS2 packages.
source /opt/ros/jazzy/setup.bash
rosdep install --from-paths src --ignore-src -r -y
colcon build --symlink-install
source install/setup.bash
-
Connect the STM32 board.
Check the serial device, for example
/dev/ttyACM0 or /dev/ttyUSB0.
The default launch file uses /dev/ttyACM0 and a baud rate of 921600.
-
Launch the platform.
ros2 launch rip_bringup rip.launch.py port:=/dev/ttyACM0 baud:=921600
-
Observe the state topics.
ros2 topic list
ros2 topic echo /rip/state
Safety notes
Always keep the rotary arm clear before enabling the motor. Start with a conservative PWM limit,
check sensor signs before closing the loop, and use the GUI STOP command immediately if the pendulum
falls or the motor response is abnormal. This ROS2 page is intended for exploration and debugging,
not for unsupervised operation.
Suggested student exploration
- Visualize
/rip/state and compare ROS2 timestamps with STM32 timing logs.
- Modify the GUI layout to display only selected variables such as
alpha, theta, and pwm.
- Record data from GO to STOP and generate publication-quality plots for controller comparison.
- Compare LQR, MPC, and exported RL policies under the same ROS2 logging interface.
- Extend the workspace for remote experiments, where the RIP hardware stays in the lab while the student monitors data from another computer.