AirSim icon indicating copy to clipboard operation
AirSim copied to clipboard

continueForTime API is not accurate

Open hashikemu opened this issue 7 years ago • 1 comments

Hello, It is after a long time of post. I tried using AirSim for about half a year and found several problems. So I will report on the problem. I am using AirSim for my research and I use AirSim and MATLAB by integrating it by calling Pythonclient from MATLAB.

I found that AirSim 's continuefortime API is incorrect. This problem occurs in car mode. The biggest problem is that updates are done for longer than the specified time. We will update 0.01 seconds with simcontinuosfortime. Then, the difference between the moving distance obtained from the product of the speed and the step time and the difference between the previous position does not match. The verification script will be posted below.

import setup_path
import airsim

import time
import math


DELTA_T=0.01
#timerate=1.7

histTime=[0]
histVelocity=[0]
histPositionX=[0]
histPositionY=[0]
histPositionZ=[0]
calculatedStepDistFromVel=[0]
calculatedStepDistFromPosition=[0]

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

car_controls = airsim.CarControls()


client.simPause(True)


for i in range(1, 1500):
    car_controls.throttle = 1.0
    car_controls.steering = 0
    client.setCarControls(car_controls)

    client.simContinueForTime(DELTA_T)

    car_state = client.getCarState()
    #get position and velocity
    histTime.append(i*DELTA_T)
    #histTime.append(i*DELTA_T*timerate)
    histVelocity.append(car_state.speed)
    histPositionX.append(car_state.kinematics_estimated.position.x_val)
    histPositionY.append(car_state.kinematics_estimated.position.y_val)
    histPositionZ.append(car_state.kinematics_estimated.position.z_val)

    #calculate step distance form velocity and position
    calculatedStepDistFromVel.append(histVelocity[i]*DELTA_T)
    #calculatedStepDistFromVel.append(histVelocity[i]*DELTA_T/timerate)
    calculatedStepDistFromPosition.append(math.sqrt( \
         math.pow((histPositionX[i]-histPositionX[i-1]),2) \
        +math.pow((histPositionY[i]-histPositionY[i-1]),2) \
        +math.pow((histPositionZ[i]-histPositionZ[i-1]),2)))


print(sum(calculatedStepDistFromVel))
print(sum(calculatedStepDistFromPosition))
print(sum(calculatedStepDistFromVel)/sum(calculatedStepDistFromPosition))

When executed, the output result is as follows.

Connected!
Client Ver:1 (Min Req: 1), Server Ver:1 (Min Req: 1)

156.9931730871114
93.58373037297422
1.6775690866502262

The settings used in the program are as follows.

{
	"SeeDocsAt": "https://github.com/Microsoft/AirSim/blob/master/docs/settings.md", "SettingsVersion": 1.2, "SimMode": "Car",
	"ClockSpeed": 1.0,
	"ViewMode": "",
	"CameraDefaults": {
		"CaptureSettings":
		[
			{
				"ImageType": 0, "Width": 1024, "Height": 576, "FOV_Degrees": 90,
				"AutoExposureSpeed": 0, "AutoExposureBias": 0, "AutoExposureMaxBrightness": 2.00, "AutoExposureMinBrightness": 0.03,
				"MotionBlurAmount": 0, "TargetGamma": 1.5, "ProjectionMode": "", "OrthoWidth": 5.12
			},
			{
				"ImageType": 1, "Width": 512, "Height": 128, "FOV_Degrees": 100,
				"AutoExposureSpeed": 0, "AutoExposureBias": 0, "AutoExposureMaxBrightness": 2.00, "AutoExposureMinBrightness": 0.03,
				"MotionBlurAmount": 0, "TargetGamma": 1.5, "ProjectionMode": "", "OrthoWidth": 5.12
			}
		]
	},
	"SubWindows":
	[
		{"WindowID": 0, "ImageType": 0, "CameraName": "DCameraLeft", "Visible": false},
		{"WindowID": 1, "ImageType": 0, "CameraName": "DCameraFront", "Visible": false},
		{"WindowID": 2, "ImageType": 0, "CameraName": "ExtCamera", "Visible": false}
	],
	"Vehicles": {

"Car1": { "VehicleType": "PhysXCar", "X":1750.01, "Y":456.9992, "Z":0, "Pitch":0, "Roll":0, "Yaw":-4.5375
}

	}
}

This problem also occurs with a combination of simpause / time.sleep(python) or pause(MATLAB) / simpause. Another problem related to the pause API is that there is a problem that RPM slowly fluctuates during pause. This problem has been reported in #1584. Under such circumstances, it can not be used for strict physical simulation. In addition to this, I found a problem that speed and acceleration information takes a large value. This has been reported in #1501. We also found a problem that images at the same time do not match. This has been reported in #1494.

We will also report a different issue from the pause API. When I request images to AirSim, I found a problem that processing becomes extremely slow. When processing time is measured while acquiring images, nearly 80% of processing time is used for image acquisition. It is considered that improvement is necessary. This problem has already been reported by #1669 by other people, but I will report it again.

hashikemu avatar Jan 19 '19 10:01 hashikemu

This is likely fixed by #4385

zimmy87 avatar Mar 02 '22 16:03 zimmy87