-
Notifications
You must be signed in to change notification settings - Fork 486
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set initial sim time from the command-line #3294
Merged
scpeters
merged 7 commits into
gazebosim:gazebo11
from
audrow:audrow/add-init-sim-time-cli
Feb 3, 2023
Merged
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e62ed55
Set initial sim time from the cli
audrow 9615d70
Add test
audrow 80de2f0
Change test name
audrow 5cc4db3
Move initial sim time
audrow 5078e9d
Update comment and remove unneeded transport node
audrow d1c807a
Remove code meant for debugging
audrow 7f872b4
adjust argument order in help string
scpeters File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Copyright (C) 2023 Open Source Robotics Foundation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
#include <string> | ||
#include "gazebo/common/Time.hh" | ||
#include "gazebo/test/ServerFixture.hh" | ||
|
||
using namespace gazebo; | ||
|
||
const double initialSimTime = 1675117690.123456; | ||
|
||
/// \brief Helper class that initializes each test. | ||
class WorldWithInitialSimTimeFromCliTest : public ServerFixture | ||
{ | ||
/// \brief Class constructor. | ||
public: WorldWithInitialSimTimeFromCliTest() | ||
{ | ||
// Start the server with a log file and paused. | ||
scpeters marked this conversation as resolved.
Show resolved
Hide resolved
|
||
this->LoadArgs("-u --initial_sim_time " + std::to_string(initialSimTime)); | ||
this->world = physics::get_world("default"); | ||
|
||
// Prepare the transport. | ||
this->node = transport::NodePtr(new transport::Node()); | ||
this->node->Init(); | ||
|
||
std::this_thread::sleep_for(std::chrono::milliseconds(300)); | ||
scpeters marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
/// \brief Gazebo transport node. | ||
public: transport::NodePtr node; | ||
|
||
/// \brief Pointer to the world. | ||
public: physics::WorldPtr world; | ||
}; | ||
|
||
///////////////////////////////////////////////// | ||
/// \brief Check that the initial simulation time is set correctly. | ||
TEST_F(WorldWithInitialSimTimeFromCliTest, CheckInitialSimTime) | ||
{ | ||
ASSERT_TRUE(this->world != NULL); | ||
EXPECT_TRUE(this->world->IsPaused()); | ||
|
||
// check that the simulation time is the same as the initial sim time | ||
EXPECT_DOUBLE_EQ(this->world->SimTime().Double(), initialSimTime); | ||
} | ||
|
||
///////////////////////////////////////////////// | ||
int main(int argc, char **argv) | ||
{ | ||
::testing::InitGoogleTest(&argc, argv); | ||
return RUN_ALL_TESTS(); | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the order of these arguments determines the formatting of the help string, so I would move this out of the middle of the
record_*
arguments to be next toiters
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 5cc4db3.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks; I pushed it one more line in 7f872b4