Skip to content
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

Allow specifying initial simulation time with a CLI argument #1801

Merged
merged 16 commits into from
Mar 2, 2023

Conversation

JoanAguilar
Copy link
Contributor

@JoanAguilar JoanAguilar commented Nov 18, 2022

🎉 New feature

Summary

The gz sim command now accepts a new optional paramater: initial-sim-time. This parameter controls the initial value of the simulation time.

Test it

One should be able to run gz sim --initial-sim-time [t], with [t] being a floating point value, and have the simulation time start at [t] seconds.

Checklist

  • Signed all commits for DCO
  • Added tests
  • Added example and/or tutorial
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • Consider updating Python bindings (if the library has them)
  • codecheck passed (See contributing)
  • All tests passed (See test coverage)
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers

Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining Signed-off-by messages.

Signed-off-by: Joan Aguilar Mayans <joan@openrobotics.org>
Signed-off-by: Joan Aguilar Mayans <joan@openrobotics.org>
Signed-off-by: Joan Aguilar Mayans <joan@openrobotics.org>
Signed-off-by: Joan Aguilar Mayans <joan@openrobotics.org>
Signed-off-by: Joan Aguilar Mayans <joan@openrobotics.org>
Signed-off-by: Joan Aguilar Mayans <joan@openrobotics.org>
@JoanAguilar JoanAguilar added the enhancement New feature or request label Nov 18, 2022
@JoanAguilar JoanAguilar self-assigned this Nov 18, 2022
@github-actions github-actions bot added the 🌱 garden Ignition Garden label Nov 18, 2022
@@ -122,6 +122,12 @@ SimulationRunner::SimulationRunner(const sdf::World *_world,
static_cast<int>(this->stepSize.count() / this->desiredRtf));
}

// Epoch
// TODO: Decide on chrono precision.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cpplint wants a user assigned to each TODO

Missing username in TODO; it should look like "// TODO(my_username): Stuff."  [readability/todo] [2]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I was hoping to decide on this before merge. In fact, seeing how updatePeriod uses nanosecond precision, I'll likely change this to the same precision and remove the TODO. That should also get CI to run a bit further.

Signed-off-by: Joan Aguilar Mayans <joan@openrobotics.org>
Signed-off-by: Joan Aguilar Mayans <joan@openrobotics.org>
src/cmd/cmdsim.rb.in Outdated Show resolved Hide resolved
Signed-off-by: Joan Aguilar Mayans <joan@openrobotics.org>
@codecov
Copy link

codecov bot commented Nov 22, 2022

Codecov Report

Merging #1801 (dd58542) into gz-sim7 (3dc8c7a) will decrease coverage by 0.07%.
The diff coverage is 69.48%.

❗ Current head dd58542 differs from pull request most recent head 26eef7b. Consider uploading reports for the commit 26eef7b to get more accurate results

@@             Coverage Diff             @@
##           gz-sim7    #1801      +/-   ##
===========================================
- Coverage    64.68%   64.61%   -0.07%     
===========================================
  Files          343      347       +4     
  Lines        27430    27731     +301     
===========================================
+ Hits         17743    17919     +176     
- Misses        9687     9812     +125     
Impacted Files Coverage Δ
include/gz/sim/ServerConfig.hh 100.00% <ø> (ø)
include/gz/sim/Util.hh 100.00% <ø> (ø)
...rc/systems/ackermann_steering/AckermannSteering.hh 100.00% <ø> (ø)
src/systems/joint_controller/JointController.hh 100.00% <ø> (ø)
...int_position_controller/JointPositionController.hh 100.00% <ø> (ø)
src/gui/plugins/component_inspector/Inertial.cc 11.76% <11.76%> (ø)
src/SdfGenerator.cc 90.33% <40.00%> (-0.62%) ⬇️
src/systems/apply_link_wrench/ApplyLinkWrench.cc 77.77% <46.15%> (ø)
...int_position_controller/JointPositionController.cc 74.13% <67.56%> (+0.56%) ⬆️
src/Util.cc 91.01% <71.42%> (-1.23%) ⬇️
... and 16 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

…l-sim-time-2

Signed-off-by: Joan Aguilar Mayans <joan@openrobotics.org>
Signed-off-by: Joan Aguilar Mayans <joan@openrobotics.org>
Signed-off-by: Joan Aguilar Mayans <joan@openrobotics.org>
@JoanAguilar
Copy link
Contributor Author

This now seems to be working fine on my machine for positive values. Negative values, on the other hand, result in a warning and the clock being reset to -1 ns every time the simulation is paused or reset:

Warning [World.cpp:139] [World] Attempting to set negative timestep. Ignoring this request because it can lead to undefined behavior.

Seeing that I couldn't find a World.cpp file or excerpts of the warning message in source, I assume that the warning (and the associated behavior) are not coming from Gazebo (DART?).


It also seems CI is not particularly happy with the changes. On my last try on my machine (Jammy) I only got one failing test: testFixture_TEST, with an error about not being able to import the python module gz.math7. Interestingly, all the Ubuntu CI jobs get other tests failing, but not this one...

Jobs:

@scpeters
Copy link
Member

scpeters commented Dec 1, 2022

This now seems to be working fine on my machine for positive values. Negative values, on the other hand, result in a warning and the clock being reset to -1 ns every time the simulation is paused or reset:

Warning [World.cpp:139] [World] Attempting to set negative timestep. Ignoring this request because it can lead to undefined behavior.

I think we shouldn't worry about supporting negative timestamps

Copy link
Contributor

@adityapande-1995 adityapande-1995 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to add some tests for this feature.

Signed-off-by: Aditya <aditya050995@gmail.com>
src/gz_TEST.cc Outdated Show resolved Hide resolved
Signed-off-by: Aditya <aditya050995@gmail.com>
@scpeters scpeters marked this pull request as ready for review January 7, 2023 00:19
@scpeters
Copy link
Member

scpeters commented Jan 7, 2023

I marked this as ready for review

@mjcarroll
Copy link
Contributor

LGTM with green CI

@scpeters
Copy link
Member

scpeters commented Mar 2, 2023

LGTM with green CI

some of the CI jobs are green, and those that aren't have unrelated failures. I will go ahead and merge

@scpeters scpeters merged commit 2127f35 into gz-sim7 Mar 2, 2023
@scpeters scpeters deleted the joanaguilar/initial-sim-time-2 branch March 2, 2023 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request 🌱 garden Ignition Garden
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants