From d28b71ef53f8e525fa79d8058892b36fb243017d Mon Sep 17 00:00:00 2001 From: Joan Aguilar Mayans Date: Thu, 17 Nov 2022 15:34:54 -0800 Subject: [PATCH 01/13] Add simulation time epoch to SimulationRunner. Signed-off-by: Joan Aguilar Mayans --- src/SimulationRunner.cc | 25 ++++++++++++++++++------- src/SimulationRunner.hh | 8 ++++++++ 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/src/SimulationRunner.cc b/src/SimulationRunner.cc index afb3909147..e600781bf6 100644 --- a/src/SimulationRunner.cc +++ b/src/SimulationRunner.cc @@ -122,6 +122,12 @@ SimulationRunner::SimulationRunner(const sdf::World *_world, static_cast(this->stepSize.count() / this->desiredRtf)); } + // Epoch + // TODO: Decide on chrono precision. + this->simTimeEpoch = std::chrono::round( + std::chrono::duration{_config.InitialSimTime()} + ); + // World control transport::NodeOptions opts; std::string ns{"/world/" + this->worldName}; @@ -266,13 +272,13 @@ void SimulationRunner::UpdateCurrentInfo() // Rewind if (this->requestedRewind) { - gzdbg << "Rewinding simulation back to time zero." << std::endl; + gzdbg << "Rewinding simulation back to initial time." << std::endl; this->realTimes.clear(); this->simTimes.clear(); this->realTimeFactor = 0; - this->currentInfo.dt = -this->currentInfo.simTime; - this->currentInfo.simTime = std::chrono::steady_clock::duration::zero(); + this->currentInfo.dt = this->simTimeEpoch - this->currentInfo.simTime; + this->currentInfo.simTime = this->simTimeEpoch; this->currentInfo.realTime = std::chrono::steady_clock::duration::zero(); this->currentInfo.iterations = 0; this->realTimeWatch.Reset(); @@ -845,8 +851,7 @@ void SimulationRunner::Step(const UpdateInfo &_info) this->UpdateSystems(); if (!this->Paused() && - this->requestedRunToSimTime > - std::chrono::steady_clock::duration::zero() && + this->requestedRunToSimTime > this->simTimeEpoch && this->currentInfo.simTime >= this->requestedRunToSimTime) { this->SetPaused(true); @@ -1104,8 +1109,7 @@ bool SimulationRunner::Stepping() const void SimulationRunner::SetRunToSimTime( const std::chrono::steady_clock::duration &_time) { - if (_time >= std::chrono::steady_clock::duration::zero() && - _time > this->currentInfo.simTime) + if (_time >= this->simTimeEpoch && _time > this->currentInfo.simTime) { this->requestedRunToSimTime = _time; } @@ -1355,6 +1359,13 @@ const UpdateInfo &SimulationRunner::CurrentInfo() const return this->currentInfo; } +///////////////////////////////////////////////// +const std::chrono::steady_clock::duration & + SimulationRunner::SimTimeEpoch() const +{ + return this->simTimeEpoch; +} + ///////////////////////////////////////////////// const std::chrono::steady_clock::duration & SimulationRunner::UpdatePeriod() const diff --git a/src/SimulationRunner.hh b/src/SimulationRunner.hh index 8690d81168..d3785eb68b 100644 --- a/src/SimulationRunner.hh +++ b/src/SimulationRunner.hh @@ -192,6 +192,10 @@ namespace gz public: void SetUpdatePeriod( const std::chrono::steady_clock::duration &_updatePeriod); + /// \brief Get the simulation epoch. + /// \return The simulation epoch. + public: const std::chrono::steady_clock::duration &SimTimeEpoch() const; + /// \brief Get the update period. /// \return The update period. public: const std::chrono::steady_clock::duration &UpdatePeriod() const; @@ -427,6 +431,10 @@ namespace gz /// The default update rate is 500hz, which is a period of 2ms. private: std::chrono::steady_clock::duration updatePeriod{2ms}; + /// \brief The simulation epoch. + /// All simulation times will be larger than the epoch. It defaults to 0. + private: std::chrono::steady_clock::duration simTimeEpoch{0}; + /// \brief List of simulation times used to compute averages. private: std::list simTimes; From 573d95b7b7fcef5d43272882e73cc3cb8a5e98f4 Mon Sep 17 00:00:00 2001 From: Joan Aguilar Mayans Date: Thu, 17 Nov 2022 15:55:42 -0800 Subject: [PATCH 02/13] Add initial simulation time to ServerConfig. Signed-off-by: Joan Aguilar Mayans --- include/gz/sim/ServerConfig.hh | 9 +++++++++ src/ServerConfig.cc | 16 ++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/include/gz/sim/ServerConfig.hh b/include/gz/sim/ServerConfig.hh index 2eaae435eb..f6dc3df92b 100644 --- a/include/gz/sim/ServerConfig.hh +++ b/include/gz/sim/ServerConfig.hh @@ -246,6 +246,15 @@ namespace gz /// an UpdateRate has not been set. public: std::optional UpdateRate() const; + /// \brief Set the initial simulation time in seconds. + /// \param[in] _initialSimTime The desired initial simulation time in + /// seconds. + public: void SetInitialSimTime(const double &_initialSimTime) const; + + /// \brief Get the initial simulation time in seconds. + /// \return The initial simulation time in seconds. + public: double InitialSimTime() const; + /// \brief Get whether the server is using the level system /// \return True if the server is set to use the level system public: bool UseLevels() const; diff --git a/src/ServerConfig.cc b/src/ServerConfig.cc index 6c325ba684..48998cc676 100644 --- a/src/ServerConfig.cc +++ b/src/ServerConfig.cc @@ -248,6 +248,7 @@ class gz::sim::ServerConfigPrivate : sdfFile(_cfg->sdfFile), sdfString(_cfg->sdfString), updateRate(_cfg->updateRate), + initialSimTime(_cfg->initialSimTime), useLevels(_cfg->useLevels), useLogRecord(_cfg->useLogRecord), logRecordPath(_cfg->logRecordPath), @@ -275,6 +276,9 @@ class gz::sim::ServerConfigPrivate /// \brief An optional update rate. public: std::optional updateRate; + /// \brief The initial simulation time in seconds. + public: double initialSimTime = 0; + /// \brief Use the level system public: bool useLevels{false}; @@ -389,6 +393,12 @@ std::string ServerConfig::SdfString() const return this->dataPtr->sdfString; } +////////////////////////////////////////////////// +void ServerConfig::SetInitialSimTime(const double &_initialSimTime) const +{ + this->dataPtr->initialSimTime = _initialSimTime; +} + ////////////////////////////////////////////////// void ServerConfig::SetUpdateRate(const double &_hz) { @@ -396,6 +406,12 @@ void ServerConfig::SetUpdateRate(const double &_hz) this->dataPtr->updateRate = _hz; } +///////////////////////////////////////////////// +double ServerConfig::InitialSimTime() const +{ + return this->dataPtr->initialSimTime; +} + ///////////////////////////////////////////////// std::optional ServerConfig::UpdateRate() const { From 974f64b52f2bc64f044c2bf95b1d1fab301ee11c Mon Sep 17 00:00:00 2001 From: Joan Aguilar Mayans Date: Thu, 17 Nov 2022 15:59:17 -0800 Subject: [PATCH 03/13] Add initial simulation time to gz.hh and gz.cc. Signed-off-by: Joan Aguilar Mayans --- src/gz.cc | 6 +++++- src/gz.hh | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/gz.cc b/src/gz.cc index 1337ab96e1..5052eba251 100644 --- a/src/gz.cc +++ b/src/gz.cc @@ -130,7 +130,8 @@ extern "C" const char *findFuelResource( ////////////////////////////////////////////////// extern "C" int runServer(const char *_sdfString, - int _iterations, int _run, float _hz, int _levels, const char *_networkRole, + int _iterations, int _run, float _hz, float _initialSimTime, + int _levels, const char *_networkRole, int _networkSecondaries, int _record, const char *_recordPath, int _recordResources, int _logOverwrite, int _logCompress, const char *_playback, const char *_physicsEngine, @@ -350,6 +351,9 @@ extern "C" int runServer(const char *_sdfString, else serverConfig.SetSdfFile(_file); + // Initial simulation time. + serverConfig.SetInitialSimTime(_initialSimTime); + // Set the update rate. if (_hz > 0.0) serverConfig.SetUpdateRate(_hz); diff --git a/src/gz.hh b/src/gz.hh index 7f54fed938..4067b1b49a 100644 --- a/src/gz.hh +++ b/src/gz.hh @@ -60,7 +60,7 @@ extern "C" GZ_SIM_VISIBLE const char *worldInstallDir(); /// \param[in] _recordPeriod --record-period option /// \return 0 if successful, 1 if not. extern "C" GZ_SIM_VISIBLE int runServer(const char *_sdfString, - int _iterations, int _run, float _hz, int _levels, + int _iterations, int _run, float _hz, float _initialSimTime, int _levels, const char *_networkRole, int _networkSecondaries, int _record, const char *_recordPath, int _recordResources, int _logOverwrite, int _logCompress, const char *_playback, From 9a61e20066342aac735cc6fb244042f02c0a1811 Mon Sep 17 00:00:00 2001 From: Joan Aguilar Mayans Date: Thu, 17 Nov 2022 16:11:54 -0800 Subject: [PATCH 04/13] Add initial simulation time to cmdsim. Signed-off-by: Joan Aguilar Mayans --- src/cmd/cmdsim.rb.in | 43 ++++++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/src/cmd/cmdsim.rb.in b/src/cmd/cmdsim.rb.in index 1ee6829614..3d34327646 100755 --- a/src/cmd/cmdsim.rb.in +++ b/src/cmd/cmdsim.rb.in @@ -49,6 +49,8 @@ COMMANDS = { 'sim' => "Available Options: \n"\ " -g Run only the GUI. \n"\ "\n"\ + " --initial-sim-time [arg] Initial simulation time, in seconds. \n"\ + "\n"\ " --iterations [arg] Number of iterations to execute. \n"\ "\n"\ " --levels Use the level system. The default is false, \n"\ @@ -209,6 +211,7 @@ class Cmd 'file' => '', 'gui' => 0, 'hz' => -1, + 'initial_sim_time' => 0, 'iterations' => 0, 'levels' => 0, 'network_role' => '', @@ -260,6 +263,10 @@ class Cmd opts.on('-z [arg]', Float, 'Update rate in Hertz') do |h| options['hz'] = h end + opts.on('--initial-sim-time [arg]', Float, + 'Initial simulation time, in seconds.') do |t| + options['initial_sim_time'] = t + end opts.on('-r') do options['run'] = 1 end @@ -497,15 +504,16 @@ See https://github.com/gazebosim/gz-sim/issues/168 for more info." ENV['RMT_PORT'] = '1500' Process.setpgid(0, 0) Process.setproctitle('gz sim server') - Importer.runServer(parsed, options['iterations'], options['run'], - options['hz'], options['levels'], options['network_role'], - options['network_secondaries'], options['record'], - options['record-path'], options['record-resources'], - options['log-overwrite'], options['log-compress'], - options['playback'], options['physics_engine'], - options['render_engine_server'], options['render_engine_gui'], - options['file'], options['record-topics'].join(':'), - options['wait_gui'], + Importer.runServer(parsed, + options['iterations'], options['run'], options['hz'], + options['initial_sim_time'], options['levels'], + options['network_role'], options['network_secondaries'], + options['record'], options['record-path'], + options['record-resources'], options['log-overwrite'], + options['log-compress'], options['playback'], + options['physics_engine'], options['render_engine_server'], + options['render_engine_gui'], options['file'], + options['record-topics'].join(':'), options['wait_gui'], options['headless-rendering'], options['record-period']) end @@ -536,14 +544,15 @@ See https://github.com/gazebosim/gz-sim/issues/168 for more info." elsif options['server'] == 1 ENV['RMT_PORT'] = '1500' Importer.runServer(parsed, options['iterations'], options['run'], - options['hz'], options['levels'], options['network_role'], - options['network_secondaries'], options['record'], - options['record-path'], options['record-resources'], - options['log-overwrite'], options['log-compress'], - options['playback'], options['physics_engine'], - options['render_engine_server'], options['render_engine_gui'], - options['file'], options['record-topics'].join(':'), - options['wait_gui'], options['headless-rendering'], options['record-period']) + options['hz'], optionas['initial_sim_time'], options['levels'], + options['network_role'], options['network_secondaries'], + options['record'], options['record-path'], + options['record-resources'], options['log-overwrite'], + options['log-compress'], options['playback'], + options['physics_engine'], options['render_engine_server'], + options['render_engine_gui'], options['file'], + options['record-topics'].join(':'), options['wait_gui'], + options['headless-rendering'], options['record-period']) # Otherwise run the gui else options['gui'] if plugin.end_with? ".dylib" From 2d76a160603edee4134fd9f41aee28b3b709864f Mon Sep 17 00:00:00 2001 From: Joan Aguilar Mayans Date: Fri, 18 Nov 2022 14:49:41 -0800 Subject: [PATCH 05/13] Increase precision of initialSimTime to double. Signed-off-by: Joan Aguilar Mayans --- src/gz.cc | 2 +- src/gz.hh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gz.cc b/src/gz.cc index 5052eba251..a1298dfa79 100644 --- a/src/gz.cc +++ b/src/gz.cc @@ -130,7 +130,7 @@ extern "C" const char *findFuelResource( ////////////////////////////////////////////////// extern "C" int runServer(const char *_sdfString, - int _iterations, int _run, float _hz, float _initialSimTime, + int _iterations, int _run, float _hz, double _initialSimTime, int _levels, const char *_networkRole, int _networkSecondaries, int _record, const char *_recordPath, int _recordResources, int _logOverwrite, int _logCompress, diff --git a/src/gz.hh b/src/gz.hh index 4067b1b49a..3e45e70f87 100644 --- a/src/gz.hh +++ b/src/gz.hh @@ -60,7 +60,7 @@ extern "C" GZ_SIM_VISIBLE const char *worldInstallDir(); /// \param[in] _recordPeriod --record-period option /// \return 0 if successful, 1 if not. extern "C" GZ_SIM_VISIBLE int runServer(const char *_sdfString, - int _iterations, int _run, float _hz, float _initialSimTime, int _levels, + int _iterations, int _run, float _hz, double _initialSimTime, int _levels, const char *_networkRole, int _networkSecondaries, int _record, const char *_recordPath, int _recordResources, int _logOverwrite, int _logCompress, const char *_playback, From d33e108c8d533431ddea8274b0b50b718216b719 Mon Sep 17 00:00:00 2001 From: Joan Aguilar Mayans Date: Mon, 21 Nov 2022 15:41:02 -0800 Subject: [PATCH 06/13] Change simTimeEpoch precision to nanoseconds and remove TODO. Signed-off-by: Joan Aguilar Mayans --- src/SimulationRunner.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/SimulationRunner.cc b/src/SimulationRunner.cc index e600781bf6..8daf9d7621 100644 --- a/src/SimulationRunner.cc +++ b/src/SimulationRunner.cc @@ -123,8 +123,7 @@ SimulationRunner::SimulationRunner(const sdf::World *_world, } // Epoch - // TODO: Decide on chrono precision. - this->simTimeEpoch = std::chrono::round( + this->simTimeEpoch = std::chrono::round( std::chrono::duration{_config.InitialSimTime()} ); From 27bdbd9084898799fe99d038f52530c0633c1091 Mon Sep 17 00:00:00 2001 From: Joan Aguilar Mayans Date: Mon, 21 Nov 2022 15:42:04 -0800 Subject: [PATCH 07/13] Add missing parameter in runServer call. Signed-off-by: Joan Aguilar Mayans --- src/cmd/cmdsim.rb.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmd/cmdsim.rb.in b/src/cmd/cmdsim.rb.in index 7c2abe813d..36be293014 100755 --- a/src/cmd/cmdsim.rb.in +++ b/src/cmd/cmdsim.rb.in @@ -467,7 +467,7 @@ Please use [GZ_SIM_RESOURCE_PATH] instead." end # Import the runServer function - Importer.extern 'int runServer(const char *, int, int, float, int, + Importer.extern 'int runServer(const char *, int, int, float, double, int, const char *, int, int, const char *, int, int, int, const char *, const char *, const char *, const char *, const char *, From 52506e2dd548602245eafe5eea936286dcc389c6 Mon Sep 17 00:00:00 2001 From: Joan Aguilar Mayans Date: Mon, 21 Nov 2022 17:46:39 -0800 Subject: [PATCH 08/13] Fix typo. Signed-off-by: Joan Aguilar Mayans --- src/cmd/cmdsim.rb.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmd/cmdsim.rb.in b/src/cmd/cmdsim.rb.in index 36be293014..1a69af9461 100755 --- a/src/cmd/cmdsim.rb.in +++ b/src/cmd/cmdsim.rb.in @@ -544,7 +544,7 @@ See https://github.com/gazebosim/gz-sim/issues/168 for more info." elsif options['server'] == 1 ENV['RMT_PORT'] = '1500' Importer.runServer(parsed, options['iterations'], options['run'], - options['hz'], optionas['initial_sim_time'], options['levels'], + options['hz'], options['initial_sim_time'], options['levels'], options['network_role'], options['network_secondaries'], options['record'], options['record-path'], options['record-resources'], options['log-overwrite'], From 8bd519f4ab6aa261eec7e29c77f20e782f9055a0 Mon Sep 17 00:00:00 2001 From: Joan Aguilar Mayans Date: Tue, 29 Nov 2022 14:45:13 -0800 Subject: [PATCH 09/13] Set currentInfo.simTime to the simTimeEpoch during construction. Signed-off-by: Joan Aguilar Mayans --- src/SimulationRunner.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/SimulationRunner.cc b/src/SimulationRunner.cc index d11bb654cd..56acfd1934 100644 --- a/src/SimulationRunner.cc +++ b/src/SimulationRunner.cc @@ -126,6 +126,7 @@ SimulationRunner::SimulationRunner(const sdf::World *_world, this->simTimeEpoch = std::chrono::round( std::chrono::duration{_config.InitialSimTime()} ); + this->currentInfo.simTime = this->simTimeEpoch; // World control transport::NodeOptions opts; From 5dea45c09e28d0196f6d4e1e6dad4eeb4ad39a6a Mon Sep 17 00:00:00 2001 From: Joan Aguilar Mayans Date: Tue, 29 Nov 2022 16:04:22 -0800 Subject: [PATCH 10/13] Update handling of requestedSeek and requestedRunToSimTime. Signed-off-by: Joan Aguilar Mayans --- src/SimulationRunner.cc | 23 ++++++++++++----------- src/SimulationRunner.hh | 14 +++++++------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/SimulationRunner.cc b/src/SimulationRunner.cc index 56acfd1934..9b220a0ec3 100644 --- a/src/SimulationRunner.cc +++ b/src/SimulationRunner.cc @@ -291,22 +291,23 @@ void SimulationRunner::UpdateCurrentInfo() } // Seek - if (this->requestedSeek >= std::chrono::steady_clock::duration::zero()) + if (this->requestedSeek && this->requestedSeek.value() >= this->simTimeEpoch) { gzdbg << "Seeking to " << std::chrono::duration_cast( - this->requestedSeek).count() << "s." << std::endl; + this->requestedSeek.value()).count() << "s." << std::endl; this->realTimes.clear(); this->simTimes.clear(); this->realTimeFactor = 0; - this->currentInfo.dt = this->requestedSeek - this->currentInfo.simTime; - this->currentInfo.simTime = this->requestedSeek; + this->currentInfo.dt = this->requestedSeek.value() - + this->currentInfo.simTime; + this->currentInfo.simTime = this->requestedSeek.value(); this->currentInfo.iterations = 0; this->currentInfo.realTime = this->realTimeWatch.ElapsedRunTime(); - this->requestedSeek = std::chrono::steady_clock::duration{-1}; + this->requestedSeek = {}; return; } @@ -850,12 +851,12 @@ void SimulationRunner::Step(const UpdateInfo &_info) // Update all the systems. this->UpdateSystems(); - if (!this->Paused() && - this->requestedRunToSimTime > this->simTimeEpoch && - this->currentInfo.simTime >= this->requestedRunToSimTime) + if (!this->Paused() && this->requestedRunToSimTime && + this->requestedRunToSimTime.value() > this->simTimeEpoch && + this->currentInfo.simTime >= this->requestedRunToSimTime.value()) { this->SetPaused(true); - this->requestedRunToSimTime = std::chrono::steady_clock::duration{-1}; + this->requestedRunToSimTime = {}; } if (!this->Paused() && this->pendingSimIterations > 0) @@ -1115,7 +1116,7 @@ void SimulationRunner::SetRunToSimTime( } else { - this->requestedRunToSimTime = std::chrono::seconds(-1); + this->requestedRunToSimTime = {}; } } @@ -1257,7 +1258,7 @@ void SimulationRunner::ProcessWorldControl() this->requestedRewind = control.rewind; // Seek - if (control.seek >= std::chrono::steady_clock::duration::zero()) + if (control.seek >= this->simTimeEpoch) { this->requestedSeek = control.seek; } diff --git a/src/SimulationRunner.hh b/src/SimulationRunner.hh index d3785eb68b..89e1841e5b 100644 --- a/src/SimulationRunner.hh +++ b/src/SimulationRunner.hh @@ -221,8 +221,8 @@ namespace gz /// \brief Set the run to simulation time. /// \param[in] _time A simulation time in the future to run to and then - /// pause. A negative number or a time less than the current simulation - /// time disables the run-to feature. + /// pause. A time prior than the current simulation time disables the + /// run-to feature. public: void SetRunToSimTime( const std::chrono::steady_clock::duration &_time); @@ -492,12 +492,12 @@ namespace gz private: bool requestedRewind{false}; /// \brief If user asks to seek to a specific sim time, this holds the - /// time.s A negative value means there's no request from the user. - private: std::chrono::steady_clock::duration requestedSeek{-1}; + /// time. + private: std::optional requestedSeek; - /// \brief A simulation time in the future to run to and then pause. - /// A negative number indicates that this variable it not being used. - private: std::chrono::steady_clock::duration requestedRunToSimTime{-1}; + /// \brief A simulation time past the epoch to run to and then pause. + private: std::optional + requestedRunToSimTime; /// \brief Keeps the latest simulation info. private: UpdateInfo currentInfo; From 4d38a9d186166ef8e2eb8ea0d281b55beb755466 Mon Sep 17 00:00:00 2001 From: Aditya Date: Wed, 4 Jan 2023 16:04:11 -0800 Subject: [PATCH 11/13] Added test for simtime argument Signed-off-by: Aditya --- src/gz_TEST.cc | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/gz_TEST.cc b/src/gz_TEST.cc index 73dbd7de1d..9dc8ee310b 100644 --- a/src/gz_TEST.cc +++ b/src/gz_TEST.cc @@ -23,6 +23,8 @@ #include #include #include +#include +#include #include #include "test_config.hh" // NOLINT(build/include) @@ -129,6 +131,29 @@ TEST(CmdLine, GazeboServer) } } +///////////////////////////////////////////////// +TEST(CmdLine, SimtimeArgument) +{ + std::string cmd = kGzCommand + " -r -v 4 --iterations 100 --initial-sim-time 1000.0 " + + std::string(PROJECT_SOURCE_PATH) + "/test/worlds/plugins.sdf"; + + std::cout << "Running command [" << cmd << "]" << std::endl; + int msgCount = 0; + + gz::transport::Node node; + auto cb = [&](const gz::msgs::Clock &_msg) -> void + { + EXPECT_GE(_msg.sim().sec(), 1000); + msgCount++; + }; + + auto cbFcn = std::function(cb); + EXPECT_TRUE(node.Subscribe(std::string("/clock"), cbFcn)); + + std::string output = customExecStr(cmd); + EXPECT_GT(msgCount, 0); +} + ///////////////////////////////////////////////// TEST(CmdLine, Gazebo) { From 6c2a1344dc2db641a64f7d68a8816ae74a3f6567 Mon Sep 17 00:00:00 2001 From: Aditya Date: Fri, 6 Jan 2023 15:11:49 -0800 Subject: [PATCH 12/13] Test starts from t = 1000.5 sec Signed-off-by: Aditya --- src/gz_TEST.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gz_TEST.cc b/src/gz_TEST.cc index 9dc8ee310b..ec58627a66 100644 --- a/src/gz_TEST.cc +++ b/src/gz_TEST.cc @@ -134,7 +134,7 @@ TEST(CmdLine, GazeboServer) ///////////////////////////////////////////////// TEST(CmdLine, SimtimeArgument) { - std::string cmd = kGzCommand + " -r -v 4 --iterations 100 --initial-sim-time 1000.0 " + + std::string cmd = kGzCommand + " -r -v 4 --iterations 100 --initial-sim-time 1000.5 " + std::string(PROJECT_SOURCE_PATH) + "/test/worlds/plugins.sdf"; std::cout << "Running command [" << cmd << "]" << std::endl; @@ -143,7 +143,8 @@ TEST(CmdLine, SimtimeArgument) gz::transport::Node node; auto cb = [&](const gz::msgs::Clock &_msg) -> void { - EXPECT_GE(_msg.sim().sec(), 1000); + EXPECT_GE(_msg.sim().sec() + _msg.sim().nsec()/1000000000.0, + 1000.5); msgCount++; }; From 26eef7b537d7762454d50e83b83a51adc1d612f7 Mon Sep 17 00:00:00 2001 From: Steve Peters Date: Tue, 28 Feb 2023 11:41:43 -0800 Subject: [PATCH 13/13] fix line length Signed-off-by: Steve Peters --- src/gz_TEST.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gz_TEST.cc b/src/gz_TEST.cc index ec58627a66..946dc6a079 100644 --- a/src/gz_TEST.cc +++ b/src/gz_TEST.cc @@ -134,7 +134,8 @@ TEST(CmdLine, GazeboServer) ///////////////////////////////////////////////// TEST(CmdLine, SimtimeArgument) { - std::string cmd = kGzCommand + " -r -v 4 --iterations 100 --initial-sim-time 1000.5 " + + std::string cmd = + kGzCommand + " -r -v 4 --iterations 100 --initial-sim-time 1000.5 " + std::string(PROJECT_SOURCE_PATH) + "/test/worlds/plugins.sdf"; std::cout << "Running command [" << cmd << "]" << std::endl;