-
Notifications
You must be signed in to change notification settings - Fork 682
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2fe8167
commit 5d2bc60
Showing
22 changed files
with
616 additions
and
1,125 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
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
2 changes: 1 addition & 1 deletion
2
planning/collision_free_path_planner/include/collision_free_path_planner/debug_marker.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
2 changes: 1 addition & 1 deletion
2
...ing/collision_free_path_planner/include/collision_free_path_planner/eb_path_optimizer.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
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
2 changes: 1 addition & 1 deletion
2
planning/collision_free_path_planner/include/collision_free_path_planner/utils/cv_utils.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
108 changes: 108 additions & 0 deletions
108
.../collision_free_path_planner/include/collision_free_path_planner/utils/geometry_utils.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,108 @@ | ||
// Copyright 2022 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 COLLISION_FREE_PATH_PLANNER__UTILS__GEOMETRY_UTILS_HPP_ | ||
#define COLLISION_FREE_PATH_PLANNER__UTILS__GEOMETRY_UTILS_HPP_ | ||
|
||
#include "collision_free_path_planner/common_structs.hpp" | ||
#include "collision_free_path_planner/type_alias.hpp" | ||
#include "eigen3/Eigen/Core" | ||
#include "interpolation/linear_interpolation.hpp" | ||
#include "interpolation/spline_interpolation.hpp" | ||
#include "interpolation/spline_interpolation_points_2d.hpp" | ||
#include "motion_utils/trajectory/trajectory.hpp" | ||
|
||
#include "autoware_auto_planning_msgs/msg/path_point.hpp" | ||
#include "autoware_auto_planning_msgs/msg/trajectory.hpp" | ||
|
||
#include "boost/optional/optional_fwd.hpp" | ||
|
||
#include <algorithm> | ||
#include <limits> | ||
#include <memory> | ||
#include <string> | ||
#include <vector> | ||
|
||
struct collision_free_path_planner::ReferencePoint; | ||
|
||
namespace tier4_autoware_utils | ||
{ | ||
template <> | ||
geometry_msgs::msg::Point getPoint(const collision_free_path_planner::ReferencePoint & p); | ||
|
||
template <> | ||
geometry_msgs::msg::Pose getPose(const collision_free_path_planner::ReferencePoint & p); | ||
} // namespace tier4_autoware_utils | ||
|
||
namespace collision_free_path_planner | ||
{ | ||
namespace geometry_utils | ||
{ | ||
template <typename T> | ||
geometry_msgs::msg::Point transformToRelativeCoordinate2D( | ||
const T & point, const geometry_msgs::msg::Pose & origin) | ||
{ | ||
// NOTE: implement transformation without defining yaw variable | ||
// but directly sin/cos of yaw for fast calculation | ||
const auto & q = origin.orientation; | ||
const double cos_yaw = 1 - 2 * q.z * q.z; | ||
const double sin_yaw = 2 * q.w * q.z; | ||
|
||
geometry_msgs::msg::Point relative_p; | ||
const double tmp_x = point.x - origin.position.x; | ||
const double tmp_y = point.y - origin.position.y; | ||
relative_p.x = tmp_x * cos_yaw + tmp_y * sin_yaw; | ||
relative_p.y = -tmp_x * sin_yaw + tmp_y * cos_yaw; | ||
relative_p.z = point.z; | ||
|
||
return relative_p; | ||
} | ||
|
||
geometry_msgs::msg::Point transformToAbsoluteCoordinate2D( | ||
const geometry_msgs::msg::Point & point, const geometry_msgs::msg::Pose & origin); | ||
|
||
geometry_msgs::msg::Quaternion getQuaternionFromPoints( | ||
const geometry_msgs::msg::Point & a, const geometry_msgs::msg::Point & a_root); | ||
|
||
geometry_msgs::msg::Quaternion getQuaternionFromPoints( | ||
const geometry_msgs::msg::Point & p1, const geometry_msgs::msg::Point & p2, | ||
const geometry_msgs::msg::Point & p3, const geometry_msgs::msg::Point & p4); | ||
|
||
template <typename T> | ||
geometry_msgs::msg::Point transformMapToImage( | ||
const T & map_point, const nav_msgs::msg::MapMetaData & occupancy_grid_info) | ||
{ | ||
geometry_msgs::msg::Point relative_p = | ||
transformToRelativeCoordinate2D(map_point, occupancy_grid_info.origin); | ||
double resolution = occupancy_grid_info.resolution; | ||
double map_y_height = occupancy_grid_info.height; | ||
double map_x_width = occupancy_grid_info.width; | ||
double map_x_in_image_resolution = relative_p.x / resolution; | ||
double map_y_in_image_resolution = relative_p.y / resolution; | ||
geometry_msgs::msg::Point image_point; | ||
image_point.x = map_y_height - map_y_in_image_resolution; | ||
image_point.y = map_x_width - map_x_in_image_resolution; | ||
return image_point; | ||
} | ||
|
||
boost::optional<geometry_msgs::msg::Point> transformMapToOptionalImage( | ||
const geometry_msgs::msg::Point & map_point, | ||
const nav_msgs::msg::MapMetaData & occupancy_grid_info); | ||
|
||
bool transformMapToImage( | ||
const geometry_msgs::msg::Point & map_point, | ||
const nav_msgs::msg::MapMetaData & occupancy_grid_info, geometry_msgs::msg::Point & image_point); | ||
} // namespace geometry_utils | ||
} // namespace collision_free_path_planner | ||
#endif // COLLISION_FREE_PATH_PLANNER__UTILS__GEOMETRY_UTILS_HPP_ |
Oops, something went wrong.