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)