@@ -41,7 +41,7 @@ struct TrackerV2::Impl {
4141
4242 RobotModel::Config robot_config;
4343 std::unordered_map<ArmorGenre, Timestamp> robot_stamps;
44- std::unordered_map<ArmorGenre, RobotModel> robots ;
44+ std::unordered_map<ArmorGenre, RobotModel> robot_models ;
4545
4646 OutpostModel::Config outpost_config;
4747 Timestamp outpost_stamp;
@@ -128,7 +128,7 @@ struct TrackerV2::Impl {
128128
129129 const auto dt = std::chrono::duration<double > { timestamp - stamp };
130130 if (dt.count () > config.timeout_seconds ) {
131- robots .erase (id);
131+ robot_models .erase (id);
132132 logging.warn (" Timeout model with {}" , get_enum_name (id));
133133 return true ;
134134 }
@@ -182,17 +182,18 @@ struct TrackerV2::Impl {
182182 if (id == DeviceId::OUTPOST ) {
183183 continue ;
184184 }
185- if (robots .contains (id) == false ) {
186- robots .try_emplace (id, robot_config);
187- robots [id].configure_camera (
185+ if (robot_models .contains (id) == false ) {
186+ robot_models .try_emplace (id, robot_config);
187+ robot_models [id].update_camera (
188188 std::bit_cast<std::array<double , 9 >>(camera.camera_matrix ),
189189 camera.distort_coeff );
190- robots [id].update_transform ({
190+ robot_models [id].update_transform ({
191191 .translation = camera.translation ,
192192 .orientation = camera.orientation ,
193193 });
194- if (!robots[id].start_with (target.armor2ds )) {
195- robots.erase (id);
194+ if (!robot_models[id].init (target.armor2ds )) {
195+ robot_models.erase (id);
196+ robot_stamps.erase (id);
196197 logging.warn (" Init failed with {}" , get_enum_name (id));
197198 } else {
198199 logging.info (" Init OK with {}" , get_enum_name (id));
@@ -202,13 +203,19 @@ struct TrackerV2::Impl {
202203 timestamp - robot_stamps[id],
203204 };
204205
205- auto & model = robots [id];
206+ auto & model = robot_models [id];
206207 model.update_transform ({
207208 .translation = camera.translation ,
208209 .orientation = camera.orientation ,
209210 });
210211 model.predict (dt.count ());
211212 model.correct (target.armor2ds , target.bars );
213+
214+ if (model.diverged ()) {
215+ robot_models.erase (id);
216+ robot_stamps.erase (id);
217+ logging.warn (" {} is diverged" , get_enum_name (id));
218+ }
212219 }
213220 robot_stamps[id] = timestamp;
214221 }
@@ -229,6 +236,8 @@ struct TrackerV2::Impl {
229236 auto result = Trackable::Unique { };
230237 auto better = std::numeric_limits<double >::max ();
231238 {
239+ // / @FIXME:
240+ // / 1. 误识别的机器人,也会被认为是收敛的,因为只进行了一帧 init
232241 if (outpost && outpost->converge ()) {
233242 const auto state = outpost->state ();
234243 const auto score = calculate (DeviceId::OUTPOST , state.direction ());
@@ -240,7 +249,7 @@ struct TrackerV2::Impl {
240249 }
241250 std::ranges::copy (outpost->full (), std::back_inserter (addition.tracked3d ));
242251 }
243- for (const auto & [id, model] : robots ) {
252+ for (const auto & [id, model] : robot_models ) {
244253 if (model.converge ()) {
245254 const auto state = model.state ();
246255 const auto score = calculate (id, state.direction ());
0 commit comments