Skip to content

Commit

Permalink
Skip updating ignition plugins when simulation is paused (#34)
Browse files Browse the repository at this point in the history
* Skip updating ignition plugins when simulation is paused

Signed-off-by: Luca Della Vedova <luca@openrobotics.org>

* Style

Signed-off-by: Luca Della Vedova <luca@openrobotics.org>
  • Loading branch information
luca-della-vedova committed Aug 12, 2021
1 parent a81991f commit 76fc231
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 0 deletions.
4 changes: 4 additions & 0 deletions rmf_building_sim_ignition_plugins/src/crowd_simulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ void CrowdSimulatorPlugin::PreUpdate(
return;
}

// Don't update the plugin if the simulation is paused
if (info.paused)
return;

// Note, the update_time_step parameter is ignored in ignition
// through GPU animated actors the performance is good enough that
// we can afford to update at every iteration and have smooth animations
Expand Down
4 changes: 4 additions & 0 deletions rmf_building_sim_ignition_plugins/src/door.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ class IGNITION_GAZEBO_VISIBLE DoorPlugin
if (!_initialized)
return;

// Don't update the pose if the simulation is paused
if (info.paused)
return;

double t =
(std::chrono::duration_cast<std::chrono::nanoseconds>(info.simTime).
count()) * 1e-9;
Expand Down
4 changes: 4 additions & 0 deletions rmf_building_sim_ignition_plugins/src/lift.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,10 @@ class IGNITION_GAZEBO_VISIBLE LiftPlugin
if (!_initialized)
return;

// Don't update the pose if the simulation is paused
if (info.paused)
return;

// Send update request
const double t =
(std::chrono::duration_cast<std::chrono::nanoseconds>(info.simTime).
Expand Down
4 changes: 4 additions & 0 deletions rmf_robot_sim_ignition_plugins/src/TeleportDispenser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,10 @@ void TeleportDispenserPlugin::PreUpdate(const UpdateInfo& info,
// TODO parallel thread executor?
rclcpp::spin_some(_dispenser_common->ros_node);

// Don't update the pose if the simulation is paused
if (info.paused)
return;

// Set item that the Dispenser will be configured to dispense. Do this only on first PreUpdate() call.
// Happens here and not in Configure() to allow for all models to load
if (!tried_fill_dispenser)
Expand Down
4 changes: 4 additions & 0 deletions rmf_robot_sim_ignition_plugins/src/TeleportIngestor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,10 @@ void TeleportIngestorPlugin::PreUpdate(const UpdateInfo& info,
// TODO parallel thread executor?
rclcpp::spin_some(_ingestor_common->ros_node);

// Don't update the pose if the simulation is paused
if (info.paused)
return;

std::function<void(void)> send_ingested_item_home_cb =
std::bind(&TeleportIngestorPlugin::send_ingested_item_home,
this, std::ref(ecm));
Expand Down
3 changes: 3 additions & 0 deletions rmf_robot_sim_ignition_plugins/src/readonly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ void ReadonlyPlugin::Configure(const Entity& entity,
void ReadonlyPlugin::PreUpdate(const UpdateInfo& info,
EntityComponentManager& ecm)
{
// Don't update the pose if the simulation is paused
if (info.paused)
return;
auto pose = rmf_plugins_utils::convert_pose(
ecm.Component<components::Pose>(_en)->Data());
auto sim_time =
Expand Down
4 changes: 4 additions & 0 deletions rmf_robot_sim_ignition_plugins/src/slotcar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,10 @@ void SlotcarPlugin::PreUpdate(const UpdateInfo& info,
if (_infrastructure.empty())
init_infrastructure(ecm);

// Don't update the pose if the simulation is paused
if (info.paused)
return;

double dt =
(std::chrono::duration_cast<std::chrono::nanoseconds>(info.dt).count()) *
1e-9;
Expand Down

0 comments on commit 76fc231

Please sign in to comment.