ros2_control - kilted
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | List of all members
external_plugin_test::TestPlugin Class Reference
Inheritance diagram for external_plugin_test::TestPlugin:
Inheritance graph
[legend]
Collaboration diagram for external_plugin_test::TestPlugin:
Collaboration graph
[legend]

Public Member Functions

bool init (rclcpp::Node::SharedPtr node, const mjModel *, mjData *) override
 Initialize the plugin.
 
void update_write (const mjModel *, mjData *) override
 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.
 
void update_read (const mjModel *, mjData *data) override
 Called once per read() cycle, on the control thread, before the state is handed to ros2_control. Default does nothing.
 
void on_reset (mjData *) override
 Called after a world reset (ResetWorld service or UI reset). Default does nothing.
 
void cleanup () override
 Cleanup the plugin.
 
- Public Member Functions inherited from mujoco_ros2_control_plugins::MuJoCoROS2ControlPluginBase
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.
 

Static Public Attributes

static constexpr double kReadOverride = 42.0
 

Member Function Documentation

◆ cleanup()

void external_plugin_test::TestPlugin::cleanup ( )
inlineoverridevirtual

◆ init()

bool external_plugin_test::TestPlugin::init ( rclcpp::Node::SharedPtr  node,
const mjModel *  model,
mjData *  data 
)
inlineoverridevirtual

Initialize the plugin.

Parameters
nodeShared pointer to the ROS 2 node for accessing parameters
modelPointer to the MuJoCo model
dataPointer to the MuJoCo data
Returns
true if initialization was successful
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.

Implements mujoco_ros2_control_plugins::MuJoCoROS2ControlPluginBase.

◆ on_reset()

void external_plugin_test::TestPlugin::on_reset ( mjData *  )
inlineoverridevirtual

Called after a world reset (ResetWorld service or UI reset). Default does nothing.

Parameters
dataPointer to the live MuJoCo data in its post-reset state.

Reimplemented from mujoco_ros2_control_plugins::MuJoCoROS2ControlPluginBase.

◆ update_read()

void external_plugin_test::TestPlugin::update_read ( const mjModel *  ,
mjData *   
)
inlineoverridevirtual

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.

Parameters
modelPointer to the MuJoCo model
dataScratch data holding the latest control state, modify it in place

Reimplemented from mujoco_ros2_control_plugins::MuJoCoROS2ControlPluginBase.

◆ update_write()

void external_plugin_test::TestPlugin::update_write ( const mjModel *  model,
mjData *  data 
)
inlineoverridevirtual

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.

Parameters
modelPointer to the MuJoCo model
dataPointer to a recent snapshot (not the live mj_data_)

Reimplemented from mujoco_ros2_control_plugins::MuJoCoROS2ControlPluginBase.


The documentation for this class was generated from the following file: