ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Change type sensor_msgs/joint_states to JointMessage [closed]

asked 2014-10-08 12:46:37 -0500

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();


}
edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by RosBort
close date 2014-10-15 13:15:40.662577

1 Answer

Sort by ยป oldest newest most voted
1

answered 2014-10-08 15:54:09 -0500

gvdhoorn gravatar image

updated 2014-10-08 15:55:17 -0500

[..] 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 [..]

Not as far as I know: the sensor_msgs/JointStates message is used to store the state of a set of joints at a certain time, as a piece of sensor information -- actual state. It is not normally used to encode desired or commanded state. Server implementations using the protocol -- running on robot controllers -- typically periodically send out JOINT_POSITION Simple Message messages, that the industrial_robot_client deserialises and republishes as sensor_msgs/JointStates.

As such, there is currently no support in simple_message for "Convert[ing] 'joint_states' to 'JointMessage' which is part of the 'simple_message' Package and send it".

Do you have a particular reason for wanting to send over sensor_msgs/JointStates messages, instead of letting the industrial_robot_client proxy between JointTrajectory and JOINT_TRAJ_PT or similar messages?

edit flag offensive delete link more

Comments

Thank you for your answer! There is no particular reason for me using sensor_msgs/JointStates. It resulted out of a lack of knowledge. I will read/work through this tomorrow. Thank you and good night (depending on where you live of course ;) )

RosBort gravatar image RosBort  ( 2014-10-08 16:49:47 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2014-10-08 12:46:37 -0500

Seen: 336 times

Last updated: Oct 08 '14