|
| 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 | +#ifndef AWAPI_AWIV_ADAPTER__AWAPI_VELOCITY_FACTOR_CONVERTER_HPP_ |
| 16 | +#define AWAPI_AWIV_ADAPTER__AWAPI_VELOCITY_FACTOR_CONVERTER_HPP_ |
| 17 | + |
| 18 | +#include "awapi_awiv_adapter/awapi_autoware_util.hpp" |
| 19 | + |
| 20 | +#include <rclcpp/rclcpp.hpp> |
| 21 | + |
| 22 | +#include <autoware_adapi_v1_msgs/msg/planning_behavior.hpp> |
| 23 | +#include <autoware_adapi_v1_msgs/msg/velocity_factor.hpp> |
| 24 | +#include <autoware_adapi_v1_msgs/msg/velocity_factor_array.hpp> |
| 25 | + |
| 26 | +#include <map> |
| 27 | +#include <string> |
| 28 | +#include <vector> |
| 29 | + |
| 30 | +namespace autoware_api |
| 31 | +{ |
| 32 | + |
| 33 | +using autoware_adapi_v1_msgs::msg::PlanningBehavior; |
| 34 | +using tier4_planning_msgs::msg::StopReason; |
| 35 | + |
| 36 | +const std::map<std::string, std::string> conversion_map = { |
| 37 | + {PlanningBehavior::AVOIDANCE, StopReason::AVOIDANCE}, |
| 38 | + {PlanningBehavior::CROSSWALK, StopReason::CROSSWALK}, |
| 39 | + {PlanningBehavior::GOAL_PLANNER, StopReason::GOAL_PLANNER}, |
| 40 | + {PlanningBehavior::INTERSECTION, StopReason::INTERSECTION}, |
| 41 | + {PlanningBehavior::LANE_CHANGE, StopReason::LANE_CHANGE}, |
| 42 | + {PlanningBehavior::MERGE, StopReason::MERGE_FROM_PRIVATE_ROAD}, |
| 43 | + {PlanningBehavior::NO_DRIVABLE_LANE, StopReason::NO_DRIVABLE_LANE}, |
| 44 | + {PlanningBehavior::NO_STOPPING_AREA, StopReason::NO_STOPPING_AREA}, |
| 45 | + {PlanningBehavior::REAR_CHECK, StopReason::BLIND_SPOT}, |
| 46 | + {PlanningBehavior::ROUTE_OBSTACLE, StopReason::OBSTACLE_STOP}, |
| 47 | + {PlanningBehavior::SIDEWALK, StopReason::WALKWAY}, |
| 48 | + {PlanningBehavior::START_PLANNER, StopReason::START_PLANNER}, |
| 49 | + {PlanningBehavior::STOP_SIGN, StopReason::STOP_LINE}, |
| 50 | + {PlanningBehavior::SURROUNDING_OBSTACLE, StopReason::SURROUND_OBSTACLE_CHECK}, |
| 51 | + {PlanningBehavior::TRAFFIC_SIGNAL, StopReason::TRAFFIC_LIGHT}, |
| 52 | + {PlanningBehavior::USER_DEFINED_DETECTION_AREA, StopReason::DETECTION_AREA}, |
| 53 | + {PlanningBehavior::VIRTUAL_TRAFFIC_LIGHT, StopReason::VIRTUAL_TRAFFIC_LIGHT}, |
| 54 | + {PlanningBehavior::RUN_OUT, StopReason::OBSTACLE_STOP}, |
| 55 | + {PlanningBehavior::ADAPTIVE_CRUISE, "AdaptiveCruise"}}; |
| 56 | + |
| 57 | +class AutowareIvVelocityFactorConverter |
| 58 | +{ |
| 59 | +public: |
| 60 | + AutowareIvVelocityFactorConverter(rclcpp::Node & node, const double thresh_dist_to_stop_pose); |
| 61 | + |
| 62 | + tier4_planning_msgs::msg::StopReasonArray::ConstSharedPtr updateStopReasonArray( |
| 63 | + const autoware_adapi_v1_msgs::msg::VelocityFactorArray::ConstSharedPtr & msg_ptr); |
| 64 | + |
| 65 | +private: |
| 66 | + tier4_planning_msgs::msg::StopReasonArray::ConstSharedPtr convert( |
| 67 | + const autoware_adapi_v1_msgs::msg::VelocityFactorArray::ConstSharedPtr & msg_ptr); |
| 68 | + |
| 69 | + tier4_planning_msgs::msg::StopFactor convert( |
| 70 | + const autoware_adapi_v1_msgs::msg::VelocityFactor & factor); |
| 71 | + |
| 72 | + rclcpp::Logger logger_; |
| 73 | + |
| 74 | + rclcpp::Clock::SharedPtr clock_; |
| 75 | + |
| 76 | + double thresh_dist_to_stop_pose_; |
| 77 | +}; |
| 78 | + |
| 79 | +} // namespace autoware_api |
| 80 | + |
| 81 | +#endif // AWAPI_AWIV_ADAPTER__AWAPI_VELOCITY_FACTOR_CONVERTER_HPP_ |
0 commit comments