Reputation: 1
I am having a velodyne lidar VLP 32C, my aim is to take data, parse and visualize. Below is the code I am using. I am getting the datapackets from the lidar but when trying to parse and visualize I am getting an error.
import socket
import numpy as np
from velodyne_decoder.decoder import VLP32CDecoder
# Configuration settings
LIDAR_IP = "192.168.1.201"
LIDAR_PORT = 2368
# Create a socket to receive data from the LiDAR
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.bind(('', LIDAR_PORT))
# Initialize the Velodyne decoder
decoder = VLP32CDecoder()
print(f"Listening for data from {LIDAR_IP} on port {LIDAR_PORT}")
try:
while True:
data, addr = sock.recvfrom(1206) # Velodyne data packets are typically 1206 bytes
if addr[0] == LIDAR_IP:
# Decode the packet to a point cloud
point_cloud = decoder.decode(data)
# Convert to numpy array for further processing
points = np.array(point_cloud.points) # Assuming 'points' is the attribute with XYZ coordinates
intensities = np.array(point_cloud.intensities) # Assuming 'intensities' is the attribute with intensity values
# Print a small sample of the parsed data
print(f"Points: {points[:5]}")
print(f"Intensities: {intensities[:5]}")
# Here, you can further process the point cloud data, e.g., save to a file, visualize, etc.
except KeyboardInterrupt:
print("Stopping data capture.")
finally:
sock.close()
print("Socket closed.")
This the error I got:
Traceback (most recent call last):
File "velodynedecoder.py", line 3, in <module>
from velodyne_decoder.decoder import VLP32CDecoder
ModuleNotFoundError: No module named 'velodyne_decoder.decoder'
Does velodyne decoder doesnot support VLP 32C? Can anyone help me on taking data and point cloud generation using this velodyne decoder for VLP 32C? Is there any other method to do this?
Upvotes: 0
Views: 212