StepperBot is a minimal, end-to-end demonstration of controlling a real stepper motor using ros2_control, an Arduino Nano, and a standard STEP/DIR driver.
This repository includes:
- custom ros2_control hardware plugin (
stepperbot_controller) - URDF + ros2_control description (
stepperbot_description) - Arduino firmware project (
stepperbot_firmware) - bringup launch to load the robot model, hardware interface, and controllers
Everything is designed to be simple, readable, and extendable.
- ROS 2 Jazzy (tested)
- PlatformIO (VS Code extension)
- Arduino Nano
- Stepper driver
- Stepper motor
git clone git@github.com:LevinTamir/ros2_control_stepper_demo.git stepperbot_ws
cd stepperbot_ws/The firmware for driving the stepper motor is located in:
stepperbot_ws/
├── src/
└── stepperbot_firmware/ # <-- HERE
To flash the Arduino Nano, install the PlatformIO VS Code Extension.
After installing the extension:
- Open VS Code
- Go to File → Open Folder and select
stepperbot_firmware/ - In the PlatformIO toolbar, click Build (checkmark icon in the bottom bar)
- Click Upload (right-arrow icon) to flash the firmware
And that's it.
cd ~/<path-to-dir-location>/stepperbot_ws # Replace with your local directory location
colcon build
source install/setup.bashWorkspace structure:
stepperbot_ws/
├── src/
│ ├── stepperbot_controller/
│ └── stepperbot_description/
├── install/
├── log/
├── build/
└── stepperbot_firmware/
After connecting the Arduino and Motor, run:
cd ~/<path-to-dir-location>/stepperbot_ws # Replace with local directory location
source install/setup.bash
ros2 launch stepperbot_controller stepperbot_controllers.launch.pyIf your Arduino Nano is on another port:
source install/setup.bash
ros2 launch stepperbot_controller stepperbot_controllers.launch.py serial_port:=/dev/<USB-PORT>To launch Rviz, run:
source install/setup.bash
ros2 launch stepperbot_description display.launch.pyTo send commands to the motor, run:
ros2 topic pub /stepper_position_controller/commands \
std_msgs/msg/Float64MultiArray "data: [1.0]" # Change radians as wanted