![]() |
ros2_control - jazzy
|
Base class for MuJoCo ROS 2 control plugins. More...
#include <mujoco_ros2_control_plugins_base.hpp>

Public Member Functions | |
| virtual bool | init (rclcpp::Node::SharedPtr node, const mjModel *model, mjData *data)=0 |
| Initialize the plugin. | |
| 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 | pre_step (mjData *) |
| Called immediately before every simulation step on the physics thread. Default does nothing. | |
| virtual void | on_reset (mjData *) |
| Called after a world reset (ResetWorld service or UI reset). Default does nothing. | |
| virtual void | cleanup ()=0 |
| Cleanup the plugin. | |
Base class for MuJoCo ROS 2 control plugins.
Plugins extend mujoco_ros2_control with custom behavior, e.g. publishing extra topics or applying external forces.
Four optional hooks are available. Override whichever fits your use case:
|
pure virtual |
Cleanup the plugin.
Implemented in external_plugin_test::TestPlugin, mujoco_ros2_control_plugins::BaseVelocityPlugin, mujoco_ros2_control_plugins::CameraPlugin, mujoco_ros2_control_plugins::ExternalWrenchPlugin, mujoco_ros2_control_plugins::FreeJointStatePublisherPlugin, mujoco_ros2_control_plugins::FtsGravCompPlugin, mujoco_ros2_control_plugins::HeartbeatPublisherPlugin, mujoco_ros2_control_plugins::Mujoco3dLidarPlugin, and mujoco_ros2_control_plugins::RangefinderLidarPlugin.
|
pure virtual |
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 |
Implemented in external_plugin_test::TestPlugin, mujoco_ros2_control_plugins::BaseVelocityPlugin, mujoco_ros2_control_plugins::CameraPlugin, mujoco_ros2_control_plugins::ExternalWrenchPlugin, mujoco_ros2_control_plugins::FreeJointStatePublisherPlugin, mujoco_ros2_control_plugins::FtsGravCompPlugin, mujoco_ros2_control_plugins::HeartbeatPublisherPlugin, mujoco_ros2_control_plugins::Mujoco3dLidarPlugin, and mujoco_ros2_control_plugins::RangefinderLidarPlugin.
|
inlinevirtual |
Called after a world reset (ResetWorld service or UI reset). Default does nothing.
| data | Pointer to the live MuJoCo data in its post-reset state. |
Reimplemented in external_plugin_test::TestPlugin.
|
inlinevirtual |
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 in mujoco_ros2_control_plugins::BaseVelocityPlugin, and mujoco_ros2_control_plugins::ExternalWrenchPlugin.
|
inlinevirtual |
Same as update_write(). Default does nothing.
| model | Pointer to the MuJoCo model |
| data | Pointer to a recent snapshot (not the live mj_data_) |
|
inlinevirtual |
Called once per read() cycle, on the control thread, before the state is handed to ros2_control. Default does nothing.
Only the control state fields of data are valid (time, qpos, qvel, act, qfrc_actuator, sensordata, ctrl), all from the same physics step. Derived quantities (e.g. site_xpos) are stale: call mj_kinematics() or similar on data if needed. Changes to the control state fields are what ros2_control reads.
| model | Pointer to the MuJoCo model |
| data | Scratch data holding the latest control state, modify it in place |
Reimplemented in external_plugin_test::TestPlugin, and mujoco_ros2_control_plugins::FtsGravCompPlugin.
|
inlinevirtual |
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.
Plugins run in order and can read and rewrite ctrl/qfrc_applied. The default forwards to the deprecated update() so plugins that still override it keep working.
| model | Pointer to the MuJoCo model |
| data | Pointer to a recent snapshot (not the live mj_data_) |
Reimplemented in external_plugin_test::TestPlugin, mujoco_ros2_control_plugins::CameraPlugin, mujoco_ros2_control_plugins::FreeJointStatePublisherPlugin, mujoco_ros2_control_plugins::HeartbeatPublisherPlugin, mujoco_ros2_control_plugins::Mujoco3dLidarPlugin, and mujoco_ros2_control_plugins::RangefinderLidarPlugin.