0
$\begingroup$

Rosanswers logo

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: http://pastebin.com/wypDERQL). 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.


Originally posted by mysteriousmonkey29 on ROS Answers with karma: 170 on 2014-08-14

Post score: 2

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

The trouble here is that rostopic pub is not a calculator - it's expecting numbers, and instead you're giving it an equation (effectively a string).

Instead, try:

  rostopic pub -1 /sweep toro/Sweep -- -1.57 1.57 1.57 3


P.S. - The ROS message type for doubles is float64 (since most doubles are 64-bit floating-precision numbers)

Originally posted by ahendrix with karma: 47576 on 2014-08-14

This answer was ACCEPTED on the original site

Post score: 5


Original comments

Comment by mysteriousmonkey29 on 2014-08-14:
Great, that completely solved the problem! Thanks for such a helpful answer, and the information on the doubles.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.