Skip to content

Commit

Permalink
Merge release/omega (4.8.0) branch into master (#236)
Browse files Browse the repository at this point in the history
<!-- Thanks for the contribution, this is awesome. -->

# PR Details
This PR is to merge release/omega branch into master branch for C1t
release with new version.
## Description

<!--- Describe your changes in detail -->

## Related GitHub Issue

<!--- This project only accepts pull requests related to open GitHub
issues or Jira Keys -->
<!--- If suggesting a new feature or change, please discuss it in an
issue first -->
<!--- If fixing a bug, there should be an issue describing it with steps
to reproduce -->
<!--- Please DO NOT name partially fixed issues, instead open an issue
specific to this fix -->
<!--- Please link to the issue here: -->

## Related Jira Key

<!-- e.g. CAR-123 -->

## Motivation and Context

<!--- Why is this change required? What problem does it solve? -->

## How Has This Been Tested?

<!--- Please describe in detail how you tested your changes. -->
<!--- Include details of your testing environment, and the tests you ran
to -->
<!--- see how your change affects other areas of the code, etc. -->

## Types of changes

<!--- What types of changes does your code introduce? Put an `x` in all
the boxes that apply: -->

- [ ] Defect fix (non-breaking change that fixes an issue)
- [ ] New feature (non-breaking change that adds functionality)
- [ ] Breaking change (fix or feature that cause existing functionality
to change)

## Checklist:

<!--- Go over all the following points, and put an `x` in all the boxes
that apply. -->
<!--- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->

- [ ] I have added any new packages to the sonar-scanner.properties file
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
- [ ] I have read the
[**CONTRIBUTING**](https://github.com/usdot-fhwa-stol/carma-platform/blob/develop/Contributing.md)
document.
- [ ] I have added tests to cover my changes.
- [ ] All new and existing tests passed.
  • Loading branch information
SaikrishnaBairamoni authored Sep 11, 2024
2 parents c9471e1 + e4ccd6f commit 85df62e
Show file tree
Hide file tree
Showing 39 changed files with 1,011 additions and 661 deletions.
28 changes: 25 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,55 @@
name: CI
on:
push:
branches:
- develop
- master
- "release/*"
pull_request:
types: [opened, synchronize, reopened]
jobs:
determine_docker_org_and_tag:
runs-on: ubuntu-latest
outputs:
docker_organization: ${{ steps.docker-org-and-tag.outputs.docker_organization }}
docker_image_tag: ${{ steps.docker-org-and-tag.outputs.docker_image_tag }}
steps:
- id: docker-org-and-tag
uses: usdot-fhwa-stol/actions/docker-org-and-tag@main
build:
needs: determine_docker_org_and_tag
defaults:
run:
shell: bash
working-directory: "/opt/carma/"
runs-on: ubuntu-latest
container:
image: usdotfhwastol/carma-base:carma-system-4.5.0
image: ${{ needs.determine_docker_org_and_tag.outputs.docker_organization }}/carma-base:${{ needs.determine_docker_org_and_tag.outputs.docker_image_tag }}
env:
INIT_ENV: "/home/carma/.base-image/init-env.sh"
ROS_2_ENV: "/opt/ros/foxy/setup.bash"
TERM: xterm
options: "--user root"
steps:
- name: Checkout ${{ github.event.repository.name }}
uses: actions/checkout@v3.3.0
uses: actions/checkout@v4
with:
fetch-depth: 0
path: src/${{ github.event.repository.name }}
- name: Move source code
run: mv $GITHUB_WORKSPACE/src /opt/carma/
- name: Determine base branch
id: determine-base-branch
run: |
if [[ "$GITHUB_EVENT_NAME" == "pull_request" ]]; then
echo git_branch="$GITHUB_BASE_REF" >> $GITHUB_OUTPUT
else
echo git_branch="$GITHUB_REF_NAME" >> $GITHUB_OUTPUT
fi
- name: Checkout dependencies
run: |
source "$INIT_ENV"
git clone -b carma-system-4.5.0 --depth 1 https://github.com/usdot-fhwa-stol/carma-msgs.git src/CARMAMsgs
git clone -b ${{ steps.determine-base-branch.outputs.git_branch }} --depth 1 https://github.com/usdot-fhwa-stol/carma-msgs.git src/CARMAMsgs
- name: Build ROS1
run: |
source "$INIT_ENV"
Expand Down
2 changes: 1 addition & 1 deletion bsm_helper/include/bsm_helper/bsm_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#pragma once
#include <string.h>
#include <vector>
#include <exception>
#include <stdexcept>
#include <mutex>
#include <memory>
#include <boost/optional.hpp>
Expand Down
145 changes: 105 additions & 40 deletions carma_ros2_utils/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,25 +1,60 @@
# Copyright 2024 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 the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

cmake_minimum_required(VERSION 3.5)
project(carma_ros2_utils)

find_package(carma_cmake_common REQUIRED)
carma_check_ros_version(2)
carma_package()

find_package(ament_cmake_auto REQUIRED)
find_package(ament_cmake_python REQUIRED)
ament_auto_find_build_dependencies()
include(dependencies.cmake)

carma_package()

# TODO(CAR-6017): Remove when we drop support for Foxy
# rclcpp_lifecycle has breaking API changes starting with Humble
if(("$ENV{ROS_DISTRO}" STREQUAL "foxy") OR ("$ENV{ROS_DISTRO}" STREQUAL "galactic"))
set(carma_ros2_utils_LIFECYCLE_PUBLISHER_INTERFACE_TYPE
rclcpp_lifecycle::LifecyclePublisherInterface
)
else()
set(carma_ros2_utils_LIFECYCLE_PUBLISHER_INTERFACE_TYPE
rclcpp_lifecycle::ManagedEntityInterface
)
endif()

# Includes
include_directories(
include
configure_file(
src/carma_lifecycle_node.hpp.in
carma_ros2_utils/carma_lifecycle_node.hpp
)

# Build
ament_auto_add_library(${PROJECT_NAME} SHARED
ament_auto_add_library(carma_ros2_utils SHARED
src/carma_lifecycle_node.cpp
)

target_include_directories(carma_ros2_utils
PUBLIC
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>
)

include(GNUInstallDirs)

INSTALL(FILES ${PROJECT_BINARY_DIR}/carma_ros2_utils/carma_lifecycle_node.hpp
DESTINATION
${CMAKE_INSTALL_INCLUDEDIR}/carma_ros2_utils
)

ament_auto_add_library(carma_ros2_utils_timers SHARED
src/timers/testing/TestTimer.cpp
src/timers/testing/TestTimerFactory.cpp
Expand Down Expand Up @@ -52,42 +87,72 @@ ament_auto_add_executable(carma_component_container_mt
src/component_container_mt.cpp
)

# Link local targets

target_link_libraries(carma_ros2_utils_timers
${PROJECT_NAME}
)

target_link_libraries(lifecycle_component_wrapper
${PROJECT_NAME}
)

target_link_libraries(lifecycle_component_wrapper_st
lifecycle_component_wrapper
${PROJECT_NAME}
)

target_link_libraries(lifecycle_component_wrapper_mt
lifecycle_component_wrapper
${PROJECT_NAME}
)

target_link_libraries(carma_component_container
carma_component_manager
)

target_link_libraries(carma_component_container_mt
carma_component_manager
)

if(BUILD_TESTING)

add_subdirectory(test)
# These CMake commands were added to ament_cmake_auto in ROS 2 Humble. Until
# CARMA supports ROS 2 Humble, we will use package-local copies.
include(cmake/ament_auto_find_test_dependencies.cmake)
include(cmake/ament_auto_add_gtest.cmake)

ament_auto_add_executable(test_carma_lifecycle_node
test/test_node.cpp
)

ament_auto_add_library(test_minimal_node SHARED
test/test_minimal_node.cpp
)

add_launch_test(
test/launch_test_lifecycle_wrapper.py
)

ament_add_gtest_executable(test_lifecycle_gtest
test/test_lifecycle_manager.cpp
)

ament_target_dependencies(test_lifecycle_gtest
ros2_lifecycle_manager
)

target_link_libraries(test_lifecycle_gtest
rclcpp::rclcpp
rclcpp_lifecycle::rclcpp_lifecycle
)

ament_add_test(test_lifecycle
GENERATE_RESULT_FOR_RETURN_CODE_ZERO
COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/test/launch_lifecycle_test.py"
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
TIMEOUT 30
ENV
TEST_EXECUTABLE=$<TARGET_FILE:test_lifecycle_gtest>
)

ament_auto_add_gtest(test_carma_lifecycle_gtest
test/test_carma_lifecycle_exceptions.cpp
test/test_carma_lifecycle_helpers.cpp
)

ament_auto_add_gtest(test_timers
test/timers/TestingTimers.cpp
)

ament_auto_add_gtest(test_containers
test/containers/containers_test.cpp
)

install(
TARGETS test_carma_lifecycle_node test_minimal_node
# EXPORT should not be needed for unit tests
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib/carma_ros2_utils
RUNTIME DESTINATION lib/carma_ros2_utils # In Ament, Executables are installed to lib/${PROJECT_NAME} not bin
INCLUDES DESTINATION include
)

rclcpp_components_register_nodes(test_minimal_node "carma_ros2_utils_testing::MinimalNode")

endif()

ament_python_install_package(${PROJECT_NAME})
ament_python_install_package(carma_ros2_utils)

ament_auto_package()
112 changes: 112 additions & 0 deletions carma_ros2_utils/cmake/ament_auto_add_gtest.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# Copyright 2021 Whitley Software Services, LLC
#
# 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 the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

#
# Add a gtest with all found test dependencies.
#
# Call add_executable(target ARGN), link it against the gtest libraries
# and all found test dependencies, and then register the executable as a test.
#
# If gtest is not available the specified target is not being created and
# therefore the target existence should be checked before being used.
#
# :param target: the target name which will also be used as the test name
# :type target: string
# :param ARGN: the list of source files
# :type ARGN: list of strings
# :param RUNNER: the path to the test runner script (default:
# see ament_add_test).
# :type RUNNER: string
# :param TIMEOUT: the test timeout in seconds,
# default defined by ``ament_add_test()``
# :type TIMEOUT: integer
# :param WORKING_DIRECTORY: the working directory for invoking the
# executable in, default defined by ``ament_add_test()``
# :type WORKING_DIRECTORY: string
# :param SKIP_LINKING_MAIN_LIBRARIES: if set skip linking against the gtest
# main libraries
# :type SKIP_LINKING_MAIN_LIBRARIES: option
# :param SKIP_TEST: if set mark the test as being skipped
# :type SKIP_TEST: option
# :param ENV: list of env vars to set; listed as ``VAR=value``
# :type ENV: list of strings
# :param APPEND_ENV: list of env vars to append if already set, otherwise set;
# listed as ``VAR=value``
# :type APPEND_ENV: list of strings
# :param APPEND_LIBRARY_DIRS: list of library dirs to append to the appropriate
# OS specific env var, a la LD_LIBRARY_PATH
# :type APPEND_LIBRARY_DIRS: list of strings
#
# @public
#
macro(ament_auto_add_gtest target)
cmake_parse_arguments(_ARG
"SKIP_LINKING_MAIN_LIBRARIES;SKIP_TEST"
"RUNNER;TIMEOUT;WORKING_DIRECTORY"
"APPEND_ENV;APPEND_LIBRARY_DIRS;ENV"
${ARGN})
if(NOT _ARG_UNPARSED_ARGUMENTS)
message(FATAL_ERROR
"ament_auto_add_gtest() must be invoked with at least one source file")
endif()

# add executable
set(_arg_executable ${_ARG_UNPARSED_ARGUMENTS})
if(_ARG_SKIP_LINKING_MAIN_LIBRARIES)
list(APPEND _arg_executable "SKIP_LINKING_MAIN_LIBRARIES")
endif()
ament_add_gtest_executable("${target}" ${_arg_executable})

# add include directory of this package if it exists
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/include")
target_include_directories("${target}" PUBLIC
"${CMAKE_CURRENT_SOURCE_DIR}/include")
endif()

# link against other libraries of this package
if(NOT ${PROJECT_NAME}_LIBRARIES STREQUAL "")
target_link_libraries("${target}" ${${PROJECT_NAME}_LIBRARIES})
endif()

# add exported information from found dependencies
ament_target_dependencies(${target}
${${PROJECT_NAME}_FOUND_BUILD_DEPENDS}
${${PROJECT_NAME}_FOUND_TEST_DEPENDS}
)

# add test
set(_arg_test "")
if(_ARG_RUNNER)
list(APPEND _arg_test "RUNNER" "${_ARG_RUNNER}")
endif()
if(_ARG_TIMEOUT)
list(APPEND _arg_test "TIMEOUT" "${_ARG_TIMEOUT}")
endif()
if(_ARG_WORKING_DIRECTORY)
list(APPEND _arg_test "WORKING_DIRECTORY" "${_ARG_WORKING_DIRECTORY}")
endif()
if(_ARG_SKIP_TEST)
list(APPEND _arg_test "SKIP_TEST")
endif()
if(_ARG_ENV)
list(APPEND _arg_test "ENV" ${_ARG_ENV})
endif()
if(_ARG_APPEND_ENV)
list(APPEND _arg_test "APPEND_ENV" ${_ARG_APPEND_ENV})
endif()
if(_ARG_APPEND_LIBRARY_DIRS)
list(APPEND _arg_test "APPEND_LIBRARY_DIRS" ${_ARG_APPEND_LIBRARY_DIRS})
endif()
ament_add_gtest_test("${target}" ${_arg_test})
endmacro()
41 changes: 41 additions & 0 deletions carma_ros2_utils/cmake/ament_auto_find_test_dependencies.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright 2021 Whitley Software Services, LLC
#
# 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 the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

#
# Invoke find_package() for all test dependencies.
#
# All found package names are appended to the
# ``${PROJECT_NAME}_FOUND_TEST_DEPENDS`` variables.
#
# @public
#
macro(ament_auto_find_test_dependencies)
set(_ARGN "${ARGN}")
if(_ARGN)
message(FATAL_ERROR "ament_auto_find_test_dependencies() called with "
"unused arguments: ${_ARGN}")
endif()

if(NOT _AMENT_PACKAGE_NAME)
ament_package_xml()
endif()

# try to find_package() all test dependencies
foreach(_dep ${${PROJECT_NAME}_TEST_DEPENDS})
find_package(${_dep} QUIET)
if(${_dep}_FOUND)
list(APPEND ${PROJECT_NAME}_FOUND_TEST_DEPENDS ${_dep})
endif()
endforeach()
endmacro()
Loading

0 comments on commit 85df62e

Please sign in to comment.