Carma-platform v4.2.0
CARMA Platform is built on robot operating system (ROS) and utilizes open source software (OSS) that enables Cooperative Driving Automation (CDA) features to allow Automated Driving Systems to interact and cooperate with infrastructure and other vehicles through communication.
ros2_rosbag Namespace Reference

Functions

def record_ros2_rosbag (LaunchContext context, vehicle_config_param_file, rosbag2_qos_override_param_file)
 
def generate_launch_description ()
 

Function Documentation

◆ generate_launch_description()

def ros2_rosbag.generate_launch_description ( )

Definition at line 81 of file ros2_rosbag.launch.py.

82 # Declare the vehicle_config_dir launch argument
83 vehicle_config_dir = LaunchConfiguration('vehicle_config_dir')
84 declare_vehicle_config_dir_arg = DeclareLaunchArgument(
85 name = 'vehicle_config_dir',
86 default_value = "/opt/carma/vehicle/config",
87 description = "Path to file containing vehicle config directories"
88 )
89
90 # Declare the vehicle_config_param_file launch argument
91 vehicle_config_param_file = LaunchConfiguration('vehicle_config_param_file')
92 declare_vehicle_config_param_file_arg = DeclareLaunchArgument(
93 name = 'vehicle_config_param_file',
94 default_value = [vehicle_config_dir, "/VehicleConfigParams.yaml"],
95 description = "Path to file contain vehicle configuration parameters"
96 )
97
98 rosbag2_qos_override_param_file = LaunchConfiguration('rosbag2_qos_override_param_file')
99 declare_rosbag2_qos_override_param_file = DeclareLaunchArgument(
100 name='rosbag2_qos_override_param_file',
101 default_value = PathJoinSubstitution([
102 FindPackageShare('carma'),'config',
103 'rosbag2_qos_overrides.yaml'
104 ]),
105 description = "Path to file containing rosbag2 override qos settings"
106 )
107
108 return LaunchDescription([
109 declare_vehicle_config_dir_arg,
110 declare_vehicle_config_param_file_arg,
111 declare_rosbag2_qos_override_param_file,
112 OpaqueFunction(function=record_ros2_rosbag, args=[vehicle_config_param_file, rosbag2_qos_override_param_file])
113 ])
def generate_launch_description()

◆ record_ros2_rosbag()

def ros2_rosbag.record_ros2_rosbag ( LaunchContext  context,
  vehicle_config_param_file,
  rosbag2_qos_override_param_file 
)

Definition at line 29 of file ros2_rosbag.launch.py.

29def record_ros2_rosbag(context: LaunchContext, vehicle_config_param_file, rosbag2_qos_override_param_file):
30
31 # Convert LaunchConfiguration object to its string representation
32 vehicle_config_param_file_string = context.perform_substitution(vehicle_config_param_file)
33
34 # Initialize an array that will contain the regex for topics to exclude from the ROS 2 rosbag
35 exclude_topics = []
36
37 overriding_qos_profiles = context.perform_substitution(rosbag2_qos_override_param_file)
38
39 # Open vehicle config params file to process various rosbag settings
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 # Join the topics with | to create a proper regex
64 exclude_topics_regex = "|".join(exclude_topics) if exclude_topics else ""
65
66 proc = ExecuteProcess(
67 cmd=[
68 'bash', '-c', 'ros2 bag record -a -s mcap --qos-profile-overrides-path '
69 + overriding_qos_profiles + ' -o /opt/carma/logs/rosbag2_'
70 + str(datetime.now().strftime('%Y-%m-%d_%H%M%S')) + ' -x "'
71 + exclude_topics_regex
72 #+ '"'], # Uncomment this line to see ros2bag topic subscriptions
73 + '" >/dev/null 2>&1'], # Turns off ros2bag print statements
74 output='screen',
75 shell='true'
76 )
77
78 return [proc]
79
80
def record_ros2_rosbag(LaunchContext context, vehicle_config_param_file, rosbag2_qos_override_param_file)

References create_two_lane_map.str.