34 #include <sr_robot_msgs/joints_data.h> 35 #include <sr_robot_msgs/joint.h> 36 #include <sensor_msgs/JointState.h> 51 n_tilde(
"~"), publish_rate(0.0)
62 std::string searched_param;
65 std::string full_topic = prefix +
"position/joint_states";
67 full_topic = prefix +
"target/joint_states";
71 full_topic = prefix +
"shadowhand_data";
88 sr_robot_msgs::joints_data
msg;
89 std::vector<sr_robot_msgs::joint> jointVector;
91 sensor_msgs::JointState jointstate_pos_msg;
92 sensor_msgs::JointState jointstate_target_msg;
95 jointstate_pos_msg.header.stamp = now;
96 jointstate_target_msg.header.stamp = now;
98 for (SRArticulatedRobot::JointsMap::const_iterator it = joints_map.begin(); it != joints_map.end(); ++it)
100 sr_robot_msgs::joint joint;
112 joint.joint_name = it->first;
113 jointstate_pos_msg.name.push_back(it->first);
114 jointstate_target_msg.name.push_back(it->first);
116 jointstate_target_msg.position.push_back(
toRad(currentData.
target));
117 jointstate_target_msg.velocity.push_back(0.0);
118 jointstate_target_msg.effort.push_back(0.0);
120 jointstate_pos_msg.position.push_back(
toRad(currentData.
position));
121 jointstate_pos_msg.velocity.push_back(currentData.
velocity);
122 jointstate_pos_msg.effort.push_back(currentData.
force);
124 joint.joint_position = currentData.
position;
125 joint.joint_target = currentData.
target;
126 joint.joint_torque = currentData.
force;
128 joint.joint_current = currentData.
current;
139 joints_map[it->first].last_pos_time.toSec());
141 jointVector.push_back(joint);
144 msg.joints_list_length = jointVector.size();
145 msg.joints_list = jointVector;
SRPublisher(boost::shared_ptr< SRArticulatedRobot > sr_art_robot)
void publish(const boost::shared_ptr< M > &message) const
std::map< std::string, JointData > JointsMap
NodeHandle node
ros node handle
Publisher sr_jointstate_target_pub
The publisher which publishes the data to the \/{prefix}\/target\/joint_states topic.
boost::shared_ptr< SRArticulatedRobot > sr_articulated_robot
The shadowhand object (can be either an object connected to the real robot or a virtual hand)...
~SRPublisher()
Destructor.
bool searchParam(const std::string &key, std::string &result) const
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
This class reads and publishes data concerning the shadowhand / shadowarm. To publish those data...
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
Publisher sr_jointstate_pos_pub
The publisher which publishes the data to the \/{prefix}\/position\/joint_states topic.
Rate publish_rate
the rate at which the data will be published. This can be set by a parameter in the launch file...
ROSCPP_DECL void spinOnce()
Publisher sr_pub
The publisher which publishes the data to the \/{prefix}\/shadowhand_data topic.