Closed Crear12 closed 2 years ago
I have not tried that myself, but it should be quite straightforward with the existing tools. Something like this:
import velodyne_decoder as vd
import socket
import sys
import time
def read_live_data(ip, port, config, as_pcl_structs=False):
decoder = vd.StreamDecoder(config)
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.bind((ip, port))
while True:
data, address = s.recvfrom(vd.PACKET_SIZE * 2)
recv_stamp = time.time()
yield decoder.decode(recv_stamp, data, as_pcl_structs)
if __name__ == "__main__":
ip = sys.argv[1]
port = sys.argv[2]
config = vd.Config(model="VLP-16", rpm=600)
for stamp, points in read_live_data(ip, port, config):
print(stamp, points.shape)
Let me know if that works and I might add this to the library as well.
Thanks! Just checked, your code works with some modifications.
import velodyne_decoder as vd
import socket
import sys
import time
def read_live_data(ip, port, config, as_pcl_structs=False): decoder = vd.StreamDecoder(config) s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.bind((ip, port)) while True: data, address = s.recvfrom(vd.PACKET_SIZE * 2) recv_stamp = time.time() yield decoder.decode(recv_stamp, data, as_pcl_structs)
if name == "main": ip = sys.argv[1] # The localhost IP, not the LiDAR's IP. port = int(sys.argv[2]) # 2368 by default config = vd.Config(model="Alpha Prime", rpm=600) for Data in read_live_data(ip, port, config): if Data != None: stamp, points = Data print(stamp, points.shape)
Thank you for your help! I will acknowledge your efforts in my paper (if any)!
Now we have successfully connect our Jetson Orin to the LiDAR device and we can use tcpdump to generate .pcap files without involving ROS. (.pcap files are just the network traffic packages) However, to test real-time processing, we would like to directly analyze the LiDAR stream instead of saving and then analyzing the pcap files. May I ask how to directly use the IP address and maybe port number as LiDAR input?