mujoco_ros_utils
ActuatorCommand.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <ros/callback_queue.h>
4 #include <ros/ros.h>
5 #include <std_msgs/Float64.h>
6 
7 #include <mujoco/mjdata.h>
8 #include <mujoco/mjmodel.h>
9 #include <mujoco/mjtnum.h>
10 #include <mujoco/mjvisualize.h>
11 
12 #include <limits>
13 #include <string>
14 
15 namespace MujocoRosUtils
16 {
17 
20 {
21 public:
23  static void RegisterPlugin();
24 
30  static ActuatorCommand * Create(const mjModel * m, mjData * d, int plugin_id);
31 
32 public:
34  ActuatorCommand(ActuatorCommand &&) = default;
35 
40  void reset(const mjModel * m, int plugin_id);
41 
47  void compute(const mjModel * m, mjData * d, int plugin_id);
48 
49 protected:
56  ActuatorCommand(const mjModel * m, mjData * d, int actuator_id, std::string topic_name);
57 
61  void callback(const std_msgs::Float64::ConstPtr & msg);
62 
63 protected:
65  int actuator_id_ = -1;
66 
68  mjtNum ctrl_ = std::numeric_limits<mjtNum>::quiet_NaN();
69 
72  std::shared_ptr<ros::NodeHandle> nh_;
73  ros::CallbackQueue callbackQueue_;
74  ros::Subscriber sub_;
76 };
77 
78 } // namespace MujocoRosUtils
MujocoRosUtils::ActuatorCommand::ctrl_
mjtNum ctrl_
Actuator command (NaN for no command)
Definition: ActuatorCommand.h:68
MujocoRosUtils::ActuatorCommand::ActuatorCommand
ActuatorCommand(ActuatorCommand &&)=default
Copy constructor.
MujocoRosUtils::ActuatorCommand::Create
static ActuatorCommand * Create(const mjModel *m, mjData *d, int plugin_id)
Create an instance.
Definition: ActuatorCommand.cpp:70
MujocoRosUtils::ActuatorCommand::reset
void reset(const mjModel *m, int plugin_id)
Reset.
Definition: ActuatorCommand.cpp:131
MujocoRosUtils::ActuatorCommand::nh_
std::shared_ptr< ros::NodeHandle > nh_
Definition: ActuatorCommand.h:72
MujocoRosUtils::ActuatorCommand::callback
void callback(const std_msgs::Float64::ConstPtr &msg)
Constructor.
Definition: ActuatorCommand.cpp:153
MujocoRosUtils::ActuatorCommand::callbackQueue_
ros::CallbackQueue callbackQueue_
Definition: ActuatorCommand.h:73
MujocoRosUtils::ActuatorCommand::sub_
ros::Subscriber sub_
Definition: ActuatorCommand.h:74
MujocoRosUtils::ActuatorCommand
Plugin to send a command to an actuator via ROS topic.
Definition: ActuatorCommand.h:19
MujocoRosUtils::ActuatorCommand::actuator_id_
int actuator_id_
Actuator ID.
Definition: ActuatorCommand.h:65
MujocoRosUtils::ActuatorCommand::RegisterPlugin
static void RegisterPlugin()
Register plugin.
Definition: ActuatorCommand.cpp:10
MujocoRosUtils::ActuatorCommand::compute
void compute(const mjModel *m, mjData *d, int plugin_id)
Compute.
Definition: ActuatorCommand.cpp:137
MujocoRosUtils
Definition: ActuatorCommand.cpp:7