Skip to content

Commit 4905992

Browse files
committed
bugfix: mot multi-step prediction is not work as intended. back to one-step prediction.
Signed-off-by: Taekjin LEE <taekjin.lee@tier4.jp>
1 parent fcebec6 commit 4905992

File tree

3 files changed

+39
-22
lines changed

3 files changed

+39
-22
lines changed

perception/multi_object_tracker/include/multi_object_tracker/multi_object_tracker_core.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ class MultiObjectTracker : public rclcpp::Node
124124
const autoware_auto_perception_msgs::msg::DetectedObject & object, const rclcpp::Time & time,
125125
const geometry_msgs::msg::Transform & self_transform) const;
126126

127-
void publish(const rclcpp::Time & time);
127+
void publish(const rclcpp::Time & time) const;
128128
inline bool shouldTrackerPublish(const std::shared_ptr<const Tracker> tracker) const;
129129
};
130130

perception/multi_object_tracker/src/multi_object_tracker_core.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ inline bool MultiObjectTracker::shouldTrackerPublish(
441441
return true;
442442
}
443443

444-
void MultiObjectTracker::publish(const rclcpp::Time & time)
444+
void MultiObjectTracker::publish(const rclcpp::Time & time) const
445445
{
446446
const auto subscriber_count = tracked_objects_pub_->get_subscription_count() +
447447
tracked_objects_pub_->get_intra_process_subscription_count();

perception/multi_object_tracker/src/tracker/motion_model/motion_model_base.cpp

+37-20
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,28 @@ bool MotionModel::predictState(const rclcpp::Time & time)
4646
if (dt < 0.0) {
4747
return false;
4848
}
49-
// if dt is too large, shorten dt and repeat prediction
50-
const uint32_t repeat = std::ceil(dt / dt_max_);
51-
const double dt_ = dt / repeat;
52-
for (uint32_t i = 0; i < repeat; ++i) {
53-
if (!predictStateStep(dt_, ekf_)) {
54-
return false;
55-
}
56-
// add interval to last_update_time_
57-
last_update_time_ += rclcpp::Duration::from_seconds(dt_);
49+
if (dt < 1e-6 /*1usec*/) {
50+
return true;
5851
}
52+
53+
// // if dt is too large, shorten dt and repeat prediction
54+
// {
55+
// const uint32_t repeat = std::floor(dt / dt_max_) + 1;
56+
// const double dt_ = dt / repeat;
57+
// for (uint32_t i = 0; i < repeat; ++i) {
58+
// if (!predictStateStep(dt_, ekf_)) {
59+
// return false;
60+
// }
61+
// // add interval to last_update_time_
62+
// last_update_time_ += rclcpp::Duration::from_seconds(dt_);
63+
// }
64+
// std::cout << "MotionModel::predictState predict dt: " << dt << ", dt_: " << dt_ << ",
65+
// repeat:
66+
// "<< repeat<< std::endl;
67+
// }
68+
69+
if (!predictStateStep(dt, ekf_)) return false;
70+
5971
// update last_update_time_ to the estimation time
6072
last_update_time_ = time;
6173
return true;
@@ -76,17 +88,22 @@ bool MotionModel::getPredictedState(
7688
dt = 0.0;
7789
}
7890

79-
// predict only when dt is small enough
80-
if (0.001 /*1msec*/ < dt) {
81-
// if dt is too large, shorten dt and repeat prediction
82-
const uint32_t repeat = std::ceil(dt / dt_max_);
83-
const double dt_ = dt / repeat;
84-
for (uint32_t i = 0; i < repeat; ++i) {
85-
if (!predictStateStep(dt_, tmp_ekf_for_no_update)) {
86-
return false;
87-
}
88-
}
89-
}
91+
// // predict only when dt is small enough
92+
// if (1e-6 /*1usec*/ < dt) {
93+
// // if dt is too large, shorten dt and repeat prediction
94+
// const uint32_t repeat = std::floor(dt / dt_max_) + 1;
95+
// const double dt_ = dt / repeat;
96+
// for (uint32_t i = 0; i < repeat; ++i) {
97+
// if (!predictStateStep(dt_, tmp_ekf_for_no_update)) {
98+
// return false;
99+
// }
100+
// }
101+
// std::cout << "MotionModel::getPredictedStateMatrix predict dt: " << dt << ", dt_: " << dt_ <<
102+
// ", repeat: "<< repeat<< std::endl;
103+
// }
104+
105+
if (!predictStateStep(dt, tmp_ekf_for_no_update)) return false;
106+
90107
tmp_ekf_for_no_update.getX(X);
91108
tmp_ekf_for_no_update.getP(P);
92109
return true;

0 commit comments

Comments
 (0)