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.

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

  1. 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.
  2. Unzip the workspace.
    unzip rip_ros2_ws_source.zip
    cd rip_ros2_ws
  3. Build the ROS2 packages.
    source /opt/ros/foxy/setup.bash
    colcon build
    source install/setup.bash
  4. 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.
  5. Launch the platform.
    ros2 launch rip_bringup rip.launch.py port:=/dev/ttyACM0 baud:=921600
  6. 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