I made a wheeled robot car and added a lidar. How can I save the lidar data and odometer data in CSV or txt format and save it to my disk?
Also, I have some questions, is it possible to save directly with python, or do I need to go through Ros?
Hope I can get some help, thank you very much.
Hi @fsb0147 - In Omniverse Kit, sensor data, like from a Lidar, can be accessed through Python scripts, therefore it is possible to save data directly to a CSV or txt file without needing to go through ROS.
Here is a simple example of how you could do this with Python:
# Access your data
lidar_data = get_lidar_data()
odometer_data = get_odometer_data()
# Save to a CSV file
with open('lidar_odometer_data.csv', 'w', newline='') as file:
writer = csv.writer(file)
writer.writerow(["Lidar Data", "Odometer Data"])
# Save to a txt file
with open('lidar_odometer_data.txt', 'w') as file:
file.write('Lidar Data: ' + str(lidar_data) + '\n')
file.write('Odometer Data: ' + str(odometer_data) + '\n')
The get_lidar_data and get_odometer_data are placeholders for however you get your data. Replace these with the functions or variables that hold your Lidar and odometer data.
Remember to handle the file paths carefully and make sure your application has the necessary write permissions to the folder where you want to save the data.
Thank you very much for your reply. I made some attempts and successfully saved the CSV. At the beginning, I could get the data and save it to CSV. But recently I encountered a problem, and I haven’t been able to find the reason. Recently, when using the same code, an error occurred. I don’t know what causes it.
Hello @fsb0147. Try adding this line before timeline.play() is called:
timeline = omni.timeline.get_timeline_interface()
@upyzm Thank you very much for your help. I successfully solved this problem. My solution was to re-run the official code. In the past, when I ran the official code, different errors were reported. I think it was a cache problem.
How to get Odometer data using python? I didn’t see any documentation.