|
| 1 | +// Copyright 2020 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 RADAR_OBJECT_TRACKER__TRACKER__MODEL__CONSTANT_TURN_RATE_MOTION_TRACKER_HPP_ |
| 16 | +#define RADAR_OBJECT_TRACKER__TRACKER__MODEL__CONSTANT_TURN_RATE_MOTION_TRACKER_HPP_ |
| 17 | + |
| 18 | +#include "radar_object_tracker/tracker/model/tracker_base.hpp" |
| 19 | + |
| 20 | +#include <kalman_filter/kalman_filter.hpp> |
| 21 | + |
| 22 | +#include <string> |
| 23 | + |
| 24 | +using Label = autoware_auto_perception_msgs::msg::ObjectClassification; |
| 25 | +class ConstantTurnRateMotionTracker : public Tracker // means constant turn rate motion tracker |
| 26 | +{ |
| 27 | +private: |
| 28 | + autoware_auto_perception_msgs::msg::DetectedObject object_; |
| 29 | + rclcpp::Logger logger_; |
| 30 | + |
| 31 | +private: |
| 32 | + KalmanFilter ekf_; |
| 33 | + rclcpp::Time last_update_time_; |
| 34 | + enum IDX { X = 0, Y = 1, YAW = 2, VX = 3, WZ = 4 }; |
| 35 | + |
| 36 | + struct EkfParams |
| 37 | + { |
| 38 | + // dimension |
| 39 | + char dim_x = 5; |
| 40 | + // system noise |
| 41 | + double q_cov_x; |
| 42 | + double q_cov_y; |
| 43 | + double q_cov_yaw; |
| 44 | + double q_cov_vx; |
| 45 | + double q_cov_wz; |
| 46 | + // measurement noise |
| 47 | + double r_cov_x; |
| 48 | + double r_cov_y; |
| 49 | + double r_cov_yaw; |
| 50 | + double r_cov_vx; |
| 51 | + // initial state covariance |
| 52 | + double p0_cov_x; |
| 53 | + double p0_cov_y; |
| 54 | + double p0_cov_yaw; |
| 55 | + double p0_cov_vx; |
| 56 | + double p0_cov_wz; |
| 57 | + }; |
| 58 | + static EkfParams ekf_params_; |
| 59 | + |
| 60 | + // limitation |
| 61 | + static double max_vx_; |
| 62 | + // rough tracking parameters |
| 63 | + float z_; |
| 64 | + |
| 65 | + // lpf parameter |
| 66 | + static double filter_tau_; // time constant of 1st order low pass filter |
| 67 | + static double filter_dt_; // sampling time of 1st order low pass filter |
| 68 | + |
| 69 | + // static flags |
| 70 | + static bool is_initialized_; |
| 71 | + static bool trust_yaw_input_; |
| 72 | + static bool trust_twist_input_; |
| 73 | + static bool use_polar_coordinate_in_measurement_noise_; |
| 74 | + static bool assume_zero_yaw_rate_; |
| 75 | + |
| 76 | +private: |
| 77 | + struct BoundingBox |
| 78 | + { |
| 79 | + double length; |
| 80 | + double width; |
| 81 | + double height; |
| 82 | + }; |
| 83 | + struct Cylinder |
| 84 | + { |
| 85 | + double width; |
| 86 | + double height; |
| 87 | + }; |
| 88 | + BoundingBox bounding_box_; |
| 89 | + Cylinder cylinder_; |
| 90 | + |
| 91 | +public: |
| 92 | + ConstantTurnRateMotionTracker( |
| 93 | + const rclcpp::Time & time, const autoware_auto_perception_msgs::msg::DetectedObject & object, |
| 94 | + const std::string & tracker_param_file, const std::uint8_t & label); |
| 95 | + |
| 96 | + static void loadDefaultModelParameters(const std::string & path); |
| 97 | + bool predict(const rclcpp::Time & time) override; |
| 98 | + bool predict(const double dt, KalmanFilter & ekf) const; |
| 99 | + bool measure( |
| 100 | + const autoware_auto_perception_msgs::msg::DetectedObject & object, const rclcpp::Time & time, |
| 101 | + const geometry_msgs::msg::Transform & self_transform) override; |
| 102 | + bool measureWithPose( |
| 103 | + const autoware_auto_perception_msgs::msg::DetectedObject & object, |
| 104 | + const geometry_msgs::msg::Transform & self_transform); |
| 105 | + bool measureWithShape(const autoware_auto_perception_msgs::msg::DetectedObject & object); |
| 106 | + bool getTrackedObject( |
| 107 | + const rclcpp::Time & time, |
| 108 | + autoware_auto_perception_msgs::msg::TrackedObject & object) const override; |
| 109 | + virtual ~ConstantTurnRateMotionTracker() {} |
| 110 | +}; |
| 111 | + |
| 112 | +#endif // RADAR_OBJECT_TRACKER__TRACKER__MODEL__CONSTANT_TURN_RATE_MOTION_TRACKER_HPP_ |
0 commit comments