This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
StepIt is a ROS 2 (Humble) project for controlling stepper motors via a Teensy 4.x microcontroller. It uses ros2_control as the hardware abstraction layer. The robot can run in simulation (fake motors) without any physical hardware.
Install dependencies:
./bin/update.sh # runs: rosdep install --ignore-src --from-paths . -y -rBuild:
./bin/build.sh # colcon build with Debug, compile_commands.json, symlink-installRun all tests:
./bin/test.sh # colcon test + test-result --all --verboseRun a single test package:
colcon test --packages-select stepit_driver --return-code-on-test-failure
colcon test-result --all --verboseRun a specific test binary directly (after build):
./build/stepit_driver/tests/test_default_driverLint/format:
pre-commit run -a # run all pre-commit hooks manually
clang-format-14 -i <file> # format a single C++ fileLaunch the simulation:
source install/setup.bash
ros2 launch stepit_description robot.launch.pyThe project is a ROS 2 workspace with two top-level directories:
src/— ROS 2 packages (ament/colcon)modules/— git submodules (non-ROS C++ libraries)
| Package | Role |
|---|---|
stepit_driver |
Core ros2_control hardware interface plugin (StepitHardware) |
stepit_description |
URDF/xacro robot model, RViz config, controllers config, launch files |
stepit_bringup |
Alternative bringup launch (hardware mode) |
stepit_teleop |
Teleoperation node |
stepit_hardware_tests |
Integration tests requiring real hardware |
cobs_serial |
COBS-encoded serial communication library (ROS 2 package) |
stepit_mcu |
PlatformIO project for Teensy firmware (not built by colcon) |
serial— Low-level cross-platform serial port C++ library (wjwwood/serial)
StepitHardware (a hardware_interface::SystemInterface plugin) delegates all hardware communication to a Driver interface:
DefaultDriver— real hardware, communicates viaCobsSerial→ COBS-encoded serial → TeensyFakeDriver— simulation, usesFakeMotorwithVelocityControl/PositionControlinternallyDefaultDriverFactory/DriverFactory— the factory is injected at construction time; in tests a mock factory is used
The StepitHardware reads joint configuration (motor IDs, max velocity, acceleration) from the URDF <ros2_control> block via HardwareInfo.
StepitHardware → DefaultDriver → CobsSerial (cobs_serial pkg) → serial (submodule) → USB/serial → Teensy
COBS encoding uses zero bytes as packet delimiters. The protocol carries typed request/response messages defined in stepit_driver/msgs/.
Tests use GMock (ament_add_gmock). Mocks live alongside tests:
tests/mock/mock_cobs_serial.hpp— mocks the serial layer fortest_default_drivertests/mock/mock_driver.hpp/mock_driver_factory.hpp— mock the driver fortest_stepit_hardwaretests/fake/fake_hardware_info.hpp— constructsHardwareInfofor unit tests without a URDF
- C++20, compiled with
-Werror -Wall -Wextra -Wpedantic -Wshadow -Wconversion -Wsign-conversion -Wold-style-cast - Formatting:
clang-format-14(pre-commit hook, style defined in.clang-formatif present) - Python formatting:
black - Spell check:
codespell(pre-commit) - Pre-commit hooks run automatically on commit; run
pre-commit run -ato check all files manually
Three GitHub Actions workflows:
industrial_ci.yml— builds and tests in Docker (Ubuntu 22.04 + ROS Humble) via ros-industrial/industrial_cici-format.yml— pre-commit hooks (clang-format-14, black, codespell)ci-ros-lint.yml— ROS-specific linters
Local CI can be run with Nektos act.