|
| 1 | +// Copyright 2022 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 | +// NOTE: This file was copied from a part of implementation in |
| 16 | +// https://github.com/autowarefoundation/autoware.universe/blob/main/planning/obstacle_avoidance_planner/include/obstacle_avoidance_planner/node.hpp |
| 17 | + |
| 18 | +#ifndef STATIC_CENTERLINE_OPTIMIZER__COLLISION_FREE_OPTIMIZER_NODE_HPP_ |
| 19 | +#define STATIC_CENTERLINE_OPTIMIZER__COLLISION_FREE_OPTIMIZER_NODE_HPP_ |
| 20 | + |
| 21 | +#include "motion_utils/motion_utils.hpp" |
| 22 | +#include "obstacle_avoidance_planner/common_structs.hpp" |
| 23 | +#include "obstacle_avoidance_planner/costmap_generator.hpp" |
| 24 | +#include "obstacle_avoidance_planner/eb_path_optimizer.hpp" |
| 25 | +#include "obstacle_avoidance_planner/mpt_optimizer.hpp" |
| 26 | +#include "rclcpp/clock.hpp" |
| 27 | +#include "rclcpp/rclcpp.hpp" |
| 28 | +#include "static_centerline_optimizer/type_alias.hpp" |
| 29 | +#include "tier4_autoware_utils/tier4_autoware_utils.hpp" |
| 30 | + |
| 31 | +#include "boost/optional.hpp" |
| 32 | + |
| 33 | +#include <algorithm> |
| 34 | +#include <memory> |
| 35 | +#include <string> |
| 36 | +#include <vector> |
| 37 | + |
| 38 | +namespace static_centerline_optimizer |
| 39 | +{ |
| 40 | +class CollisionFreeOptimizerNode : public rclcpp::Node |
| 41 | +{ |
| 42 | +private: |
| 43 | + rclcpp::Clock logger_ros_clock_; |
| 44 | + int eb_solved_count_; |
| 45 | + bool is_driving_forward_{true}; |
| 46 | + |
| 47 | + bool is_publishing_debug_visualization_marker_; |
| 48 | + bool is_publishing_area_with_objects_; |
| 49 | + bool is_publishing_object_clearance_map_; |
| 50 | + bool is_publishing_clearance_map_; |
| 51 | + bool is_showing_debug_info_; |
| 52 | + bool is_showing_calculation_time_; |
| 53 | + bool is_stopping_if_outside_drivable_area_; |
| 54 | + bool enable_avoidance_; |
| 55 | + bool enable_pre_smoothing_; |
| 56 | + bool skip_optimization_; |
| 57 | + bool reset_prev_optimization_; |
| 58 | + |
| 59 | + // vehicle circles info for for mpt constraints |
| 60 | + std::string vehicle_circle_method_; |
| 61 | + int vehicle_circle_num_for_calculation_; |
| 62 | + std::vector<double> vehicle_circle_radius_ratios_; |
| 63 | + |
| 64 | + // params for replan |
| 65 | + double max_path_shape_change_dist_for_replan_; |
| 66 | + double max_ego_moving_dist_for_replan_; |
| 67 | + double max_delta_time_sec_for_replan_; |
| 68 | + |
| 69 | + // logic |
| 70 | + std::unique_ptr<CostmapGenerator> costmap_generator_ptr_; |
| 71 | + std::unique_ptr<EBPathOptimizer> eb_path_optimizer_ptr_; |
| 72 | + std::unique_ptr<MPTOptimizer> mpt_optimizer_ptr_; |
| 73 | + |
| 74 | + // params |
| 75 | + TrajectoryParam traj_param_; |
| 76 | + EBParam eb_param_; |
| 77 | + VehicleParam vehicle_param_; |
| 78 | + MPTParam mpt_param_; |
| 79 | + int mpt_visualize_sampling_num_; |
| 80 | + |
| 81 | + // debug |
| 82 | + mutable DebugData debug_data_; |
| 83 | + |
| 84 | + geometry_msgs::msg::Pose current_ego_pose_; |
| 85 | + std::unique_ptr<Trajectories> prev_optimal_trajs_ptr_; |
| 86 | + std::unique_ptr<std::vector<PathPoint>> prev_path_points_ptr_; |
| 87 | + |
| 88 | + std::unique_ptr<rclcpp::Time> latest_replanned_time_ptr_; |
| 89 | + |
| 90 | + // ROS |
| 91 | + rclcpp::Subscription<Path>::SharedPtr path_sub_; |
| 92 | + |
| 93 | + // functions |
| 94 | + void resetPlanning(); |
| 95 | + void resetPrevOptimization(); |
| 96 | + |
| 97 | +public: |
| 98 | + explicit CollisionFreeOptimizerNode(const rclcpp::NodeOptions & node_options); |
| 99 | + |
| 100 | + // subscriber callback functions |
| 101 | + Trajectory pathCallback(const Path::ConstSharedPtr); |
| 102 | +}; |
| 103 | +} // namespace static_centerline_optimizer |
| 104 | + |
| 105 | +#endif // STATIC_CENTERLINE_OPTIMIZER__COLLISION_FREE_OPTIMIZER_NODE_HPP_ |
0 commit comments