ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

Need interpretation of error:'PointCloud2' object has no attribute 'channels'

asked 2015-03-25 13:28:32 -0600

rnunziata gravatar image

updated 2015-03-25 13:28:52 -0600

Need interpretation of error

 [ERROR] [WallTime: 1427306405.964789] [396.335000] bad callback: <bound method TranslatePCL.callback of <__main__.TranslatePCL instance at 0x7f1e81cab638>>
    Traceback (most recent call last):
      File "/opt/ros/indigo/lib/python2.7/dist-packages/rospy/", line 702, in _invoke_callback
      File "/home/richard/catkin_ws/src/gazebo_ros_demos/prrbot_control/src/", line 259, in callback
        pcl_out = self.transformPointCloud("/rrbot/camera_frame", msg)
      File "/home/richard/catkin_ws/src/gazebo_ros_demos/prrbot_control/src/", line 264, in transformPointCloud
        return self.listener.transformPointCloud(target_frame, point_cloud);
      File "/opt/ros/indigo/lib/python2.7/dist-packages/tf/", line 219, in transformPointCloud
        r.channels = point_cloud.channels
    AttributeError: 'PointCloud2' object has no attribute 'channels'
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2015-03-25 15:12:46 -0600

gvdhoorn gravatar image

updated 2015-03-26 03:06:25 -0600

It would seem instances of class PointCloud2 don't have a member variable called channels.

That is what the error tells you.


ah...I was looking for a deeper 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/, 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
edit flag offensive delete link more


ah...I was looking for a deeper what are channels and why is transformPointCloud looking for them.

rnunziata gravatar image rnunziata  ( 2015-03-25 19:26:38 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2015-03-25 13:28:32 -0600

Seen: 1,372 times

Last updated: Mar 26 '15