autoware_record is an Autoware ROS bag record file (in sqlite)
offline parse tool. You can use autoware_record
to read messages from record file.
os | support | remark |
---|---|---|
ubuntu | ✔️ | |
mac | ||
windows |
- ROS2 humble
- Python 3.10.12 or later
- Reduced installation of Autoware
First clone "autoware_record" to your project:
git clone https://github.com/lethal233/autoware_record.git
You can download a Autoware demo record from sample-rosbag.zip
NOTE: NOT Supported for now
You can use autoware_record
in the python file by importing
from autoware_record.record import Record
Below are some examples to help you read and write messages from record files.
You can read messages directly from the record file in the following ways.
from autoware_record.record import Record
record_file_path = "~/Downloads/sample-rosbag/"
record = Record(record_file_path)
for topic, message, t in record.read_messages():
print("{}, {}, {}".format(topic, type(message), t))
The following is the output log of the program
/clock, <class 'rosgraph_msgs.msg._clock.Clock'>, 1614315746338218272
/sensing/imu/tamagawa/imu_raw, <class 'sensor_msgs.msg._imu.Imu'>, 1614315746340263903
/clock, <class 'rosgraph_msgs.msg._clock.Clock'>, 1614315746347214625
/vehicle/status/control_mode, <class 'autoware_auto_vehicle_msgs.msg._control_mode_report.ControlModeReport'>, 1614315746348259492
/vehicle/status/gear_status, <class 'autoware_auto_vehicle_msgs.msg._gear_report.GearReport'>, 1614315746348361304
/vehicle/status/steering_status, <class 'autoware_auto_vehicle_msgs.msg._steering_report.SteeringReport'>, 1614315746348408503
/vehicle/status/velocity_status, <class 'autoware_auto_vehicle_msgs.msg._velocity_report.VelocityReport'>, 1614315746348462066
/clock, <class 'rosgraph_msgs.msg._clock.Clock'>, 1614315746357520034
You can also read messages filtered by topics and time. This will improve the speed of parsing messages.
from autoware_record.record import Record
file_name = "~/Downloads/sample-rosbag/"
def read_filter():
record = Record(file_name)
for topic, message, t in record.read_messages('/vehicle/status/gear_status',
start_time=1614315746865701308, end_time=1614315776212543503):
print("{}, {}, {}".format(topic, type(message), t))
Since deserialization is a time-consuming operation, you can speed up the reading process by setting the interested_topics
parameter.
If the topic is not in the interested_topics
, the message will not be deserialized.
autoware_record/autoware_record/record.py
Line 77 in 4a1d722
from autoware_record.record import Record
file_name = "~/Downloads/sample-rosbag/"
interested_topics = ['/vehicle/status/gear_status', '/clock']
record = Record(file_name, interested_topics=interested_topics)
for topic, message, t in record.read_messages():
print("{}, {}, {}".format(topic, type(message), t))