48 auto latest_object_pair = track_data->GetLatestObject();
52 double time_diff = new_object->object_ptr->latest_tracked_time -
53 latest_object->object_ptr->latest_tracked_time;
54 Eigen::Vector3d filter_velocity_gain = new_object->belief_velocity_gain;
55 double filter_acceleration_gain = 0.0;
57 filter_acceleration_gain = 0.0;
59 filter_acceleration_gain = filter_velocity_gain.norm() / time_diff;
61 bool need_keep_motion =
66 need_keep_motion =
true;
69 if (need_keep_motion && (!new_object->converged)) {
70 Eigen::Vector3d current_velocity = Eigen::Vector3d::Zero();
71 current_velocity = latest_object->output_velocity;
72 new_object->output_velocity = current_velocity;
77 AINFO <<
"[Velocity-Refine] track_id: " << track_data->track_id_
78 <<
" KEEP MOTION because of extraodinary acceleration.";
82 bool is_static_hypothesis =
85 if (is_static_hypothesis) {
86 new_object->output_velocity = Eigen::Vector3d::Zero();
87 new_object->state.tail<2>().setZero();
88 AINFO <<
"[Velocity-Refine] track_id: " << track_data->track_id_
89 <<
" set velocity to zero because of static_hypothesis.";
101 double speed = new_object->output_velocity.head(2).norm();
104 bool velocity_noise_level_0 =
false;
105 bool velocity_noise_level_1 =
false;
106 bool velocity_noise_level_2 =
false;
107 auto type_select = new_object->type;
125 if (velocity_noise_level_0) {
126 ADEBUG <<
"type: " <<
static_cast<size_t>(type_select)
127 <<
" speed is " << speed <<
" so small";
131 double velocity_change_angle = M_PI, velocity_heading_angle = M_PI;
133 &velocity_change_angle, &velocity_heading_angle)) {
134 ADEBUG <<
" velocity_change_angle: " << velocity_change_angle
135 <<
" velocity_heading_angle: " << velocity_heading_angle;
140 bool dir_change_level_0 = (fabs(velocity_change_angle) > M_PI / 6 ||
141 fabs(velocity_heading_angle) > M_PI / 6);
142 if (velocity_noise_level_1 && dir_change_level_0) {
143 ADEBUG <<
"type: " <<
static_cast<size_t>(type_select) <<
" speed is "
144 << speed <<
" velocity_change is " << velocity_change_angle
145 <<
" velocity_heading is " << velocity_heading_angle
146 <<
" bigger than PI/6";
152 bool dir_change_level_1 = (fabs(velocity_change_angle) > M_PI / 4 ||
153 fabs(velocity_heading_angle) > M_PI / 4);
154 if (velocity_noise_level_2 && dir_change_level_1) {
155 ADEBUG <<
"type: " <<
static_cast<size_t>(type_select) <<
" speed is "
156 << speed <<
" velocity_change is " << velocity_change_angle
157 <<
" velocity_heading is " << velocity_heading_angle
158 <<
" bigger than PI/4";
167 double* vel_change_angle,
168 double* velocity_heading_angle)
const {
169 Eigen::Vector3d pre_velocity = latest_object->output_velocity;
170 Eigen::Vector3d cur_velocity = new_object->output_velocity;
171 Eigen::Vector3d pre_direction = latest_object->output_direction;
172 constexpr double kEpsilon = std::numeric_limits<double>::epsilon();
174 if (pre_velocity.norm() < kEpsilon || cur_velocity.norm() < kEpsilon) {
177 *vel_change_angle = algorithm::CalculateTheta2DXY<double>(
178 pre_velocity, cur_velocity);
180 double velocity_heading_angle_1 = algorithm::CalculateTheta2DXY<double>(
181 pre_direction, cur_velocity);
183 double velocity_heading_angle_2 = algorithm::CalculateTheta2DXY<double>(
184 pre_direction, cur_velocity);
185 *velocity_heading_angle = std::min(fabs(velocity_heading_angle_1),
186 fabs(velocity_heading_angle_2));
193 double reasonable_angle_change_maximum)
const {
197 Eigen::Vector3d previous_velocity = latest_object->output_velocity;
198 Eigen::Vector3d current_velocity = new_object->output_velocity;
199 constexpr double kEpsilon = std::numeric_limits<double>::epsilon();
200 if (previous_velocity.norm() < kEpsilon) {
204 if (current_velocity.norm() < kEpsilon) {
209 double velocity_angle_change =
211 if (fabs(velocity_angle_change) > reasonable_angle_change_maximum) {
217 Eigen::Vector3d previous_direction = latest_object->output_direction;
218 double velocity_heading_angle_change_1 =
220 previous_direction *= -1;
221 double velocity_heading_angle_change_2 =
222 algorithm::CalculateTheta2DXY<double>(
223 previous_direction, current_velocity);
224 velocity_angle_change = std::min(fabs(velocity_heading_angle_change_1),
225 fabs(velocity_heading_angle_change_2));
226 if (fabs(velocity_angle_change) > reasonable_angle_change_maximum) {
bool GetProtoFromFile(const std::string &file_name, google::protobuf::Message *message)
Parses the content of the file specified by the file_name as a representation of protobufs,...