[英]How can I save scan data(topic) in npy file?
我是ros的新手
我正在嘗試將 LiDAR Laserscan 數據保存到 npy 文件以在不啟動 ros 的情況下檢查我的測試代碼。
我想保存的理想形式是 numpy 數組文件,其中包含每個 Laserscan 主題數據中的所有信息,例如標題(stamp,seq),角度數據(angle_min,--),范圍。
我希望我可以在我的測試代碼中使用這些數據。 看起來像
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)
...
我不知道如何將所有掃描數據一起保存,不僅是“范圍”,還有“標題、角度最小值、時間增量”
另外,我想要 append 每個掃描數據每次掃描訂閱者獲取掃描數據
我唯一能做的就是
scandata = msg.ranges # msg is Laserscan
np.save("~/scan_save", scandata)
我解決了我的問題:這是我的代碼:)
通過這個,我可以將所有主題保存為 numpy 數組
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)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.