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

Reading LaserScans from an esp32 through websocket.

asked 2023-05-13 20:43:44 -0500

jenggam gravatar image

Is it possible to read the lidar readings from an esp32 through a websocket? I'm planning to publish this readings on a scan topic for me to visualize them on rviz2.

I am receiving angles (in radians) and ranges (in meters) from the websocket. I am successfully receiving and publishing the data into /scan topic. However, once i try to open slam_toolbox or rviz2 they always discard the message due to the queue being full even if that message is the first one to arrive.

def on_message(self, ws, message):
    data = json.loads(message)
    angles = data['angles']
    ranges = data['ranges']

    scan = LaserScan()
    scan.header.stamp = self.get_clock().now().to_msg()
    scan.header.frame_id = "laser"
    scan.angle_min = min(angles)
    scan.angle_max = max(angles)
    scan.range_max = max(ranges)
    scan.ranges = ranges
    scan.intensities = [0. for _ in ranges]

    self.publish_.publish(scan)
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2023-05-14 08:06:28 -0500

Mike Scheutzow gravatar image

For most data types, rviz needs to convert the coordinates of the input data to a single "fixed frame" for display. You select which frame rviz should use for this, for example: "map" or "world".

One possible reason the queue is overflowing is that your setup has not provided a TF Transform (or sequence of transforms) to get from the "laser" frame to your fixed frame. rviz waits for the TF info, and so it does not read the scan messages in its subscribe queue until it is able to do something useful with them.

If you set your fixed frame to "laser" in rviz, no data transformation will be needed for the scan data points and rviz should display them centered at x=0, y=0.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2023-05-13 20:43:44 -0500

Seen: 73 times

Last updated: May 14 '23