ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Vignesh_93's profile - activity

2022-09-08 04:33:05 -0500 received badge  Nice Answer (source)
2022-09-08 04:33:04 -0500 received badge  Student (source)
2022-05-30 09:07:26 -0500 marked best answer Converting x, y, z array to point cloud data

Hello ROS developers, I am trying to convert a2D array to a point cloud value and publish it thereby visualising it in rviz. Can anyone guide me to solve the below issue which I am facing during the conversion ? This is the code and I get the error stated below that.

def scanProcessing(msg):
    laserProj = LaserProjection()
    cloud_out = laserProj.projectLaser(msg)
    xyz_array = ros_numpy.point_cloud2.pointcloud2_to_xyz_array(cloud_out)
    stamp = rospy.Time.now()
    frame_id = 'odom'
    xyz_coordinate = [[x[i],y[i], z[i]] for i in range(len(x))]
    print(xyz_array)
    header = std_msgs.msg.Header()
    header.stamp = rospy.Time.now()
    header.frame_id = 'map'
    cloud_msg = ros_numpy.point_cloud2.array_to_pointcloud2(xyz_array, stamp, frame_id)
    pointcloud_publisher.publish(cloud_msg)

if __name__ == "__main__":
    rospy.init_node('scan_processor')
    pointcloud_publisher = rospy.Publisher("/my_pointcloud_topic", PointCloud, queue_size=1)
    scanSubscriber = rospy.Subscriber('/robot2/scan', LaserScan, scanProcessing, queue_size=1)        
    rospy.spin()

The Error observed is:

[ERROR] [1614671648.584787, 6.342000]: bad callback: <function scanProcessing at 0x7f88928728b0>
Traceback (most recent call last):
  File "/opt/ros/noetic/lib/python3/dist-packages/rospy/topics.py", line 750, in _invoke_callback
    cb(msg)
  File "pointCloud_v8.py", line 120, in scanProcessing
    cloud_msg = ros_numpy.point_cloud2.array_to_pointcloud2(xyz_array, stamp, frame_id)
  File "/opt/ros/noetic/lib/python3/dist-packages/ros_numpy/point_cloud2.py", line 147, in array_to_pointcloud2
    cloud_msg.fields = dtype_to_fields(cloud_arr.dtype)
  File "/opt/ros/noetic/lib/python3/dist-packages/ros_numpy/point_cloud2.py", line 92, in dtype_to_fields
    for field_name in dtype.names:
TypeError: 'NoneType' object is not iterable

P.S: As I understand this is a bit basic question. I would really appreciate some answers which could help me to continue my ROS journey

Edit 1: To emphasize more on the issue side from the comments :

Inside the function array_to_pointcloud2 there is a conversion to a 2D array. After which an object of pointCloud2 is created and the field attribute is associated with the data type of the array which in my case is 'float64' So basically dtype = 'foat64' All all good till the below function, iteration over dtype.names takes place which is None (which is logical), is there anything which we must do to tag it along with the dtype ?

 def dtype_to_fields(dtype):
         fields = []
         for field_name in dtype.names:
             np_field_type, field_offset = dtype.fields[field_name]
             pf = PointField()
             pf.name = field_name
             if np_field_type.subdtype:
                 item_dtype, shape = np_field_type.subdtype
                 pf.count = np.prod(shape)
                 np_field_type = item_dtype
             else:
                 pf.count = 1 ...(more code)...
2022-05-24 19:11:17 -0500 received badge  Popular Question (source)
2022-05-22 15:54:12 -0500 received badge  Rapid Responder (source)
2022-05-22 15:54:12 -0500 answered a question Publish a transparent marker with non-transparent edge

One of an inefficient ways to do so is publishing line markers for each and every cube. But this requires a lot of resou

2022-05-21 05:32:24 -0500 received badge  Famous Question (source)
2022-05-21 05:31:42 -0500 edited question Publish a transparent marker with non-transparent edge

Publish a transparent marker with non-transparent edge Hello developers I am currently working with publishing marker i

2022-05-21 05:31:42 -0500 received badge  Associate Editor (source)
2022-05-21 05:30:18 -0500 edited question Publish a transparent marker with non-transparent edge

Publish a transparent marker with non-transparent edge Hello developers I am currently working with publishing marker i

2022-05-21 05:29:36 -0500 asked a question Publish a transparent marker with non-transparent edge

Publish a transparent marker with non-transparent edge Hello developers I am currently working with publishing marker i

2022-05-21 05:17:37 -0500 commented answer Reasons for marker or markerarray to be invisible in rviz?

Can we make the edge of a marker non tranparent but the marker on the whole is transparent ?

2022-05-20 12:22:51 -0500 commented answer How to show multiple LINE_STRIPs?

Any idea on using marker arrays to publish multiple line strips ?

2022-05-05 05:55:43 -0500 commented answer How can I change transform from "frame A" to "frame B" ?

Apologies for a late reply. Can you be more specific on the node ? Like giving details like what does the node do, what

2022-04-07 12:55:29 -0500 received badge  Popular Question (source)
2022-04-07 12:55:29 -0500 received badge  Notable Question (source)
2022-04-02 05:32:56 -0500 received badge  Necromancer (source)
2022-01-31 03:59:07 -0500 received badge  Famous Question (source)
2021-07-23 08:52:50 -0500 received badge  Famous Question (source)
2021-07-21 12:45:20 -0500 received badge  Notable Question (source)
2021-07-09 05:43:47 -0500 received badge  Notable Question (source)
2021-07-09 03:33:42 -0500 edited question Limitations of visualizing a topic in rviz

Limitations of visualizing a topic in rviz ROS Enthusiasts Many of us would have observed this phenomenon while publish

2021-07-09 03:33:15 -0500 asked a question Limitations of visualizing a topic in rviz

Limitations of visualizing a topic in rviz ROS Enthusiasts Many of us would have observed this phenomenon while publishi

2021-07-05 05:46:55 -0500 commented question Does transforming a pointcloud message from one frame to another result in the change of frame id of the transformed message?

The way I am doing is listening to the transform with the help of a tf::TransformListener object and then transform the

2021-07-05 02:24:09 -0500 received badge  Famous Question (source)
2021-07-02 07:44:40 -0500 answered a question How can I change transform from "frame A" to "frame B" ?

For the question, First you need to transform from one source frame to target frame using the available functions. For

2021-07-02 05:54:33 -0500 received badge  Notable Question (source)
2021-07-02 01:38:57 -0500 received badge  Popular Question (source)
2021-07-01 16:27:08 -0500 commented question How can I change transform from "frame A" to "frame B" ?

It would also be helpful for others if the way to change the frame id in a particular message is explained. As stated by

2021-07-01 16:21:10 -0500 edited question Does transforming a pointcloud message from one frame to another result in the change of frame id of the transformed message?

Does transforming a pointcloud message from one frame to another result in the change of frame id of the transformed mes

2021-07-01 16:18:24 -0500 asked a question Does transforming a pointcloud message from one frame to another result in the change of frame id of the transformed message?

Does transforming a pointcloud message from one frame to another result in the change of frame id of the transformed mes

2021-06-05 08:58:02 -0500 answered a question Issue with converting laser scan readings from base_scan frame to odom frame

Closing this as the issue was with the frame id. When publishing the point cloud, it is always advised to publish the po

2021-06-05 08:56:16 -0500 received badge  Popular Question (source)
2021-04-30 08:56:02 -0500 received badge  Popular Question (source)
2021-04-22 08:33:29 -0500 edited question Issue with converting laser scan readings from base_scan frame to odom frame

Issue with converting laser scan readings from base_scan frame to odom frame ROS developers and robotic enthusiasts Re

2021-04-22 08:32:37 -0500 asked a question Issue with converting laser scan readings from base_scan frame to odom frame

Issue with converting laser scan readings from base_scan frame to odom frame ROS developers and robotic enthusiasts Rec

2021-04-01 10:28:18 -0500 received badge  Self-Learner (source)
2021-04-01 10:28:18 -0500 received badge  Teacher (source)
2021-03-31 10:05:02 -0500 received badge  Notable Question (source)
2021-03-31 06:51:42 -0500 commented answer Transforming PointCloud2

I have tested this part of the code and am facing some offset issues, meaning there is an increasing offset issue with i

2021-03-31 06:44:06 -0500 answered a question How do we align the robot's orientation each and every instant in delivering a PID controlled motion to a desired location x, y ?

CLosing the question as its solution is already available online. Below is snipped of my version of the function of a pr

2021-03-29 07:38:43 -0500 received badge  Popular Question (source)
2021-03-28 03:38:04 -0500 asked a question How to fuse radar with 2D lidar and generate maps using NDT packages

How to fuse radar with 2D lidar and generate maps using NDT packages I am working with 3D radar and 2D lidar and trying

2021-03-27 16:51:39 -0500 received badge  Famous Question (source)
2021-03-27 07:36:57 -0500 edited question How do we align the robot's orientation each and every instant in delivering a PID controlled motion to a desired location x, y ?

How do we align the robot's orientation each and every instant in delivering a PID controlled motion to a desired locati

2021-03-27 07:36:52 -0500 edited question How do we align the robot's orientation each and every instant in delivering a PID controlled motion to a desired location x, y ?

How do we align the robot's orientation each and every instant in delivering a PID controlled motion to a desired locati