Skip to content

Commit fca1310

Browse files
committed
ArduPilotPlugin: add option to disable SITL from trying to sync with wall time
- Populate extra fields in JSON message. - Generally Gazebo runs with simulation time, so we do not want to sync with the wall clock. - When running SITL on a docker container using a windows or macOS host, the monotonic clock can jump to a different epoch if there is a vDSO page fault. This results in a FPE and crash. Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>
1 parent 6822fe4 commit fca1310

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

include/ArduPilotPlugin.hh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ class ArduPilotPluginPrivate;
8484
/// <anemometer> scoped name for the wind sensor
8585
/// <connectionTimeoutMaxCount> timeout before giving up on
8686
/// controller synchronization
87+
/// <lock_step> set true to enforce lock-step simulation
88+
/// <no_time_sync> set true to prevent SITL from trying to sync
89+
/// with wall-time
8790
/// <have_32_channels> set true if 32 channels are enabled
8891
///
8992
class GZ_SIM_VISIBLE ArduPilotPlugin:

src/ArduPilotPlugin.cc

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,9 @@ class gz::sim::systems::ArduPilotPluginPrivate
244244
/// \brief Set true to enforce lock-step simulation
245245
public: bool isLockStep{false};
246246

247+
/// \brief Set true to prevent SITL from trying to sync with wall-time
248+
public: bool isNoTimeSync{true};
249+
247250
/// \brief Set true if have 32 servo channels
248251
public: bool have32Channels{false};
249252

@@ -510,7 +513,11 @@ void gz::sim::systems::ArduPilotPlugin::Configure(
510513
this->dataPtr->isLockStep =
511514
sdfClone->Get("lock_step", this->dataPtr->isLockStep).first;
512515

513-
this->dataPtr->have32Channels =
516+
// Prevent SITL attempting time-sync (has default: true)
517+
this->dataPtr->isNoTimeSync =
518+
sdfClone->Get("no_time_sync", this->dataPtr->isNoTimeSync).first;
519+
520+
this->dataPtr->have32Channels =
514521
sdfClone->Get("have_32_channels", false).first;
515522

516523
// Add the signal handler
@@ -2000,6 +2007,14 @@ void gz::sim::systems::ArduPilotPlugin::CreateStateJSON(
20002007
writer.EndObject();
20012008
}
20022009

2010+
// Set no time sync
2011+
writer.Key("no_time_sync");
2012+
writer.Bool(this->dataPtr->isNoTimeSync);
2013+
2014+
// Set no lockstep
2015+
writer.Key("no_lockstep");
2016+
writer.Bool(!this->dataPtr->isLockStep);
2017+
20032018
writer.EndObject();
20042019

20052020
// get JSON

0 commit comments

Comments
 (0)