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

init.d-posix: support running SITL slower #12259

Closed
wants to merge 4 commits into from
Closed

Conversation

julianoes
Copy link
Contributor

This enables using a rational number for PX4_SIM_SPEED_FACTOR.
This is required if the simulation is run slower than realtime, for instance 0.5 to simulate at half the speed.

Since bash can't natively do floating point arithmetic, we need to use bc.

Please use PX4 Discuss or Slack to align on pull requests if necessary. You can then open draft pull requests to get early feedback.

This enables using a rational number for PX4_SIM_SPEED_FACTOR.
This is required if the simulation is run slower than realtime, for
instance 0.5 to simulate at half the speed.

Since bash can't natively do floating point arithmetic, we need to use
bc.
@julianoes julianoes requested a review from bkueng June 13, 2019 15:23
@dagar
Copy link
Member

dagar commented Jun 13, 2019

@julianoes
Copy link
Contributor Author

@dagar ok, so we just can't do it given the shellcheck. I suppose the possible solutions are:

  1. Set the variable in a script outside the startup script.
  2. Add a systemcmd that can multiply floating point 😄
  3. Use the actual (not fake) system time for RC and datalink lost checks.

I tend towards number 3 since that's the proper fix.

When the simulation runs faster than realtime we need to relax the
timeout checks. This was done using this hack to change the timeout
parameters. In subsequent commits we will fix this properly by using the
correct time source when checking timeouts of external messages.
When the simulation is running faster than realtime we sometimes need to
use the actual host/environment time. This is for instance required to
check for timeouts on external messages.
Heartbeats arriving are sent at a rate based on the normal
system/environment time and not at the PX4 time which might run faster
or slower in SITL.

Therefore, we need to use the environment time when checking for
timeouts of the heartbeats.
@julianoes
Copy link
Contributor Author

I went ahead with number 3.

@dagar
Copy link
Member

dagar commented Jun 15, 2019

I'm not sure how I feel about making commander aware of what's really happening like this.

@dagar
Copy link
Member

dagar commented Jun 15, 2019

Taking a step back I'm starting to think we'd specifically want these things interpreted in the vehicles reference timeframe (testing failsafes, etc).

@julianoes
Copy link
Contributor Author

@dagar so we change the params as I suggested initially in this PR?

@julianoes
Copy link
Contributor Author

Fixed by #12401.

@julianoes julianoes closed this Jul 3, 2019
@julianoes julianoes deleted the fix-lockstep-slower branch July 3, 2019 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants