This is a simple ROS demonstration of a mass-spring-damper system. In the ROS system we have two nodes: the first represents the dynamics and the second one is the controller.
The system's equations of motion:
and after laplace transformation (with zero I.C) we get a second order system:
where the natural frequency
You can choose the system's parameters m, k and c and choose the initial condition x0, v0 and a0 and set them in the dynamics parameters file.
You can write your own controller to try stabilize the system for a given setpoint.
the default controller is a simple PID controller with the following form:
you can tune the controller gains,
clone the repository to your local machine:
git clone [email protected]:citros-garden/mass_spring_damper.git
open the repository in the VScode:
cd ~/mass_spring_damper
code .
open the repository in the container from VScode with reopen in container option.
build and source the workspace:
colcon build
source install/local_setup.bash
Use VSCode tasks. build with build and then launch simulator with launch (default controller).
you can run the free-system without controller with this launch file:
ros2 launch dynamics dynamics.launch.py
to run the default controller:
ros2 launch dynamics dynamics_controller.launch.py
Open the project in a devcontainer with reopen in container option in VSCode, all the development environment is ready for further development.
