Skip to content

Commit

Permalink
Integrate ros2_tracing into carma-platform (#2190)
Browse files Browse the repository at this point in the history
  • Loading branch information
saina-ramyar authored Nov 20, 2023
2 parents 89abf3a + 6cbcb15 commit 66d4304
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ jobs:
command: |
source ${INIT_ENV}
export ROS_PARALLEL_JOBS='-j4 -l4' # Try to reduce memory consumption on build
sed -i 's/colcon build /colcon build --packages-skip novatel_oem7_msgs novatel_oem7_driver /' /home/carma/.ci-image/engineering_tools/code_coverage/make_with_coverage.bash
sed -i 's/colcon build /colcon build --packages-skip novatel_oem7_msgs tracetools tracetools_test /' /home/carma/.ci-image/engineering_tools/code_coverage/make_with_coverage.bash
make_with_coverage.bash -m -e /opt/carma/ -o ./coverage_reports/gcov
- run:
name: Run C++ Tests ROS 1
command: |
source ${INIT_ENV}
export ROS_PARALLEL_JOBS='-j4 -l4' # Try to reduce memory consumption on build
sed -i 's/colcon test /colcon test --packages-skip novatel_oem7_msgs novatel_oem7_driver /' /home/carma/.ci-image/engineering_tools/code_coverage/make_with_coverage.bash
sed -i 's/colcon test /colcon test --packages-skip novatel_oem7_msgs tracetools tracetools_test /' /home/carma/.ci-image/engineering_tools/code_coverage/make_with_coverage.bash
make_with_coverage.bash -t -e /opt/carma/ -o ./coverage_reports/gcov
- run:
name: Backup ROS1 compile_commands.json
Expand Down
38 changes: 37 additions & 1 deletion carma/launch/carma_src.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

from ament_index_python import get_package_share_directory
import launch
from launch.actions import Shutdown
from launch import LaunchDescription
from launch_ros.actions import Node
Expand All @@ -26,9 +27,36 @@
from carma_ros2_utils.launch.get_log_level import GetLogLevel
from launch.substitutions import LaunchConfiguration, PythonExpression
from launch.actions import DeclareLaunchArgument
from launch.actions import OpaqueFunction

from tracetools_launch.action import Trace

from datetime import datetime
import os

def create_ros2_tracing_action(context, *args, **kwargs):
"""
Opaque Function for generating a 'Trace' ROS 2 launch action, which is dependent on the
'ROS_LOG_DIR' EnvironmentVariable and the 'is_ros2_tracing_enabled' LaunchConfiguration.
NOTE: This Opaque Function is required in order to evaluate the 'ROS_LOG_DIR' environment
variable as a string.
"""
log_directory_string = launch.substitutions.EnvironmentVariable('ROS_LOG_DIR').perform(context)

trace = GroupAction(
condition=IfCondition(LaunchConfiguration('is_ros2_tracing_enabled')),
actions=[
Trace(
base_path = log_directory_string,
session_name='my-tracing-session-' + str(datetime.now().strftime('%Y-%m-%d_%H%M%S')),
events_kernel = [], # Empty since kernel tracing is not enabled for CARMA Platform
)
]
)

return [trace]

def generate_launch_description():
"""
Launch CARMA System.
Expand Down Expand Up @@ -144,6 +172,12 @@ def generate_launch_description():
simulation_mode = LaunchConfiguration('simulation_mode')
declare_simulation_mode = DeclareLaunchArgument(name='simulation_mode', default_value = 'False', description = 'True if CARMA Platform is launched with CARLA Simulator')

is_ros2_tracing_enabled = LaunchConfiguration('is_ros2_tracing_enabled')
declare_is_ros2_tracing_enabled = DeclareLaunchArgument(
name='is_ros2_tracing_enabled',
default_value = 'False',
description = 'True if user wants ROS 2 Tracing logs to be generated from CARMA Platform.')

# Launch ROS2 rosbag logging
ros2_rosbag_launch = GroupAction(
actions=[
Expand Down Expand Up @@ -290,6 +324,7 @@ def generate_launch_description():
declare_arealist_path,
declare_vector_map_file,
declare_simulation_mode,
declare_is_ros2_tracing_enabled,
drivers_group,
transform_group,
environment_group,
Expand All @@ -298,5 +333,6 @@ def generate_launch_description():
guidance_group,
ros2_rosbag_launch,
ui_group,
system_controller
system_controller,
OpaqueFunction(function=create_ros2_tracing_action)
])
13 changes: 11 additions & 2 deletions docker/checkout.bash
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ echo "" > COLCON_IGNORE

cd ../

# Clone the foxy branch of ros2_tracing in order to enable certain analyses of CARMA Platform
# made possible through collected trace data, such as analyzing ROS 2 callback durations.
git clone -b foxy https://github.com/ros2/ros2_tracing

#rosbridge_suite is a ROS meta-package including all the rosbridge packages.
# NOTE: clone -b flag is used instead of --branch to avoid hook rewriting it
git clone -b ros2 https://github.com/usdot-fhwa-stol/rosbridge_suite
Expand All @@ -84,10 +88,15 @@ git clone -b carma-develop https://github.com/usdot-fhwa-stol/rosbag2
# NOTE: This is required since otherwise this image will not contain the novatel_oem7_msgs package, and a missing ROS 2 message package
# can cause ROS 2 rosbag logging to fail in Foxy.
# Related GitHub discussion for fix that was not backported to Foxy: https://github.com/ros2/rosbag2/pull/858
sudo git clone https://github.com/novatel/novatel_oem7_driver.git ${dir}/src/novatel_oem7_driver -b ros2-dev
git clone https://github.com/novatel/novatel_oem7_driver.git ${dir}/src/novatel_oem7_driver -b ros2-dev
# Checkout verified commit
cd ${dir}/src/novatel_oem7_driver
sudo git checkout 3055e220bb9715b59c3ef53ab0aba05a495d9d5
git checkout 3055e220bb9715b59c3ef53ab0aba05a495d9d5
# Ignore novatel_oem7_driver package; only novatel_oem7_msgs is required
cd ${dir}/src/novatel_oem7_driver/src/novatel_oem7_driver
echo "" > COLCON_IGNORE
cd ${dir}/src


cd ${dir}/src

Expand Down
4 changes: 2 additions & 2 deletions docker/install.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

# Copyright (C) 2018-2021 LEIDOS.
# Copyright (C) 2018-2023 LEIDOS.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
Expand Down Expand Up @@ -46,7 +46,7 @@ if [[ ! -z "$ROS1_PACKAGES$ROS2_PACKAGES" ]]; then
fi
else
echo "Building all ROS1 CARMA Components"
colcon build --install-base /opt/carma/install --cmake-args -DCMAKE_BUILD_TYPE=Release --packages-skip novatel_oem7_driver novatel_oem7_msgs
colcon build --install-base /opt/carma/install --cmake-args -DCMAKE_BUILD_TYPE=Release --packages-skip novatel_oem7_msgs tracetools tracetools_test
fi
echo "Build of ROS1 CARMA Components Complete"

Expand Down

0 comments on commit 66d4304

Please sign in to comment.