29def record_ros2_rosbag(context: LaunchContext, vehicle_config_param_file, rosbag2_qos_override_param_file):
30
31
32 vehicle_config_param_file_string = context.perform_substitution(vehicle_config_param_file)
33
34
35 exclude_topics = []
36
37 overriding_qos_profiles = context.perform_substitution(rosbag2_qos_override_param_file)
38
39
40 with open(vehicle_config_param_file_string, 'r') as f:
41
42 vehicle_config_params = yaml.safe_load(f)
43
44 if "use_ros2_rosbag" in vehicle_config_params:
45 if vehicle_config_params["use_ros2_rosbag"] == True:
46
47 if "exclude_default" in vehicle_config_params:
48 if (vehicle_config_params["exclude_default"] == True) and ("excluded_default_topics" in vehicle_config_params):
49 exclude_topics.extend(vehicle_config_params["excluded_default_topics"])
50
51 if "exclude_lidar" in vehicle_config_params:
52 if (vehicle_config_params["exclude_lidar"] == True) and ("excluded_lidar_topics" in vehicle_config_params):
53 exclude_topics.extend(vehicle_config_params["excluded_lidar_topics"])
54
55 if "exclude_camera" in vehicle_config_params:
56 if (vehicle_config_params["exclude_camera"] == True) and ("excluded_camera_topics" in vehicle_config_params):
57 exclude_topics.extend(vehicle_config_params["excluded_camera_topics"])
58
59 if "exclude_can" in vehicle_config_params:
60 if (vehicle_config_params["exclude_can"] == True) and ("excluded_can_topics" in vehicle_config_params):
61 exclude_topics.extend(vehicle_config_params["excluded_can_topics"])
62
63
64 exclude_topics_regex = "|".join(exclude_topics) if exclude_topics else ""
65
66 proc = ExecuteProcess(
67 cmd=['ros2', 'bag', 'record', '-a', '-s', 'mcap',
68 '--qos-profile-overrides-path', overriding_qos_profiles,
69 '-o', '/opt/carma/logs/rosbag2_' + str(datetime.now().strftime('%Y-%m-%d_%H%M%S')),
70 '-x', exclude_topics_regex],
71 output='screen',
72 shell='true'
73 )
74
75 return [proc]
76
77
def record_ros2_rosbag(LaunchContext context, vehicle_config_param_file, rosbag2_qos_override_param_file)