Converting from point to point32

Hi Construct Team,

Can you help with a method for converting geometry_msgs/msg/point to point32?

I am attempting on the actions section of the rosject to output a list of point32 for the result when the goal has suceeded… However I am having trouble understanding this. How do I let the action server run in parallel to the “main” wall_follower cpp file? Is it correct using a while statement? or do I keep calling the server over and over and that’s why we’re using “#include memory”?

Additionally, since there is no goal, how does it know when the goal is completed? is it when it stops calling the action server by closing the terminal running the main cpp file with ctrl+c or ctrl+z?

Many Thanks for the help,

Hi @william.lubiantoro ,

First make sure the custom message definition file uses, geometry_msgs/Point32 instead of geomtery_msgs/Point.

Next, in your code, make sure you import geometry_msgs/msg/Point32 instead of geometry_msgs/msg/Point.

Point is a float64 data type, whereas, Point32 is a float32 data type.
You can easily convert float64 to float32 by type casting, but you will have round-off errors at 7th decimal place onwards - since float32 is precise only up to 8 decimal places, while float64 is precise up to 16 decimal places.
If precision is not your concern then you can directly copy Point’s x, y, z into Point32’s x, y, z values directly (with loss of precision of course).

I hope this is clear enough to you. Let me know if you are still unclear.


This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.