Skip to content

Commit dda3cca

Browse files
committed
tmp: implement assert
Signed-off-by: Takayuki Murooka <takayuki5168@gmail.com>
1 parent 44e4be7 commit dda3cca

File tree

4 files changed

+57
-0
lines changed

4 files changed

+57
-0
lines changed

common/motion_utils/src/resample/resample.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "motion_utils/resample/resample_utils.hpp"
2121
#include "motion_utils/trajectory/trajectory.hpp"
2222
#include "tier4_autoware_utils/geometry/geometry.hpp"
23+
#include "tier4_autoware_utils/system/assert.hpp"
2324

2425
namespace motion_utils
2526
{
@@ -28,6 +29,7 @@ std::vector<geometry_msgs::msg::Point> resamplePointVector(
2829
const std::vector<double> & resampled_arclength, const bool use_akima_spline_for_xy,
2930
const bool use_lerp_for_z)
3031
{
32+
ASSERT(false);
3133
// validate arguments
3234
if (!resample_utils::validate_arguments(points, resampled_arclength)) {
3335
return points;

common/tier4_autoware_utils/CMakeLists.txt

+6
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,14 @@ ament_auto_add_library(tier4_autoware_utils SHARED
1616
src/ros/marker_helper.cpp
1717
src/ros/logger_level_configure.cpp
1818
src/system/backtrace.cpp
19+
src/system/assert.cpp
1920
)
2021

22+
option(ENABLE_ASSERT_ABORT "Option to enable assert abort" ON)
23+
if(ENABLE_ASSERT_ABORT)
24+
target_compile_definitions(tier4_autoware_utils PUBLIC ENABLE_ASSERT_ABORT)
25+
endif()
26+
2127
if(BUILD_TESTING)
2228
find_package(ament_cmake_ros REQUIRED)
2329

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Copyright 2024 TIER IV, 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+
#ifndef TIER4_AUTOWARE_UTILS__SYSTEM__ASSERT_HPP_
16+
#define TIER4_AUTOWARE_UTILS__SYSTEM__ASSERT_HPP_
17+
18+
#ifdef ENABLE_ASSERT_ABORT
19+
20+
#define ASSERT(expr) \
21+
printf( \
22+
"[Assertion] %s() at %s:%d " #expr \
23+
"--------------------------------------------------------------------------------------------" \
24+
"---------------------------------------------------------", \
25+
__FUNCTION__, __FILE__, __LINE__);
26+
27+
#else
28+
29+
#define ASSERT(...)
30+
hogehoge
31+
32+
#endif
33+
34+
#endif // TIER4_AUTOWARE_UTILS__SYSTEM__ASSERT_HPP_
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2024 TIER IV, 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+
#include "tier4_autoware_utils/system/assert.hpp"

0 commit comments

Comments
 (0)