-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(behavior_tree_plugin) Fix isssue with pedestrian turning
- Loading branch information
1 parent
0aae035
commit a213185
Showing
4 changed files
with
135 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright 2015 TIER IV, Inc. All rights reserved. | ||
// | ||
// 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 GEOMETRY__QUATERNION__NORM_HPP_ | ||
#define GEOMETRY__QUATERNION__NORM_HPP_ | ||
|
||
#include <cmath> | ||
#include <geometry/quaternion/is_like_quaternion.hpp> | ||
|
||
namespace math | ||
{ | ||
namespace geometry | ||
{ | ||
template <typename T, std::enable_if_t<IsLikeQuaternion<T>::value, std::nullptr_t> = nullptr> | ||
auto norm(const T & q) | ||
{ | ||
return std::hypot(std::hypot(q.w, q.x), std::hypot(q.y, q.z)); | ||
} | ||
} // namespace geometry | ||
} // namespace math | ||
|
||
#endif // GEOMETRY__QUATERNION__NORM_HPP_ |
43 changes: 43 additions & 0 deletions
43
common/math/geometry/include/geometry/quaternion/normalize.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,43 @@ | ||
// Copyright 2015 TIER IV, Inc. All rights reserved. | ||
// | ||
// 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 GEOMETRY__QUATERNION__NORMALIZE_HPP_ | ||
#define GEOMETRY__QUATERNION__NORMALIZE_HPP_ | ||
|
||
#include <geometry/quaternion/is_like_quaternion.hpp> | ||
#include <geometry/quaternion/norm.hpp> | ||
#include <geometry/quaternion/operator.hpp> | ||
#include <scenario_simulator_exception/exception.hpp> | ||
|
||
namespace math | ||
{ | ||
namespace geometry | ||
{ | ||
template <typename T, std::enable_if_t<IsLikeQuaternion<T>::value, std::nullptr_t> = nullptr> | ||
auto normalize(const T & q) | ||
{ | ||
const auto n = norm(q); | ||
if (std::fabs(n) <= std::numeric_limits<double>::epsilon()) { | ||
THROW_SIMULATION_ERROR( | ||
"Norm of quaternion (", q.w, ",", q.x, ",", q.y, ",", q.z, ") is ", n, | ||
". The norm of the quaternion you want to normalize should be greater than ", | ||
std::numeric_limits<double>::epsilon()); | ||
} | ||
return geometry_msgs::build<geometry_msgs::msg::Quaternion>().x(q.x / n).y(q.y / n).z(q.z / n).w( | ||
q.w / n); | ||
} | ||
} // namespace geometry | ||
} // namespace math | ||
|
||
#endif // GEOMETRY__QUATERNION__NORMALIZE_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
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