ros2_control - kilted
Loading...
Searching...
No Matches
mujoco_ros2_control_plugins_base.hpp
1// Copyright 2026 PAL Robotics S.L.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#ifndef MUJOCO_ROS2_CONTROL_PLUGINS__PLUGIN_BASE_HPP_
16#define MUJOCO_ROS2_CONTROL_PLUGINS__PLUGIN_BASE_HPP_
17
18#include <mujoco/mujoco.h>
19#include <rclcpp/rclcpp.hpp>
20
22{
23
52{
53public:
54 virtual ~MuJoCoROS2ControlPluginBase() = default;
55
66 virtual bool init(rclcpp::Node::SharedPtr node, const mjModel* model, mjData* data) = 0;
67
80 virtual void update_read(const mjModel* /*model*/, mjData* /*data*/)
81 {
82 }
83
94 virtual void update_write(const mjModel* model, mjData* data)
95 {
96#pragma GCC diagnostic push
97#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
98 update(model, data);
99#pragma GCC diagnostic pop
100 }
101
108 [[deprecated("Override update_write() instead.")]] virtual void update(const mjModel* /*model*/, mjData* /*data*/)
109 {
110 }
111
119 virtual void pre_step(mjData* /*data*/)
120 {
121 }
122
128 virtual void on_reset(mjData* /*data*/)
129 {
130 }
131
135 virtual void cleanup() = 0;
136};
137
138} // namespace mujoco_ros2_control_plugins
139
140#endif // MUJOCO_ROS2_CONTROL_PLUGINS__PLUGIN_BASE_HPP_
Base class for MuJoCo ROS 2 control plugins.
Definition mujoco_ros2_control_plugins_base.hpp:52
virtual void update_read(const mjModel *, mjData *)
Called once per read() cycle, on the control thread, before the state is handed to ros2_control....
Definition mujoco_ros2_control_plugins_base.hpp:80
virtual void on_reset(mjData *)
Called after a world reset (ResetWorld service or UI reset). Default does nothing.
Definition mujoco_ros2_control_plugins_base.hpp:128
virtual void update(const mjModel *, mjData *)
Same as update_write(). Default does nothing.
Definition mujoco_ros2_control_plugins_base.hpp:108
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 con...
Definition mujoco_ros2_control_plugins_base.hpp:94
virtual void pre_step(mjData *)
Called immediately before every simulation step on the physics thread. Default does nothing.
Definition mujoco_ros2_control_plugins_base.hpp:119
virtual bool init(rclcpp::Node::SharedPtr node, const mjModel *model, mjData *data)=0
Initialize the plugin.
Definition mujoco_ros2_control_plugins_base.hpp:22