@@ -258,6 +258,9 @@ void CommsBrokerPlugin::OnPose(const ignition::msgs::Pose_V &_msg)
258
258
for (int i = 0 ; i < _msg.pose_size (); ++i)
259
259
this ->poses [_msg.pose (i).name ()] = ignition::msgs::Convert (_msg.pose (i));
260
260
261
+ // Update the visibility graph if needed.
262
+ this ->UpdateIfNewBreadcrumbs ();
263
+
261
264
// double dt = (this->simTime - this->lastROSParameterCheckTime).Double();
262
265
263
266
// Todo: Remove this line and enable the block below when ROS parameter
@@ -299,3 +302,29 @@ void CommsBrokerPlugin::OnPose(const ignition::msgs::Pose_V &_msg)
299
302
// the message according to the communication model.
300
303
this ->broker .DispatchMessages ();
301
304
}
305
+
306
+ // ///////////////////////////////////////////////
307
+ void CommsBrokerPlugin::UpdateIfNewBreadcrumbs ()
308
+ {
309
+ bool newBreadcrumbFound = false ;
310
+ for (const auto & [name, pose] : this ->poses )
311
+ {
312
+ // New breadcrumb found.
313
+ if (name.find (" __breadcrumb__" ) != std::string::npos &&
314
+ this ->breadcrumbs .find (name) == this ->breadcrumbs .end ())
315
+ {
316
+ this ->breadcrumbs [name] = pose;
317
+ newBreadcrumbFound = true ;
318
+ }
319
+ }
320
+
321
+ // Update the comms.
322
+ if (newBreadcrumbFound)
323
+ {
324
+ std::set<ignition::math::Vector3d> breadcrumbPoses;
325
+ for (const auto & [name, pose] : this ->breadcrumbs )
326
+ breadcrumbPoses.insert (pose.Pos ());
327
+ this ->visibilityModel ->PopulateVisibilityInfo (breadcrumbPoses);
328
+ ignmsg << " New breadcrumb detected, visibility graph updated" << std::endl;
329
+ }
330
+ }
0 commit comments