ros / geometry2

A set of ROS packages for keeping track of coordinate transforms.
190 stars 275 forks source link

PyKDL.Vector do not have header attribute #503

Closed rkoyama1623-2021 closed 3 years ago

rkoyama1623-2021 commented 3 years ago

I think we cannot use the function tf2_kdl.to_msg_vector, because the PyKDL.Vector do not have header attribute.

import PyKDL
from tf2_kdl import to_msg_vector

vector = PyKDL.Vector()
msg = to_msg_vector(vector) # cause following error
# AttributeError: 'Vector' object has no attribute 'header'

I think following line should be removed, since the PyKDL.Vector do not have the information of timestamp.

https://github.com/ros/geometry2/blob/3ca66d97a8b732a9fda5c74ca466001d66d7196a/tf2_kdl/src/tf2_kdl/tf2_kdl.py#L76

I might misunderstand the way to use the function tf2_kdl.to_msg_vector, so please let me know if my understanding is right or not.

Thank you.

rkoyama1623-2021 commented 3 years ago

Sorry, I misunderstood the way to use the function, and the right sample code is as follows:

import PyKDL
import rospy
import tf2_ros
from tf2_kdl import to_msg_vector

vector = tf2_ros.Stamped(PyKDL.Vector(), rospy.Time(0), 'some_frame')
msg = to_msg_vector(vector)

We may express the type of vector in this function as tf2_ros.Stamped(PyKDL.Vector) instead of PyKDL.Vector

https://github.com/ros/geometry2/blob/3ca66d97a8b732a9fda5c74ca466001d66d7196a/tf2_kdl/src/tf2_kdl/tf2_kdl.py#L67-L74