AttributeError: 'Point' object has no attribute 'point'
I am transforming a point from source frame to target frame using tf2. Below is the code snippet:
import tf2_ros
import tf2_geometry_msgs
transform = tf_buffer.lookup_transform(target_frame, source_frame, rospy.Time(0), rospy.Duration(1.0))
pose_transformed = tf2_geometry_msgs.do_transform_point(point_wrt_kinect, transform)
print pose_transformed
It throws following error:
pose_transformed = tf2_geometry_msgs.do_transform_point(point_wrt_kinect, transform)
File "/opt/ros/indigo/lib/python2.7/dist-packages/tf2_geometry_msgs/tf2_geometry_msgs.py", line 59, in do_transform_point
p = transform_to_kdl(transform) * PyKDL.Vector(point.point.x, point.point.y, point.point.z)
AttributeError: 'Point' object has no attribute 'point'
The point is defined as follows:
from geometry_msgs.msg import Point
point_wrt_kinect = Point()
point_wrt_kinect.x = -0.41
point_wrt_kinect.y = -0.13
point_wrt_kinect.z = 0.77
However, since I am getting the above error. So I redefined the point as follows
from geometry_msgs.msg import Point
class MyPoint():
def __init__(self):
self.point = Point()
And then initialize the point as below:
point_wrt_kinect = MyPoint()
point_wrt_kinect.point = Point(-0.41, -0.13, 0.77)
It works! However is a there better way to do it?
BTW: That's a really well formulated question. It contains all the info and also your current solution. (and pose_transformed should be point_stamped)