ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
It would seem instances of class PointCloud2
don't have a member variable called channels
.
That is what the error tells you.
2 | No.2 Revision |
It would seem instances of class PointCloud2
don't have a member variable called channels
.
That is what the error tells you.
Edit:
ah...I was looking for a deeper insight...like what are channels and why is transformPointCloud looking for them.
Well, then you should've stated your question differently :).
In any case, see ros/geometry/tf/listener.py, lines 207 to 226 for the source of transformPointCloud
:
def transformPointCloud(self, target_frame, point_cloud):
r = sensor_msgs.msg.PointCloud()
r.header.stamp = point_cloud.header.stamp
r.header.frame_id = target_frame
r.channels = point_cloud.channels
...
it does more, but I've copied the relevant bit here.
The method essentially makes a copy of point_cloud
(but transformed into target_frame
). In order to do that, it needs to copy all fields of the incoming msg. It copies the header
field first, then the channels
field, and finally goes on to copy all points in the cloud (in point_cloud.points
) while simultaneously transforming them.
As to what are channels, see the sensor_msgs/PointCloud.msg documentation:
Each channel should have the same number of elements as points array, and the data in each channel should correspond 1:1 with each point.
Channel names in common practice are listed in ChannelFloat32.msg.
3 | No.3 Revision |
It would seem instances of class PointCloud2
don't have a member variable called channels
.
That is what the error tells you.
Edit:
ah...I was looking for a deeper insight...like what are channels and why is transformPointCloud looking for them.
Well, then you should've stated your question differently :).
In any case, see ros/geometry/tf/listener.py, lines 207 to 226 for the source of transformPointCloud
:
def transformPointCloud(self, target_frame, point_cloud):
r = sensor_msgs.msg.PointCloud()
r.header.stamp = point_cloud.header.stamp
r.header.frame_id = target_frame
r.channels = point_cloud.channels
...
it does more, but I've copied the relevant bit here.
The method essentially makes a copy of point_cloud
(but transformed into target_frame
). In order to do that, it needs to copy all fields of the incoming msg. It copies the header
field first, then the channels
field, and finally goes on to copy all points in the cloud (in point_cloud.points
) while simultaneously transforming them.
As to what are channels, see the sensor_msgs/PointCloud.msg documentation:
#
Each channel should have the same number of elements as points From the error msg it would appear that you are trying to pass an instance of PointCloud2
to transformPointCloud(..)
, which it doesn't seem to support. PointCloud2
msgs don't have a channels
field (see sensor_msgs/PointCloud2.msg). The requirement for the point_cloud
parameter to be an instance of sensor_msgs/PointCloud
is also stated in the documentation of transformPointCloud(..)
:
:param target_frame: the tf target frame, a string
:param ps: the sensor_msgs.msg.PointCloud message
:return: new sensor_msgs.msg.PointCloud message, in frame target_frame
4 | No.4 Revision |
It would seem instances of class PointCloud2
don't have a member variable called channels
.
That is what the error tells you.
Edit:
ah...I was looking for a deeper insight...like what are channels and why is transformPointCloud looking for them.
Well, then you should've stated your question differently :).
In any case, see ros/geometry/tf/listener.py, lines 207 to 226 for the source of transformPointCloud
:
def transformPointCloud(self, target_frame, point_cloud):
r = sensor_msgs.msg.PointCloud()
r.header.stamp = point_cloud.header.stamp
r.header.frame_id = target_frame
r.channels = point_cloud.channels
...
it does more, but I've copied the relevant bit here.
The method essentially makes a copy of point_cloud
(but transformed into target_frame
). In order to do that, it needs to copy all fields of the incoming msg. It copies the header
field first, then the channels
field, and finally goes on to copy all points in the cloud (in point_cloud.points
) while simultaneously transforming them.
As to what are channels, see the sensor_msgs/PointCloud.msg documentation:
# Each channel should have the same number of elements as points array,
# and the data in each channel should correspond 1:1 with each point.
# Channel names in common practice are listed in ChannelFloat32.msg.
From the error msg it would appear that you are trying to pass an instance of PointCloud2
to transformPointCloud(..)
, which it doesn't seem to support. PointCloud2
msgs don't have a channels
field (see sensor_msgs/PointCloud2.msg). ).
The requirement for the point_cloud
parameter to be an instance of sensor_msgs/PointCloud
is also stated in the documentation of transformPointCloud(..)
:
:param target_frame: the tf target frame, a string
:param ps: the sensor_msgs.msg.PointCloud message
:return: new sensor_msgs.msg.PointCloud message, in frame target_frame