Change type sensor_msgs/joint_states to JointMessage [closed]
Hello!
My Node is subscribing to a ROS-Node that publishes sensor_msgs/joint_state. Now I would like to send this data via the simple_message Protocol using TCP/IP to my robot controller. My goal is to subsribe to the topic "joint_states" which, as I so far understood, is often used for sending actual robot positions and send it over TCP/IP using the "simple_message" protocol.
So there are two possibilities for me: Get "joint_states" to "simple_message" directly and send it. or Convert "joint_states" to "JointMessage" which is part of the "simple_message" Package and send it.
The Communication already works. I followed a ROS-I-Tutorial, which I am not able to find again at the moment. What the robot controller receives is not important yet. For now a dummy node prints the sequence of the simple message to the screen and this works for the first.
May someone have an idea.
Here is my code-snippet:
while(client.isConnected())
{
ros::spinOnce();
ROS_INFO_STREAM("POS1 = " << globalJointState.position[1]);
// Create a message of type JointMessage and corresponding simple message
industrial::joint_message::JointMessage jmReq;
industrial::simple_message::SimpleMessage req, reply;
jmReq.setSequence(globalJointState.header.seq);
//jmReq.addAllDataIwishForMyJointMessage(outOffMyGlobalJointStates);
jmReq.toRequest(req);
ROS_INFO_STREAM("Sending sequence: " << globalJointState.header.seq << " to " << LOCAL_HOST << ":" << TCP_PORT);
client.sendAndReceiveMsg(req, reply);
ROS_INFO_STREAM("Received reply code: " << reply.getReplyCode());
ros::Duration(1).sleep();
}