|
| 1 | +// Copyright 2024 Tier IV, Inc. |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +#include "scene.hpp" |
| 16 | + |
| 17 | +#include <motion_utils/trajectory/trajectory.hpp> |
| 18 | + |
| 19 | +namespace behavior_velocity_planner |
| 20 | +{ |
| 21 | + |
| 22 | +/* |
| 23 | + * for default |
| 24 | + */ |
| 25 | +template <typename T> |
| 26 | +void BlindSpotModule::setRTCStatusByDecision( |
| 27 | + const T &, const autoware_auto_planning_msgs::msg::PathWithLaneId & path) |
| 28 | +{ |
| 29 | + static_assert("Unsupported type passed to setRTCStatus"); |
| 30 | + return; |
| 31 | +} |
| 32 | + |
| 33 | +template <typename T> |
| 34 | +void BlindSpotModule::reactRTCApprovalByDecision( |
| 35 | + [[maybe_unused]] const T & decision, |
| 36 | + [[maybe_unused]] autoware_auto_planning_msgs::msg::PathWithLaneId * path, |
| 37 | + [[maybe_unused]] StopReason * stop_reason) |
| 38 | +{ |
| 39 | + static_assert("Unsupported type passed to reactRTCApprovalByDecision"); |
| 40 | +} |
| 41 | + |
| 42 | +/* |
| 43 | + * for InternalError |
| 44 | + */ |
| 45 | +template <> |
| 46 | +void BlindSpotModule::setRTCStatusByDecision( |
| 47 | + [[maybe_unused]] const InternalError & decision, |
| 48 | + [[maybe_unused]] const autoware_auto_planning_msgs::msg::PathWithLaneId & path) |
| 49 | +{ |
| 50 | + return; |
| 51 | +} |
| 52 | + |
| 53 | +template <> |
| 54 | +void BlindSpotModule::reactRTCApprovalByDecision( |
| 55 | + [[maybe_unused]] const InternalError & decision, |
| 56 | + [[maybe_unused]] autoware_auto_planning_msgs::msg::PathWithLaneId * path, |
| 57 | + [[maybe_unused]] StopReason * stop_reason) |
| 58 | +{ |
| 59 | + return; |
| 60 | +} |
| 61 | + |
| 62 | +/* |
| 63 | + * For OverPassJudge |
| 64 | + */ |
| 65 | +template <> |
| 66 | +void BlindSpotModule::setRTCStatusByDecision( |
| 67 | + [[maybe_unused]] const OverPassJudge & decision, |
| 68 | + [[maybe_unused]] const autoware_auto_planning_msgs::msg::PathWithLaneId & path) |
| 69 | +{ |
| 70 | + return; |
| 71 | +} |
| 72 | + |
| 73 | +template <> |
| 74 | +void BlindSpotModule::reactRTCApprovalByDecision( |
| 75 | + [[maybe_unused]] const OverPassJudge & decision, |
| 76 | + [[maybe_unused]] autoware_auto_planning_msgs::msg::PathWithLaneId * path, |
| 77 | + [[maybe_unused]] StopReason * stop_reason) |
| 78 | +{ |
| 79 | + return; |
| 80 | +} |
| 81 | + |
| 82 | +/* |
| 83 | + * for Unsafe |
| 84 | + */ |
| 85 | +template <> |
| 86 | +void BlindSpotModule::setRTCStatusByDecision( |
| 87 | + const Unsafe & decision, const autoware_auto_planning_msgs::msg::PathWithLaneId & path) |
| 88 | +{ |
| 89 | + setSafe(false); |
| 90 | + const auto & current_pose = planner_data_->current_odometry->pose; |
| 91 | + setDistance( |
| 92 | + motion_utils::calcSignedArcLength(path.points, current_pose.position, decision.stop_line_idx)); |
| 93 | + return; |
| 94 | +} |
| 95 | + |
| 96 | +template <> |
| 97 | +void BlindSpotModule::reactRTCApprovalByDecision( |
| 98 | + const Unsafe & decision, autoware_auto_planning_msgs::msg::PathWithLaneId * path, |
| 99 | + StopReason * stop_reason) |
| 100 | +{ |
| 101 | + if (!isActivated()) { |
| 102 | + constexpr double stop_vel = 0.0; |
| 103 | + planning_utils::setVelocityFromIndex(decision.stop_line_idx, stop_vel, path); |
| 104 | + debug_data_.virtual_wall_pose = planning_utils::getAheadPose( |
| 105 | + decision.stop_line_idx, planner_data_->vehicle_info_.max_longitudinal_offset_m, *path); |
| 106 | + |
| 107 | + tier4_planning_msgs::msg::StopFactor stop_factor; |
| 108 | + const auto stop_pose = path->points.at(decision.stop_line_idx).point.pose; |
| 109 | + stop_factor.stop_pose = stop_pose; |
| 110 | + stop_factor.stop_factor_points = planning_utils::toRosPoints(debug_data_.conflicting_targets); |
| 111 | + planning_utils::appendStopReason(stop_factor, stop_reason); |
| 112 | + velocity_factor_.set( |
| 113 | + path->points, planner_data_->current_odometry->pose, stop_pose, VelocityFactor::UNKNOWN); |
| 114 | + } |
| 115 | + return; |
| 116 | +} |
| 117 | + |
| 118 | +/* |
| 119 | + * for Safe |
| 120 | + */ |
| 121 | +template <> |
| 122 | +void BlindSpotModule::setRTCStatusByDecision( |
| 123 | + const Safe & decision, const autoware_auto_planning_msgs::msg::PathWithLaneId & path) |
| 124 | +{ |
| 125 | + setSafe(true); |
| 126 | + const auto & current_pose = planner_data_->current_odometry->pose; |
| 127 | + setDistance( |
| 128 | + motion_utils::calcSignedArcLength(path.points, current_pose.position, decision.stop_line_idx)); |
| 129 | + return; |
| 130 | +} |
| 131 | + |
| 132 | +template <> |
| 133 | +void BlindSpotModule::reactRTCApprovalByDecision( |
| 134 | + const Safe & decision, autoware_auto_planning_msgs::msg::PathWithLaneId * path, |
| 135 | + StopReason * stop_reason) |
| 136 | +{ |
| 137 | + if (!isActivated()) { |
| 138 | + constexpr double stop_vel = 0.0; |
| 139 | + planning_utils::setVelocityFromIndex(decision.stop_line_idx, stop_vel, path); |
| 140 | + debug_data_.virtual_wall_pose = planning_utils::getAheadPose( |
| 141 | + decision.stop_line_idx, planner_data_->vehicle_info_.max_longitudinal_offset_m, *path); |
| 142 | + |
| 143 | + tier4_planning_msgs::msg::StopFactor stop_factor; |
| 144 | + const auto stop_pose = path->points.at(decision.stop_line_idx).point.pose; |
| 145 | + stop_factor.stop_pose = stop_pose; |
| 146 | + stop_factor.stop_factor_points = planning_utils::toRosPoints(debug_data_.conflicting_targets); |
| 147 | + planning_utils::appendStopReason(stop_factor, stop_reason); |
| 148 | + velocity_factor_.set( |
| 149 | + path->points, planner_data_->current_odometry->pose, stop_pose, VelocityFactor::UNKNOWN); |
| 150 | + } |
| 151 | + return; |
| 152 | +} |
| 153 | + |
| 154 | +} // namespace behavior_velocity_planner |
0 commit comments