hebiros_subscribers_gazebo.cpp
Go to the documentation of this file.
3 #include "hebiros.h"
4 
5 using namespace hebiros;
6 
7 
9 
10  subscribers["hebiros/"+group_name+"/command"] =
11  HebirosNode::n_ptr->subscribe<CommandMsg>("hebiros/"+group_name+"/command", 100,
12  boost::bind(&HebirosSubscribersGazebo::command, this, _1, group_name));
13 
14  subscribers["hebiros/"+group_name+"/command/joint_state"] =
15  HebirosNode::n_ptr->subscribe<sensor_msgs::JointState>(
16  "hebiros/"+group_name+"/command/joint_state", 100,
17  boost::bind(&HebirosSubscribersGazebo::jointCommand, this, _1, group_name));
18 
19  subscribers["hebiros_gazebo_plugin/feedback/"+group_name] =
20  HebirosNode::n_ptr->subscribe<FeedbackMsg>(
21  "hebiros_gazebo_plugin/feedback/"+group_name, 100,
22  boost::bind(&HebirosSubscribersGazebo::feedback, this, _1, group_name));
23 }
24 
26  std::string group_name) {
27 
28  HebirosNode::publishers_gazebo.command(*data, group_name);
29 }
30 
32  const boost::shared_ptr<sensor_msgs::JointState const> data, std::string group_name) {
33 
34  CommandMsg command_msg;
35  command_msg.name = data->name;
36  command_msg.position = data->position;
37  command_msg.velocity = data->velocity;
38  command_msg.effort = data->effort;
39 
40  HebirosNode::publishers_gazebo.command(command_msg, group_name);
41 }
42 
44  std::string group_name) {
45 
46  // TODO: replace with better abstraction later
47  HebirosGroupGazebo* group = dynamic_cast<HebirosGroupGazebo*>
49  if (!group) {
50  ROS_WARN("Improper group type during feedback call");
51  return;
52  }
53 
54  FeedbackMsg feedback_msg = *data;
55  sensor_msgs::JointState joint_state_msg;
56  joint_state_msg.header.stamp = ros::Time::now();
57  joint_state_msg.name = feedback_msg.name;
58  joint_state_msg.position = feedback_msg.position;
59  joint_state_msg.velocity = feedback_msg.velocity;
60  joint_state_msg.effort = feedback_msg.effort;
61 
62  group->feedback_msg = feedback_msg;
63  group->joint_state_msg = joint_state_msg;
64 
65  HebirosNode::publishers_gazebo.feedback(feedback_msg, group_name);
66  HebirosNode::publishers_gazebo.feedbackJointState(joint_state_msg, group_name);
67 }
68 
69 
70 
71 
void command(hebiros::CommandMsg command_msg, std::string group_name)
void jointCommand(const boost::shared_ptr< sensor_msgs::JointState const > data, std::string group_name)
static HebirosPublishersGazebo publishers_gazebo
Definition: hebiros.h:79
sensor_msgs::JointState joint_state_msg
Definition: hebiros_group.h:19
void command(const boost::shared_ptr< hebiros::CommandMsg const > data, std::string group_name)
#define ROS_WARN(...)
static std::shared_ptr< ros::NodeHandle > n_ptr
Definition: hebiros.h:78
hebiros::FeedbackMsg feedback_msg
Definition: hebiros_group.h:20
static HebirosGroupRegistry & Instance()
HebirosGroup * getGroup(const std::string &name)
void feedback(const boost::shared_ptr< hebiros::FeedbackMsg const > data, std::string group_name)
void feedbackJointState(sensor_msgs::JointState joint_state_msg, std::string group_name)
void registerGroupSubscribers(std::string group_name)
static Time now()
void feedback(hebiros::FeedbackMsg feedback_msg, std::string group_name)


hebiros
Author(s): Xavier Artache , Matthew Tesch
autogenerated on Thu Sep 3 2020 04:08:14