hebiros_publishers.cpp
Go to the documentation of this file.
1 #include "hebiros_publishers.h"
3 
4 #include "hebiros.h"
5 
6 using namespace hebiros;
7 
8 
9 std::map<std::string, ros::Publisher> HebirosPublishers::publishers;
10 
11 void HebirosPublishers::registerGroupPublishers(std::string group_name) {
12 
13  publishers["hebiros/"+group_name+"/feedback"] =
14  HebirosNode::n_ptr->advertise<FeedbackMsg>("hebiros/"+group_name+"/feedback", 100);
15 
16  publishers["hebiros/"+group_name+"/feedback/joint_state"] =
17  HebirosNode::n_ptr->advertise<sensor_msgs::JointState>(
18  "hebiros/"+group_name+"/feedback/joint_state", 100);
19 
20  publishers["hebiros/"+group_name+"/feedback/joint_state_urdf"] =
21  HebirosNode::n_ptr->advertise<sensor_msgs::JointState>(
22  "hebiros/"+group_name+"/feedback/joint_state_urdf", 100);
23 
24  publishers["hebiros/"+group_name+"/command/joint_state"] =
25  HebirosNode::n_ptr->advertise<sensor_msgs::JointState>(
26  "hebiros/"+group_name+"/command/joint_state", 100);
27 }
28 
29 
30 void HebirosPublishers::feedback(FeedbackMsg feedback_msg, std::string group_name) {
31  publishers["hebiros/"+group_name+"/feedback"].publish(feedback_msg);
32 }
33 
34 void HebirosPublishers::feedbackJointState(sensor_msgs::JointState joint_state_msg,
35  std::string group_name) {
36  publishers["hebiros/"+group_name+"/feedback/joint_state"].publish(joint_state_msg);
37 
38  feedbackJointStateUrdf(joint_state_msg, group_name);
39 }
40 
41 void HebirosPublishers::feedbackJointStateUrdf(sensor_msgs::JointState joint_state_msg,
42  std::string group_name) {
43 
45 
46  if (joint_state_msg.name.size() == group->joint_full_names.size()) {
47  for (int i = 0; i < group->joint_full_names.size(); i++) {
48  joint_state_msg.name[i] = group->joint_full_names[joint_state_msg.name[i]];
49  }
50 
51  publishers["hebiros/"+group_name+"/feedback/joint_state_urdf"].publish(joint_state_msg);
52  }
53 }
54 
55 void HebirosPublishers::commandJointState(sensor_msgs::JointState joint_state_msg,
56  std::string group_name) {
57  publishers["hebiros/"+group_name+"/command/joint_state"].publish(joint_state_msg);
58 }
static std::shared_ptr< ros::NodeHandle > n_ptr
Definition: hebiros.h:78
void commandJointState(sensor_msgs::JointState joint_state_msg, std::string group_name)
static HebirosGroupRegistry & Instance()
HebirosGroup * getGroup(const std::string &name)
void feedbackJointState(sensor_msgs::JointState joint_state_msg, std::string group_name)
static std::map< std::string, ros::Publisher > publishers
std::map< std::string, std::string > joint_full_names
Definition: hebiros_group.h:17
void registerGroupPublishers(std::string group_name)
void feedbackJointStateUrdf(sensor_msgs::JointState joint_state_msg, std::string group_name)
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