Skip to content
This repository was archived by the owner on Aug 27, 2021. It is now read-only.

Commit a7cad4b

Browse files
authored
Refactor obstacle_stop_planner (#3)
1 parent 8e09f12 commit a7cad4b

38 files changed

+2768
-1585
lines changed

.github/workflows/build_and_test.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ jobs:
2222
with:
2323
required-ros-distributions: foxy
2424

25+
- name: Concat build_depends.repos
26+
run: |
27+
curl -sSL https://raw.githubusercontent.com/tier4/AutowareArchitectureProposal.iv/ros2/build_depends.repos | sed '1d' >> build_depends.repos
28+
2529
- name: Run action-ros-ci
2630
id: action_ros_ci_step
2731
uses: ros-tooling/[email protected]

.isort.cfg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[settings]
2+
force_sort_within_sections=true
3+
known_third_party=launch
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
cmake_minimum_required(VERSION 3.5)
2+
3+
project(ament_cmake_auto_gtest NONE)
4+
5+
find_package(ament_cmake REQUIRED)
6+
7+
ament_package(
8+
CONFIG_EXTRAS "ament_cmake_auto_gtest-extras.cmake"
9+
)
10+
11+
install(
12+
DIRECTORY cmake
13+
DESTINATION share/${PROJECT_NAME}
14+
)

ament_cmake_auto_gtest/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
NOTE: This package is temporary and will be removed after the following pull requests have been merged.
2+
3+
<https://github.com/ament/ament_cmake/pull/257>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Copyright 2014 Open Source Robotics Foundation, Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# copied from ament_cmake_auto/ament_cmake_auto-extras.cmake
16+
17+
find_package(ament_cmake_auto QUIET REQUIRED)
18+
find_package(ament_cmake_gtest QUIET REQUIRED)
19+
20+
include("${ament_cmake_auto_gtest_DIR}/ament_auto_add_gtest.cmake")
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
# Copyright 2014 Open Source Robotics Foundation, Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
#
16+
# Add a gtest, automatically linking and including dependencies.
17+
#
18+
# Call add_executable(target ARGN), link it against the gtest libraries
19+
# and register the executable as a test.
20+
#
21+
# If gtest is not available the specified target is not being created and
22+
# therefore the target existence should be checked before being used.
23+
#
24+
#
25+
# All arguments of the CMake function ``add_executable()`` can be
26+
# used beside the custom arguments ``DIRECTORY`` and
27+
# ``NO_TARGET_LINK_LIBRARIES``.
28+
#
29+
# :param target: the name of the executable target
30+
# :type target: string
31+
# :param DIRECTORY: the directory to recursively glob for source
32+
# files with the following extensions: c, cc, cpp, cxx
33+
# :type DIRECTORY: string
34+
# :param NO_TARGET_LINK_LIBRARIES: if set skip linking against
35+
# ``${PROJECT_NAME}_LIBRARIES``
36+
# :type NO_TARGET_LINK_LIBRARIES: option
37+
# :param ARGN: the list of source files
38+
# :type ARGN: list of strings
39+
# :param RUNNER: the path to the test runner script
40+
# (default: see ament_add_test).
41+
# :type RUNNER: string
42+
# :param TIMEOUT: the test timeout in seconds,
43+
# default defined by ``ament_add_test()``
44+
# :type TIMEOUT: integer
45+
# :param WORKING_DIRECTORY: the working directory for invoking the
46+
# executable in, default defined by ``ament_add_test()``
47+
# :type WORKING_DIRECTORY: string
48+
# :param SKIP_LINKING_MAIN_LIBRARIES: if set skip linking against the gtest
49+
# main libraries
50+
# :type SKIP_LINKING_MAIN_LIBRARIES: option
51+
# :param SKIP_TEST: if set mark the test as being skipped
52+
# :type SKIP_TEST: option
53+
# :param ENV: list of env vars to set; listed as ``VAR=value``
54+
# :type ENV: list of strings
55+
# :param APPEND_ENV: list of env vars to append if already set, otherwise set;
56+
# listed as ``VAR=value``
57+
# :type APPEND_ENV: list of strings
58+
# :param APPEND_LIBRARY_DIRS: list of library dirs to append to the appropriate
59+
# OS specific env var, a la LD_LIBRARY_PATH
60+
# :type APPEND_LIBRARY_DIRS: list of strings
61+
#
62+
# @public
63+
#
64+
macro(ament_auto_add_gtest target)
65+
cmake_parse_arguments(ARG
66+
"WIN32;MACOSX_BUNDLE;EXCLUDE_FROM_ALL;NO_TARGET_LINK_LIBRARIES;SKIP_LINKING_MAIN_LIBRARIES;SKIP_TEST"
67+
"RUNNER;TIMEOUT;WORKING_DIRECTORY;DIRECTORY"
68+
"APPEND_ENV;APPEND_LIBRARY_DIRS;ENV"
69+
${ARGN})
70+
if(NOT ARG_DIRECTORY AND NOT ARG_UNPARSED_ARGUMENTS)
71+
message(FATAL_ERROR "ament_auto_add_executable() called without any "
72+
"source files and without a DIRECTORY argument")
73+
endif()
74+
75+
set(_source_files "")
76+
if(ARG_DIRECTORY)
77+
# glob all source files
78+
file(
79+
GLOB_RECURSE
80+
_source_files
81+
RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
82+
"${ARG_DIRECTORY}/*.c"
83+
"${ARG_DIRECTORY}/*.cc"
84+
"${ARG_DIRECTORY}/*.cpp"
85+
"${ARG_DIRECTORY}/*.cxx"
86+
)
87+
if(NOT _source_files)
88+
message(FATAL_ERROR "ament_auto_add_executable() no source files found "
89+
"in directory '${CMAKE_CURRENT_SOURCE_DIR}/${ARG_DIRECTORY}'")
90+
endif()
91+
endif()
92+
93+
# parse again to "remove" custom arguments
94+
cmake_parse_arguments(ARG "NO_TARGET_LINK_LIBRARIES" "DIRECTORY" "" ${ARGN})
95+
ament_add_gtest("${target}" ${ARG_UNPARSED_ARGUMENTS} ${_source_files})
96+
97+
# add include directory of this package if it exists
98+
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/include")
99+
target_include_directories("${target}" PUBLIC
100+
"${CMAKE_CURRENT_SOURCE_DIR}/include")
101+
endif()
102+
# link against other libraries of this package
103+
if(NOT ${PROJECT_NAME}_LIBRARIES STREQUAL "" AND
104+
NOT ARG_NO_TARGET_LINK_LIBRARIES)
105+
target_link_libraries("${target}" ${${PROJECT_NAME}_LIBRARIES})
106+
endif()
107+
108+
# add exported information from found build dependencies
109+
ament_target_dependencies(${target} ${${PROJECT_NAME}_FOUND_BUILD_DEPENDS})
110+
endmacro()

ament_cmake_auto_gtest/package.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0"?>
2+
<?xml-model href="http://download.ros.org/schema/package_format2.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
3+
<package format="2">
4+
<name>ament_cmake_auto_gtest</name>
5+
<version>0.9.2</version>
6+
<description>The auto-magic functions for ease to use of the ament buildsystem in CMake.</description>
7+
<maintainer email="[email protected]">Dirk Thomas</maintainer>
8+
<license>Apache License 2.0</license>
9+
10+
<buildtool_depend>ament_cmake</buildtool_depend>
11+
<buildtool_depend>ament_cmake_gtest</buildtool_depend>
12+
13+
<buildtool_export_depend>ament_cmake_auto</buildtool_export_depend>
14+
<buildtool_export_depend>ament_cmake_gtest</buildtool_export_depend>
15+
16+
<export>
17+
<build_type>ament_cmake</build_type>
18+
</export>
19+
</package>

obstacle_stop_planner_refine/CMakeLists.txt

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,38 +7,45 @@ if(NOT CMAKE_CXX_STANDARD)
77
set(CMAKE_CXX_EXTENSIONS OFF)
88
endif()
99
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
10-
add_compile_options(-Wall -Wextra -Wpedantic -O3)
10+
add_compile_options(-Wall -Wextra -Wpedantic)
1111
add_compile_options(-Wno-unused-parameter)
1212
endif()
1313

1414
find_package(ament_cmake_auto REQUIRED)
1515
ament_auto_find_build_dependencies()
1616

1717
find_package(Eigen3 REQUIRED)
18-
find_package(OpenCV REQUIRED)
19-
find_package(PCL REQUIRED)
20-
21-
ament_auto_add_executable(obstacle_stop_planner_node
22-
src/debug_marker.cpp
23-
src/node.cpp
24-
src/main.cpp
25-
src/adaptive_cruise_control.cpp
26-
)
2718

28-
target_include_directories(obstacle_stop_planner_node
29-
PUBLIC
30-
${OpenCV_INCLUDE_DIRS}
31-
${PCL_INCLUDE_DIRS}
19+
file(GLOB_RECURSE OBSTACLE_STOP_PLANNER_NODES_NODE_SRC
20+
src/*
21+
)
22+
file(GLOB_RECURSE OBSTACLE_STOP_PLANNER_NODES_NODE_HEADERS
23+
include/obstacle_stop_planner/*
3224
)
3325

34-
target_link_libraries(obstacle_stop_planner_node
35-
${OpenCV_LIBRARIES}
36-
${PCL_LIBRARIES}
26+
# generate component node library
27+
ament_auto_add_library(obstacle_stop_planner_node SHARED
28+
${OBSTACLE_STOP_PLANNER_NODES_NODE_SRC}
29+
${OBSTACLE_STOP_PLANNER_NODES_NODE_HEADERS}
30+
)
31+
rclcpp_components_register_node(obstacle_stop_planner_node
32+
PLUGIN "obstacle_stop_planner::ObstacleStopPlannerNode"
33+
EXECUTABLE obstacle_stop_planner_node_exe
3734
)
3835

3936
if(BUILD_TESTING)
4037
find_package(ament_lint_auto REQUIRED)
4138
ament_lint_auto_find_test_dependencies()
39+
40+
add_ros_test(
41+
test/obstacle_stop_planner_node_launch_test.py
42+
TIMEOUT "30"
43+
)
44+
45+
find_package(ament_cmake_auto_gtest REQUIRED)
46+
ament_auto_add_gtest(test_obstacle_stop_planner
47+
DIRECTORY "test/"
48+
)
4249
endif()
4350

4451
ament_auto_package(
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**:
2+
ros__parameters:
3+
wheel_radius: 0.39
4+
wheel_width: 0.42
5+
wheel_base: 2.74 # between front wheel center and rear wheel center
6+
wheel_tread: 1.63 # between left wheel center and right wheel center
7+
front_overhang: 1.0 # between front wheel center and vehicle front
8+
rear_overhang: 1.03 # between rear wheel center and vehicle rear
9+
left_overhang: 0.1 # between left wheel center and vehicle left
10+
right_overhang: 0.1 # between right wheel center and vehicle right
11+
vehicle_height: 2.5

0 commit comments

Comments
 (0)