Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to publish messages with specific data types for arguments?

Hello, I've adapted some C++ control code for a smart motor I have attached to a laser scanner (it rotates the laser scanner back and forth) into a node to do the same thing upon receiving a custom message. The message includes start/end angle, speed, and duration, which are the inputs the original control code uses:

  float32 start
  float32 end
  float32 speed
  float32 duration

The node compiles and runs (the code as is can be found here: Now I am trying to complete a simple back and forth sweep for 3 seconds, by publishing a custom Sweep message to the /sweep topic from the command line. I run the command:

  rostopic pub -1 /sweep toro/Sweep -- -3.14159/2 3.14159/2 3.14159/2 3

but get the following response (repeated many times):

 [WARN] [WallTime: 1408045951.800915] Inbound TCP/IP connection failed: <class 'struct.error'>: 'required argument is not  a float' when writing 'start: -3.14159/2
 end: 3.14159/2
 speed: 3.14159/2
 duration: 3'

Is there any kind of way I can specify the data type of the arguments while publishing the message? I guess they might be doubles by default, but ros custom messages don't support doubles (or at least I couldn't get them to work), so I don't think I can fix the problem on that end.