AttributeError:' Point'对象没有属性' point'

时间:2017-11-07 03:51:45

标签: python ros

我正在使用tf2将源点从源帧转换为目标帧。以下是代码段:

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

代码抛出以下错误:

Traceback (most recent call last):
  File "q1.py", line 29, in <module>
    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'

可以在tf_geometry_msgs.py在线查看here。这似乎很愚蠢,因为他们正在呼叫point.point.x

他们在谈论哪一点?我认为它应该是geometry_msgs/Point,我用以下方式声明:

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

请问任何解决方法吗?

1 个答案:

答案 0 :(得分:1)

do_transform_point(point_wrt_kinect,transform)

point_wrt_kinect是Point类的对象。在文档中它应该是PointStamped类对象。它的文档错误。  你必须创建PointStamped类的对象而不是Point类。