forked from autowarefoundation/autoware.universe
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request autowarefoundation#305 from tier4/sync-upstream
chore: sync upstream
- Loading branch information
Showing
72 changed files
with
9,345 additions
and
255 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
common/tier4_autoware_utils/include/tier4_autoware_utils/math/sin_table.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright 2023 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__MATH__SIN_TABLE_HPP_ | ||
#define TIER4_AUTOWARE_UTILS__MATH__SIN_TABLE_HPP_ | ||
|
||
#include <cstddef> | ||
|
||
namespace tier4_autoware_utils | ||
{ | ||
|
||
constexpr size_t sin_table_size = 32769; | ||
constexpr size_t discrete_arcs_num_90 = 32768; | ||
constexpr size_t discrete_arcs_num_360 = 131072; | ||
extern const float g_sin_table[sin_table_size]; | ||
|
||
} // namespace tier4_autoware_utils | ||
|
||
#endif // TIER4_AUTOWARE_UTILS__MATH__SIN_TABLE_HPP_ |
27 changes: 27 additions & 0 deletions
27
common/tier4_autoware_utils/include/tier4_autoware_utils/math/trigonometry.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright 2023 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__MATH__TRIGONOMETRY_HPP_ | ||
#define TIER4_AUTOWARE_UTILS__MATH__TRIGONOMETRY_HPP_ | ||
|
||
namespace tier4_autoware_utils | ||
{ | ||
|
||
float sin(float radian); | ||
|
||
float cos(float radian); | ||
|
||
} // namespace tier4_autoware_utils | ||
|
||
#endif // TIER4_AUTOWARE_UTILS__MATH__TRIGONOMETRY_HPP_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8,215 changes: 8,215 additions & 0 deletions
8,215
common/tier4_autoware_utils/src/math/sin_table.cpp
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright 2023 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/math/trigonometry.hpp" | ||
|
||
#include "tier4_autoware_utils/math/constants.hpp" | ||
#include "tier4_autoware_utils/math/sin_table.hpp" | ||
|
||
#include <cmath> | ||
|
||
namespace tier4_autoware_utils | ||
{ | ||
|
||
float sin(float radian) | ||
{ | ||
float degree = radian * (180.f / static_cast<float>(tier4_autoware_utils::pi)) * | ||
(discrete_arcs_num_360 / 360.f); | ||
size_t idx = | ||
(static_cast<int>(std::round(degree)) % discrete_arcs_num_360 + discrete_arcs_num_360) % | ||
discrete_arcs_num_360; | ||
|
||
float mul = 1.f; | ||
if (discrete_arcs_num_90 <= idx && idx < 2 * discrete_arcs_num_90) { | ||
idx = 2 * discrete_arcs_num_90 - idx; | ||
} else if (2 * discrete_arcs_num_90 <= idx && idx < 3 * discrete_arcs_num_90) { | ||
mul = -1.f; | ||
idx = idx - 2 * discrete_arcs_num_90; | ||
} else if (3 * discrete_arcs_num_90 <= idx && idx < 4 * discrete_arcs_num_90) { | ||
mul = -1.f; | ||
idx = 4 * discrete_arcs_num_90 - idx; | ||
} | ||
|
||
return mul * g_sin_table[idx]; | ||
} | ||
|
||
float cos(float radian) { return sin(radian + static_cast<float>(tier4_autoware_utils::pi) / 2.f); } | ||
|
||
} // namespace tier4_autoware_utils |
42 changes: 42 additions & 0 deletions
42
common/tier4_autoware_utils/test/src/math/test_trigonometry.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright 2023 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/math/constants.hpp" | ||
#include "tier4_autoware_utils/math/trigonometry.hpp" | ||
|
||
#include <gtest/gtest.h> | ||
|
||
#include <cmath> | ||
|
||
TEST(trigonometry, sin) | ||
{ | ||
float x = 4.f * tier4_autoware_utils::pi / 128.f; | ||
for (int i = 0; i < 128; i++) { | ||
EXPECT_TRUE( | ||
std::abs( | ||
std::sin(x * static_cast<float>(i)) - | ||
tier4_autoware_utils::sin(x * static_cast<float>(i))) < 10e-5); | ||
} | ||
} | ||
|
||
TEST(trigonometry, cos) | ||
{ | ||
float x = 4.f * tier4_autoware_utils::pi / 128.f; | ||
for (int i = 0; i < 128; i++) { | ||
EXPECT_TRUE( | ||
std::abs( | ||
std::cos(x * static_cast<float>(i)) - | ||
tier4_autoware_utils::cos(x * static_cast<float>(i))) < 10e-5); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
...ion/probabilistic_occupancy_grid_map/config/laserscan_based_occupancy_grid_map.param.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/**: | ||
ros__parameters: | ||
map_frame: "map" | ||
base_link_frame: "base_link" | ||
output_frame: "base_link" | ||
# using top of the main lidar frame is appropriate. ex) velodyne_top | ||
|
||
use_height_filter: true | ||
enable_single_frame_mode: false | ||
map_length: 100.0 | ||
map_width: 100.0 | ||
map_resolution: 0.5 | ||
input_obstacle_pointcloud: true | ||
input_obstacle_and_raw_pointcloud: true |
13 changes: 13 additions & 0 deletions
13
...on/probabilistic_occupancy_grid_map/config/pointcloud_based_occupancy_grid_map.param.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/**: | ||
ros__parameters: | ||
map_length: 100 # [m] | ||
map_resolution: 0.5 # [m] | ||
|
||
use_height_filter: true | ||
enable_single_frame_mode: false | ||
|
||
# grid map coordinate | ||
map_frame: "map" | ||
base_link_frame: "base_link" | ||
output_frame: "base_link" | ||
# center of grid_map. Main LiDAR frame is preferable like: "velodyne_top" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.