Class MuJoCoROS2ControlPluginBase

Class Documentation

class MuJoCoROS2ControlPluginBase

Base class for MuJoCo ROS 2 control plugins.

This is an example base class that plugins can inherit from. Plugins can extend the functionality of mujoco_ros2_control by implementing custom behaviors.

Public Functions

virtual ~MuJoCoROS2ControlPluginBase() = default
virtual bool init(rclcpp::Node::SharedPtr node, const mjModel *model, mjData *data) = 0

Initialize the plugin.

Note

This method will be called once when the plugin is loaded. It can be used to read parameters, set up publishers/subscribers, etc. The node will be a child of the main mujoco_ros2_control node, so parameters should be namespaced accordingly.

Parameters:
  • node – Shared pointer to the ROS 2 node for accessing parameters

  • model – Pointer to the MuJoCo model

  • data – Pointer to the MuJoCo data

Returns:

true if initialization was successful

virtual void update(const mjModel *model, mjData *data) = 0

Update the plugin (called every simulation step)

Note

This method will be called at the end of the mujoco_ros2_control read loop, before the update loop of controllers and the write loop. This means that changes to the data here will be visible to controllers and will affect the next simulation step.

Note

This method will be called in a real-time thread, so it should avoid blocking operations and should be efficient.

Parameters:
  • model – Pointer to the MuJoCo model

  • data – Pointer to the MuJoCo data

virtual void cleanup() = 0

Cleanup the plugin.