![]() |
ros2_control - kilted
|
Drives a mobile/floating-base robot from a commanded planar body velocity (vx, vy, yaw-rate) by writing a hard kinematic override of the base's free-joint velocity directly into data->qvel every cycle. More...
#include <base_velocity_plugin.hpp>


Public Member Functions | |
| bool | init (rclcpp::Node::SharedPtr node, const mjModel *model, mjData *data) override |
| Initialize the plugin. | |
| void | pre_step (mjData *data) override |
| Called immediately before every simulation step on the physics thread. Default does nothing. | |
| void | cleanup () override |
| Cleanup the plugin. | |
Public Member Functions inherited from mujoco_ros2_control_plugins::MuJoCoROS2ControlPluginBase | |
| virtual void | update_read (const mjModel *, mjData *) |
Called once per read() cycle, on the control thread, before the state is handed to ros2_control. Default does nothing. | |
| virtual void | update_write (const mjModel *model, mjData *data) |
Called once per write() cycle, on the control thread, after the hardware interface has staged the controller commands and right before they are sent to the simulation. | |
| virtual void | update (const mjModel *, mjData *) |
Same as update_write(). Default does nothing. | |
| virtual void | on_reset (mjData *) |
| Called after a world reset (ResetWorld service or UI reset). Default does nothing. | |
Drives a mobile/floating-base robot from a commanded planar body velocity (vx, vy, yaw-rate) by writing a hard kinematic override of the base's free-joint velocity directly into data->qvel every cycle.
Wheel-terrain friction/slip modelling is often unreliable enough to make it a poor foundation for testing navigation stacks. This plugin instead subscribes to a cmd_vel-style topic and, every cycle, writes the (optionally clamped) commanded planar velocity directly into the base body's free-joint qvel entries in data. There is no gain to tune and no convergence delay: the measured body velocity on the driven DOFs is exactly the commanded velocity on the very next simulation step.
The trade-off is that the driven DOFs cannot be influenced by anything else – not contacts, not forces from other bodies rigidly mounted on the base (e.g. a swinging arm). They are simply reasserted every cycle regardless of what the physics engine computed in between.
Only the planar DOFs are driven: world-frame linear x/y (converted from the commanded body-frame vx/vy via the body's current orientation) and body-local yaw-rate about z. Vertical linear velocity and local roll/pitch are left untouched every cycle, so gravity and contacts continue to settle the base onto the ground normally.
body (string, required) - MJCF body name of the base. Must have a <freejoint>; init() fails otherwise, since there is no qvel to override without one. cmd_vel_topic (string, default "cmd_vel") - command topic name. use_stamped_twist (bool, default false) - subscribe to geometry_msgs/TwistStamped instead of geometry_msgs/Twist. max_linear_velocity (double, default +inf) - clamps the commanded planar speed sqrt(vx^2+vy^2) [m/s]; direction is preserved when scaled down. max_yaw_rate (double, default +inf) - clamps the commanded yaw-rate [rad/s]. cmd_timeout (double, default 0.5) - seconds since the last command after which it is treated as zero (safety stop).
|
overridevirtual |
Cleanup the plugin.
Implements mujoco_ros2_control_plugins::MuJoCoROS2ControlPluginBase.
|
overridevirtual |
Initialize the plugin.
| node | Shared pointer to the ROS 2 node for accessing parameters |
| model | Pointer to the MuJoCo model |
| data | Pointer to the MuJoCo data |
Implements mujoco_ros2_control_plugins::MuJoCoROS2ControlPluginBase.
|
overridevirtual |
Called immediately before every simulation step on the physics thread. Default does nothing.
USE WITH CAUTION.
| data | Pointer to the live MuJoCo data, can be modified as needed. |
Reimplemented from mujoco_ros2_control_plugins::MuJoCoROS2ControlPluginBase.