msg file float variable digit problem
- OS: Ubuntu 16.04 LTS with 4.15.0-52-generic kernel
- ROS version: Kinetic
Hello, I'm writing a node for Pepperl+Fuchs PGV100.
You can check it out on it's github page.
I have a message file like this,
my.msg
Header header
float32 angle
uint64 x_pos
float32 y_pos
string direction
uint8 color_lane_count
uint8 no_color_lane
uint8 no_pos
The output like this. The angle looks like has a one digit but it is 0 always. But why ROS msg is not publishing this one also with 10 digit accuracy.
angle: 314.0
x_pos: 11
y_pos: -19.6000003815
direction: "Straight ahead"
color_lane_count: 0
no_color_lane: 1
no_pos: 1
I want to publish my float messages with 2 digit after decimal. I'm writing the node in C++ and If it's nothing to do with ROS msg publishing, I'll try to fix the problem on my code.
Thanks!
Asked by ermanas on 2019-12-10 06:47:07 UTC
Comments
Can you show us how you are populating the
angle
field? So: can you show the code that sets its value?Asked by gvdhoorn on 2019-12-10 06:54:35 UTC
I get the data from the Pepperl+Fuchs PGV100 as a string. I convert this string to the decimal with a unsigned long integer variable in the string2decimal function. Then, when I'm populating angle, I converted to degree by dividing to 10.0
y-pos is the same but the values that I got from the device are like this
angle: 3450 - for angle 345 degree y-pos: 72 - for 7.2 mm
When I change the angular resolution to 0.1 degree. It starts to give me with 10 digits like y-pos.
I'll add the code's github page to the question. But it's a quite dirty code with all of the communication settings.
Asked by ermanas on 2019-12-10 07:41:54 UTC
what do you think? By the way, the code is pretty straight forward. Because I'm still learning programming.
Asked by ermanas on 2019-12-12 00:24:18 UTC