|
| 1 | +// Copyright 2023 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 "behavior_path_avoidance_by_lane_change_module/interface.hpp" |
| 16 | + |
| 17 | +#include "behavior_path_planner_common/interface/scene_module_interface.hpp" |
| 18 | +#include "behavior_path_planner_common/interface/scene_module_visitor.hpp" |
| 19 | +#include "behavior_path_planner_common/marker_utils/utils.hpp" |
| 20 | + |
| 21 | +#include <algorithm> |
| 22 | +#include <memory> |
| 23 | +#include <string> |
| 24 | +#include <utility> |
| 25 | +#include <vector> |
| 26 | + |
| 27 | +namespace behavior_path_planner |
| 28 | +{ |
| 29 | +AvoidanceByLaneChangeInterface::AvoidanceByLaneChangeInterface( |
| 30 | + const std::string & name, rclcpp::Node & node, |
| 31 | + const std::shared_ptr<LaneChangeParameters> & parameters, |
| 32 | + const std::shared_ptr<AvoidanceByLCParameters> & avoidance_by_lane_change_parameters, |
| 33 | + const std::unordered_map<std::string, std::shared_ptr<RTCInterface>> & rtc_interface_ptr_map, |
| 34 | + std::unordered_map<std::string, std::shared_ptr<ObjectsOfInterestMarkerInterface>> & |
| 35 | + objects_of_interest_marker_interface_ptr_map) |
| 36 | +: LaneChangeInterface{ |
| 37 | + name, |
| 38 | + node, |
| 39 | + parameters, |
| 40 | + rtc_interface_ptr_map, |
| 41 | + objects_of_interest_marker_interface_ptr_map, |
| 42 | + std::make_unique<AvoidanceByLaneChange>(parameters, avoidance_by_lane_change_parameters)} |
| 43 | +{ |
| 44 | +} |
| 45 | + |
| 46 | +bool AvoidanceByLaneChangeInterface::isExecutionRequested() const |
| 47 | +{ |
| 48 | + return module_type_->specialRequiredCheck() && module_type_->isLaneChangeRequired(); |
| 49 | +} |
| 50 | + |
| 51 | +void AvoidanceByLaneChangeInterface::updateRTCStatus( |
| 52 | + const double start_distance, const double finish_distance) |
| 53 | +{ |
| 54 | + const auto direction = std::invoke([&]() -> std::string { |
| 55 | + const auto dir = module_type_->getDirection(); |
| 56 | + return (dir == Direction::LEFT) ? "left" : "right"; |
| 57 | + }); |
| 58 | + |
| 59 | + rtc_interface_ptr_map_.at(direction)->updateCooperateStatus( |
| 60 | + uuid_map_.at(direction), isExecutionReady(), start_distance, finish_distance, clock_->now()); |
| 61 | +} |
| 62 | +} // namespace behavior_path_planner |
0 commit comments