25 #include <sensor_msgs/JointState.h> 32 sensor_msgs::JointState present_msg;
34 for (
int index = 0; index < msg->name.size(); index++)
36 present_msg.name.push_back(msg->name[index]);
37 present_msg.position.push_back(msg->position[index]);
39 if (present_msg.name[index] ==
"l_arm_grip")
41 present_msg.name.push_back(
"l_arm_grip_1");
42 present_msg.position.push_back(present_msg.position[index]);
45 if (present_msg.name[index] ==
"r_arm_grip")
47 present_msg.name.push_back(
"r_arm_grip_1");
48 present_msg.position.push_back(present_msg.position[index]);
51 g_present_joint_states_pub.
publish(present_msg);
56 sensor_msgs::JointState goal_msg;
58 for (
int index = 0; index < msg->name.size(); index++)
60 goal_msg.name.push_back(msg->name[index]);
61 goal_msg.position.push_back(msg->position[index]);
63 if (goal_msg.name[index] ==
"l_arm_grip")
65 goal_msg.name.push_back(
"l_arm_grip_1");
66 goal_msg.position.push_back(goal_msg.position[index]);
69 if (goal_msg.name[index] ==
"r_arm_grip")
71 goal_msg.name.push_back(
"r_arm_grip_1");
72 goal_msg.position.push_back(goal_msg.position[index]);
75 g_goal_joint_states_pub.
publish(goal_msg);
78 int main(
int argc,
char **argv)
80 ros::init(argc, argv,
"thormang3_rviz_publisher");
83 g_present_joint_states_pub = nh.
advertise<sensor_msgs::JointState>(
"/robotis/thormang3/present_joint_states", 0);
84 g_goal_joint_states_pub = nh.
advertise<sensor_msgs::JointState>(
"/robotis/thormang3/goal_joint_states", 0);
void publish(const boost::shared_ptr< M > &message) const
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
void presentJointStatesCallback(const sensor_msgs::JointState::ConstPtr &msg)
void goalJointStatesCallback(const sensor_msgs::JointState::ConstPtr &msg)
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
ROSCPP_DECL void spin(Spinner &spinner)
ros::Publisher g_goal_joint_states_pub
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
int main(int argc, char **argv)
ros::Publisher g_present_joint_states_pub