-
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.
Skip computation if prepare length exceed distance to terminal start
Signed-off-by: Zulfaqar Azmi <zulfaqar.azmi@tier4.jp>
- Loading branch information
1 parent
e0e8a56
commit e82dcc9
Showing
4 changed files
with
104 additions
and
1 deletion.
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
45 changes: 45 additions & 0 deletions
45
...ane_change_module/include/autoware/behavior_path_lane_change_module/utils/calculation.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,45 @@ | ||
// 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 AUTOWARE__BEHAVIOR_PATH_LANE_CHANGE_MODULE__UTILS__CALCULATION_HPP_ | ||
#define AUTOWARE__BEHAVIOR_PATH_LANE_CHANGE_MODULE__UTILS__CALCULATION_HPP_ | ||
|
||
#include "autoware/behavior_path_lane_change_module/utils/data_structs.hpp" | ||
|
||
namespace autoware::behavior_path_planner::utils::lane_change::calculation | ||
{ | ||
using behavior_path_planner::lane_change::CommonDataPtr; | ||
|
||
/** | ||
* @brief Calculates the distance from the ego vehicle to the terminal point. | ||
* | ||
* This function computes the distance from the current position of the ego vehicle | ||
* to either the goal pose or the end of the current lane, depending on whether | ||
* the vehicle's current lane is within the goal section. | ||
* | ||
* @param common_data_ptr Shared pointer to a CommonData structure, which should include: | ||
* - Non null `lanes_ptr` that points to the current lanes data. | ||
* - Non null `self_odometry_ptr` that contains the current pose of the ego vehicle. | ||
* - Non null `route_handler_ptr` that contains the goal pose of the route. | ||
* | ||
* @return The distance to the terminal point (either the goal pose or the end of the current lane) | ||
* in meters. | ||
*/ | ||
double calc_ego_dist_to_terminal_end(const CommonDataPtr & common_data_ptr); | ||
|
||
double calc_dist_from_pose_to_terminal_end( | ||
const CommonDataPtr & common_data_ptr, const lanelet::ConstLanelets & lanes, | ||
const Pose & src_pose); | ||
} // namespace autoware::behavior_path_planner::utils::lane_change::calculation | ||
|
||
#endif // AUTOWARE__BEHAVIOR_PATH_LANE_CHANGE_MODULE__UTILS__CALCULATION_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
45 changes: 45 additions & 0 deletions
45
...behavior_path_planner/autoware_behavior_path_lane_change_module/src/utils/calculation.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,45 @@ | ||
// 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 <autoware/behavior_path_lane_change_module/utils/calculation.hpp> | ||
#include <autoware/behavior_path_planner_common/utils/utils.hpp> | ||
|
||
namespace autoware::behavior_path_planner::utils::lane_change::calculation | ||
{ | ||
double calc_ego_dist_to_terminal_end(const CommonDataPtr & common_data_ptr) | ||
{ | ||
const auto & lanes_ptr = common_data_ptr->lanes_ptr; | ||
const auto & current_lanes = lanes_ptr->current; | ||
const auto & current_pose = common_data_ptr->get_ego_pose(); | ||
|
||
return calc_dist_from_pose_to_terminal_end(common_data_ptr, current_lanes, current_pose); | ||
} | ||
|
||
double calc_dist_from_pose_to_terminal_end( | ||
const CommonDataPtr & common_data_ptr, const lanelet::ConstLanelets & lanes, | ||
const Pose & src_pose) | ||
{ | ||
if (lanes.empty()) { | ||
return 0.0; | ||
} | ||
|
||
const auto & lanes_ptr = common_data_ptr->lanes_ptr; | ||
const auto & goal_pose = common_data_ptr->route_handler_ptr->getGoalPose(); | ||
|
||
if (lanes_ptr->current_lane_in_goal_section) { | ||
return utils::getSignedDistance(src_pose, goal_pose, lanes); | ||
} | ||
return utils::getDistanceToEndOfLane(src_pose, lanes); | ||
} | ||
} // namespace autoware::behavior_path_planner::utils::lane_change::calculation |