161 {
164
165 Eigen::Vector2d z;
166 z << std::sin(object->theta), std::cos(object->theta);
169 float theta = static_cast<float>(std::atan2(z[0], z[1]));
170 AINFO <<
"dir " <<
id <<
" " <<
object->theta <<
" " << theta;
171 object->theta = theta;
172 object->direction[0] =
static_cast<float>(
cos(object->theta));
173 object->direction[1] =
static_cast<float>(
sin(object->theta));
174 object->direction[2] = 0;
175
176 z << object->center(0), object->center(1);
179 } else {
180
181 float obj_2_car_x = object->camera_supplement.local_center[0];
182 float obj_2_car_z = object->camera_supplement.local_center[2];
183 float obj_distance_to_main_car =
184 obj_2_car_x * obj_2_car_x + obj_2_car_z * obj_2_car_z;
186 obj_distance_to_main_car;
190 ADEBUG <<
"Velocity: " <<
id <<
" " << z.transpose() <<
" "
192
193
196 KalmanFilterConstState<2>::VectorNd pos_measure;
197 pos_measure << object->center(0), object->center(1);
199 }
200 }
201
205 object->center(0) = x(0);
206 object->center(1) = x(1);
207 object->center_uncertainty(0) = static_cast<float>(var(0));
208 object->center_uncertainty(1) = static_cast<float>(var(1));
209 object->velocity(0) = 0;
210 object->velocity(1) = 0;
211 object->velocity(2) = 0;
212 } else {
214
220 Eigen::Vector3d vel = (pose1 - pose2) / (ts1 - ts2);
221 double speed1 = std::sqrt(vel(0) * vel(0) + vel(1) * vel(1));
222 double speed2 = std::sqrt(x(2) * x(2) + x(3) * x(3));
223 double ratio = (
Equal(speed1, 0)) ? 0 : speed2 / speed1;
224 ADEBUG <<
"Target: " <<
id <<
" " << vel.transpose() <<
" , "
225 << x.block<2, 1>(2, 0).transpose();
228 ADEBUG <<
"Velocity too large";
230 vel(0) = (x(2) + vel(0)) / 2;
231 vel(1) = (x(3) + vel(1)) / 2;
233 ADEBUG <<
"Velocity large";
234 } else {
235 ADEBUG <<
"Velocity normal";
236 }
237 }
238
240 double speed = std::sqrt(x(2) * x(2) + x(3) * x(3));
241 const std::map<base::ObjectSubType, float> &kTypeSpeedLimit =
243 if (speed > kTypeSpeedLimit.at(object->sub_type)) {
244 double ratio = kTypeSpeedLimit.at(object->sub_type) / speed;
245 Eigen::Vector2d vel;
246 vel << x(2) * ratio, x(3) * ratio;
249 }
250 object->center(0) = x(0);
251 object->center(1) = x(1);
252 object->center_uncertainty.setConstant(0);
253 object->center_uncertainty(0, 0) =
255 object->center_uncertainty(1, 1) =
257 object->velocity(0) = static_cast<float>(x(2));
258 object->velocity(1) = static_cast<float>(x(3));
259 object->velocity(2) = 0;
263 object->direction(0) = static_cast<float>(x(2) / speed);
264 object->direction(1) = static_cast<float>(x(3) / speed);
265 object->direction(2) = 0;
266 object->theta = static_cast<float>(std::atan2(x(3), x(2)));
267 }
268 }
269
272
273 bool stable_moving = false;
276 stable_moving = true;
278 auto prev_pos =
get_object(-2)->object->center;
279 auto displacement = object->center - prev_pos;
280 Eigen::VectorXd measured_theta(1);
281 measured_theta << std::atan2(displacement[1], displacement[0]);
283
284
287 }
288
289
291 if (!stable_moving &&
292 residual(0) * residual(0) <
294 residual(1) * residual(1) <
296 object->velocity(0) = 0;
297 object->velocity(1) = 0;
298 }
299
300
301 history_world_states_.push_back(object);
302 ClappingTrackVelocity(object);
303 }
304
305
306 ADEBUG <<
"obj_speed--id: " <<
id <<
" " <<
object->velocity.head(2).norm();
307}
void Correct(const VectorNd &measurement)
void MagicVelocity(const Eigen::VectorXd &vel)
const Eigen::MatrixXd & get_variance() const
const std::map< base::ObjectSubType, float > & TypeSpeedLimit()
bool Equal(double x, double target, double eps)
optional float displacement_theta_var
optional float large_velocity_ratio
optional float stable_moving_speed
optional float velocity_threshold
optional float too_large_velocity_ratio
optional bool clapping_velocity