Skip to content

Commit

Permalink
tmp: implement assert
Browse files Browse the repository at this point in the history
Signed-off-by: Takayuki Murooka <[email protected]>
  • Loading branch information
takayuki5168 committed Mar 7, 2024
1 parent 44e4be7 commit dda3cca
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 0 deletions.
2 changes: 2 additions & 0 deletions common/motion_utils/src/resample/resample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "motion_utils/resample/resample_utils.hpp"
#include "motion_utils/trajectory/trajectory.hpp"
#include "tier4_autoware_utils/geometry/geometry.hpp"
#include "tier4_autoware_utils/system/assert.hpp"

namespace motion_utils
{
Expand All @@ -28,6 +29,7 @@ std::vector<geometry_msgs::msg::Point> resamplePointVector(
const std::vector<double> & resampled_arclength, const bool use_akima_spline_for_xy,
const bool use_lerp_for_z)
{
ASSERT(false);
// validate arguments
if (!resample_utils::validate_arguments(points, resampled_arclength)) {
return points;
Expand Down
6 changes: 6 additions & 0 deletions common/tier4_autoware_utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,14 @@ ament_auto_add_library(tier4_autoware_utils SHARED
src/ros/marker_helper.cpp
src/ros/logger_level_configure.cpp
src/system/backtrace.cpp
src/system/assert.cpp
)

option(ENABLE_ASSERT_ABORT "Option to enable assert abort" ON)
if(ENABLE_ASSERT_ABORT)
target_compile_definitions(tier4_autoware_utils PUBLIC ENABLE_ASSERT_ABORT)
endif()

if(BUILD_TESTING)
find_package(ament_cmake_ros REQUIRED)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright 2024 TIER IV, Inc.
//
// 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.

#ifndef TIER4_AUTOWARE_UTILS__SYSTEM__ASSERT_HPP_
#define TIER4_AUTOWARE_UTILS__SYSTEM__ASSERT_HPP_

#ifdef ENABLE_ASSERT_ABORT

#define ASSERT(expr) \
printf( \
"[Assertion] %s() at %s:%d " #expr \
"--------------------------------------------------------------------------------------------" \
"---------------------------------------------------------", \
__FUNCTION__, __FILE__, __LINE__);

#else

#define ASSERT(...)
hogehoge

Check warning on line 30 in common/tier4_autoware_utils/include/tier4_autoware_utils/system/assert.hpp

View workflow job for this annotation

GitHub Actions / spell-check-partial

Unknown word (hogehoge)

#endif

#endif // TIER4_AUTOWARE_UTILS__SYSTEM__ASSERT_HPP_
15 changes: 15 additions & 0 deletions common/tier4_autoware_utils/src/system/assert.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright 2024 TIER IV, Inc.
//
// 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.

#include "tier4_autoware_utils/system/assert.hpp"

0 comments on commit dda3cca

Please sign in to comment.