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

tf_conversions / posemath / pykdl problem with fromMsg

asked 2012-02-15 04:57:10 -0500

TomTUM gravatar image

updated 2014-01-28 17:11:23 -0500

ngrennan gravatar image

There seems to be a bug in the python kdl wrapper, leading to unexpected behavior when working on KDL frames. I felt like posting it here since other people might run into it before it's fixed, and they would most probably look for a solution here.

The simple remedy is of course to assign whatever is returned from fromMsg to a variable before usage.

import roslib; roslib.load_manifest('tf')
roslib.load_manifest('tf_conversions')
import tf_conversions.posemath as pm
roslib.load_manifest('geometry_msgs')
import geometry_msgs
pose_msg = geometry_msgs.msg.Pose()
pose_msg.position.x = 100
print pm.fromMsg(pose_msg).p
#[           0,           0,           0]
pose = pm.fromMsg(pose_msg)
print pose.p
#[         100,           0,           0]
edit retag flag offensive close merge delete

Comments

We can create this error using kdl: import PyKDL as kdl kdl.Frame(kdl.Rotation.Quaternion(0,0,0,1),kdl.Vector(100,200,300)).p Out[9]: [2.56735e-316,6.93179e-310, 300] kdl.Frame(kdl.Rotation.Quaternion(0,0,0,1),kdl.Vector(100,200,300)).p[0] Out[10]: 0.0 # which is not 100!

TomTUM gravatar image TomTUM  ( 2012-02-17 01:54:33 -0500 )edit
1

Turns out it's a general problem with SIP. Whenever we have a struct C { Member m; } and access from from a an instantiation C().m, the instantiated object gets garbage collected while .m still points to the memory held by C++ directly. It seems like there is no way to do this right in SIP.

TomTUM gravatar image TomTUM  ( 2012-02-29 00:20:13 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2012-03-06 06:32:49 -0500

Wim gravatar image

Answer by TomTUM: Turns out it's a general problem with SIP. Whenever we have a struct C { Member m; } and access from from a an instantiation C().m, the instantiated object gets garbage collected while .m still points to the memory held by C++ directly. It seems like there is no way to do this right in SIP.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2012-02-15 04:57:10 -0500

Seen: 638 times

Last updated: Mar 06 '12