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

fix clock speed in car mode #4305

Merged
merged 1 commit into from
Jan 31, 2022
Merged

fix clock speed in car mode #4305

merged 1 commit into from
Jan 31, 2022

Conversation

zimmy87
Copy link
Contributor

@zimmy87 zimmy87 commented Jan 20, 2022

Fixes: #4241
Fixes: #4232

About

The car mode currently utilizes a default clock for returning the CarState's timestamp, so the clock speed from the settings isn't reflected in the timestamp. This change adds logic for initializing the appropriate clock type from settings as well as logic for reading the timestamp from the newly initialized clock.

How Has This Been Tested?

The following script was used in car mode to confirm the clock was advancing at the proper clock speed. This script outputs the delta of the simulation clock after 1 real-world second elapses. If everything is working correctly, this script should output the same value as the ClockSpeed in the settings:

import setup_path 
import airsim

import pprint
import time

# connect to the AirSim simulator 
#client = airsim.MultirotorClient()
client = airsim.CarClient()
client.confirmConnection()
client.enableApiControl(True)

#prev = client.getMultirotorState().timestamp
prev = client.getCarState().timestamp
curr = prev
print(prev)
while True:
    #curr = client.getMultirotorState().timestamp
    curr = client.getCarState().timestamp
    delta = curr - prev
    prev = curr
    print(delta / 1000000000)
    time.sleep(1.0)

client.enableApiControl(False)

Screenshots (if appropriate):

@rhalaly
Copy link

rhalaly commented Jan 20, 2022

Does it also support pause and resume? If the simulation is paused for 10 seconds, will the timestamp be the same?

@jonyMarino jonyMarino merged commit 420808c into microsoft:master Jan 31, 2022
@jonyMarino
Copy link
Collaborator

jonyMarino commented Jan 31, 2022

Thanks @zimmy87 !!!

@zimmy87
Copy link
Contributor Author

zimmy87 commented Feb 1, 2022

Hi @rhalaly, thank you for taking a look at this PR. From testing locally with pause_continue_car.py, it looks like the new clock does respond to pause and resume commands correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

clockspeed seems doesn't work Wrong timestamp when using small ClockSpeed
3 participants