Reputation: 31
I'm newbie in ros
I'm trying to save LiDAR Laserscan data to npy file to check my test code without launching ros.
The ideal form i wanna save is numpy array file which contains every information in each Laserscan topic data such as header(stamp, seq), angle data(angle_min, --), ranges.
I hope I can use this data at the my test code. It looks like
buffer = np.load('scan_save.npy', allow_pickle = True)
buffer[0] = prev_scan
for scan in buffer[1:]:
scan.header.stamp - prev_scan.stamp = dt
function(scan.ranges)
...
I have no idea how to save all of scan data together not only 'ranges' but 'header, angle_min, time_increment'
Also, I want append each scan data every time scan subscriber get the scan data
Only thing I can do is
scandata = msg.ranges # msg is Laserscan
np.save("~/scan_save", scandata)
Upvotes: 1
Views: 583
Reputation: 31
I solved my qustion! here is my code :)
By dong this, I could save all of topic as numpy array
self.scan_data = np.array([]) # define it at __init__
'''at the scan callbalck function'''
buffer = msg # Laserscan msg from subscriber
self.scan_data = np.array(buffer)
self.save_scan = np.append(self.save_scan, scan_data)
np.save("~/record/scan", self.save_scan)
Upvotes: 2