Compile MechanicsDSL physical systems directly to complete ROS2 packages.
mechanicsdsl-ros2 provides a dedicated ROS2 integration layer for MechanicsDSL. Physical systems defined in DSL notation compile to complete, buildable ROS2 packages — no manual C++ required for the physics layer.
The first generated package, currently including:
| Node | System | Rate | Topics |
|---|---|---|---|
pendulum_node |
Simple pendulum | 250 Hz | /mechanicsdsl/pendulum/state, /mechanicsdsl/pendulum/energy |
double_pendulum_node |
Double pendulum | 200 Hz | /double_pendulum/state |
| Message | Fields |
|---|---|
PendulumState |
header, theta, omega, energy, energy_drift, sim_time |
SystemState |
header, q[], q_dot[], q_ddot[], lambda[], energy, energy_drift, conserved_quantities[], sim_time |
ros2 launch mechanicsdsl_pendulum pendulum.launch.py
ros2 launch mechanicsdsl_pendulum pendulum.launch.py l_m:=0.5 theta0_rad:=0.8
ros2 launch mechanicsdsl_pendulum double_pendulum.launch.py theta1_0:=0.3 theta2_0:=0.2mechanicsdsl-ros2/
├── mechanicsdsl_pendulum/
│ ├── package.xml, CMakeLists.txt
│ ├── msg/ PendulumState.msg, SystemState.msg
│ ├── src/ pendulum_node.cpp, double_pendulum_node.cpp
│ ├── include/mechanicsdsl_pendulum/ pendulum_dynamics.hpp
│ ├── launch/ pendulum.launch.py, double_pendulum.launch.py
│ ├── config/ pendulum_params.yaml
│ └── test/ test_pendulum_eom.cpp, test_pendulum_integration.py
├── docker/ Dockerfile (ROS2 Jazzy + MechanicsDSL)
├── scripts/ build.sh, monitor.sh
└── docs/ getting_started.md, architecture.md, adding_systems.md
# Clone into ROS2 workspace
mkdir -p ~/ros2_ws/src && cd ~/ros2_ws/src
git clone https://github.com/MechanicsDSL/mechanicsdsl-ros2.git
# Build
cd ~/ros2_ws
rosdep install --from-paths src --ignore-src -r -y
colcon build --packages-select mechanicsdsl_pendulum
source install/setup.bash
# Run
ros2 launch mechanicsdsl_pendulum pendulum.launch.pyDocker:
docker build -t mechanicsdsl-ros2:jazzy docker/
docker run --rm -it mechanicsdsl-ros2:jazzyros2 topic echo /mechanicsdsl/pendulum/state
ros2 topic hz /mechanicsdsl/pendulum/state # should be ~250 Hz
# Reset
ros2 topic pub --once /pendulum/reset std_msgs/msg/Bool "data: true"colcon test --packages-select mechanicsdsl_pendulum
colcon test-result --verboseGTests cover EOM correctness, energy conservation, equilibrium stability, and small-angle period accuracy.
See docs/architecture.md for the full node/message/layer diagram.
See CONTRIBUTING.md.
MIT License — see LICENSE.
