How to save LiDAR and mileage data?

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:

import csv

# 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"])
    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 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.

1 Like


How to get Odometer data using python? I didn’t see any documentation.

Hi @fsb0147 - Try this documentation: 4.7. Data Logging — Omniverse IsaacSim latest documentation