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

Covnert geometry_msg/StampedPoint to Stamped pose

asked 2020-08-17 01:03:18 -0500

Ray_Shim gravatar image

updated 2020-08-19 00:02:02 -0500

Hi guys.

I'm trying to convert point to pose. But i don't know how to do. I saw topic_tool package, but the only example is about stg_msgs. I can't find parameteres that i need. :(
And i also saw 'covert pose to point' ( The answer is so simple. But it's not for me.

Thanks you for your interest, Ray.

(edit) Code

rosrun topic_tools transform /clicked_point /clicked_pose geometry_msgs/PoseStamped \

'geometry_msgs.msg.PoseStamped( \

header=m.header,  \
pose=geometry_msgs.msg.Pose( \
  position=m.position, \
  orientation=geometry_msgs.msg.Quaternion( \
orientation.x = 0.0 \
    orientation.y = 0.0 \
orientation.z = 0.0 \
orientation.w = 0.0 \
)))' \

--import geometry_msgs


Traceback (most recent call last): File "/home/raptor/nav_ws/src/ros_comm/clients/rospy/src/rospy/", line 750, in _invoke_callback cb(msg) File "/home/raptor/nav_ws/src/ros_comm/tools/topic_tools/scripts/transform", line 94, in callback res = eval("{}".format(self.expression), self.modules, {'m': m}) File "<string>", line 7 orientation.y = 0.0 \ ^ SyntaxError: invalid syntax

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2020-08-17 01:53:30 -0500

Tahir M. gravatar image

updated 2020-08-17 01:55:51 -0500

You can use transform from topic_tools. It is quite useful yet handy tool for which you have to care about. You can see the details of paramters here. Here is an example to use in launch file:

<?xml version="1.0"?>
  <node name="diagnostics_stamped" pkg="topic_tools" type="transform"
    args="/diagnostics /diagnostics_stamped diagnostic_msgs/DiagnosticArray 
    level=m.level,, message=m.message, hardware_id=m.hardware_id, values=[])])' 
    --import diagnostic_msgs std_msgs rospy"/>

To run an from terminal an example can be seen here

edit flag offensive delete link more


Thanks for your help. But i'm still stuck.

I face problem that i don't know how to write orientation part. I cannot find any reference about orientation. I want to put all 0.0 values in orientation. So I made some simplse code. But i got error msg about syntax.

Could i get some advice about my code? (i upload my code)

Ray_Shim gravatar image Ray_Shim  ( 2020-08-18 23:55:20 -0500 )edit

answered 2020-08-17 01:45:39 -0500

HappyBit gravatar image

Hi Ray,

A geometry_msgs/Pose consits of a geometry_msgs/Point and a geometry_msgs/Quaternion (click for details). Hence you can't convert a point to a pose, since the orientation is missing.

That said, you can however write a node. Design a class where you register a Subscriber and Publisher in the constructor by passing the NodeHandle as argument. In the callback for the subscriber (Point-topic) you create a new pose message and pass the point as pose.position and a add a custom quaternion as pose.orientation. I would make the orientation a ROS-Parameter which i can set in the launch file.

edit flag offensive delete link more


Thanks for help.

But i'm not fluent in cpp. So I will try some more easy way first.

Really thanks for your interest and help.

Ray_Shim gravatar image Ray_Shim  ( 2020-08-18 23:59:59 -0500 )edit

You could use python.

HappyBit gravatar image HappyBit  ( 2020-08-19 03:21:22 -0500 )edit

Question Tools



Asked: 2020-08-17 01:03:18 -0500

Seen: 508 times

Last updated: Aug 19 '20