Robotics StackExchange | Archived questions

Reading LaserScans from an esp32 through websocket.

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)

Asked by jenggam on 2023-05-13 20:43:44 UTC

Comments

Answers

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.

Asked by Mike Scheutzow on 2023-05-14 08:06:28 UTC

Comments