data mismatch between simGetVehiclePose() and simSetVehiclePose()
stepsize= [0,0,10] airsim_client.simSetVehiclePose(airsim.Pose(airsim.Vector3r(currentposition.x_val+ stepsize[0], currentposition.y_val+stepsize[1], currentposition.z_val+stepsize[2]), airsim.to_quaternion(0, 0, 20)), True) currentposition.x_val+ stepsize[0] 3.0517577442878974e-07 currentposition.y_val+stepsize[1] 0.0 currentposition.z_val+stepsize[2] 21.820711135864258 currentposition = airsim_client.simGetVehiclePose().position print(currentposition)
{ 'x_val': 3.0517577442878974e-07, 'y_val': 0.0, 'z_val': 11.820711135864258}
Looks like you add 10 in the line "currentposition.z_val+stepsize[2]" in which case there is no mismatch.
stepsize= [0,0,10] airsim_client.simSetVehiclePose(airsim.Pose(airsim.Vector3r(currentposition.x_val+ stepsize[0], currentposition.y_val+stepsize[1], currentposition.z_val+stepsize[2]), airsim.to_quaternion(0, 0, 20)), True) currentposition.x_val+ stepsize[0] 3.0517577442878974e-07 currentposition.y_val+stepsize[1] 0.0 currentposition.z_val+stepsize[2] 21.820711135864258 #currentposition.z_val+stepsize[2] 21.820711135864258 is what i set the new position by simSetVehiclePose currentposition = airsim_client.simGetVehiclePose().position print(currentposition) { 'x_val': 3.0517577442878974e-07, 'y_val': 0.0, 'z_val': 11.820711135864258}
'z_val': 11.820711135864258 is the new current position obtained by simGetVehiclePose() after i set the new position
thus there is mismatch between simSetVehiclePose() and simGetVehiclePose()...
stepsize= [0,0,10] airsim_client.simSetVehiclePose(airsim.Pose(airsim.Vector3r(currentposition.x_val+ stepsize[0], currentposition.y_val+stepsize[1], currentposition.z_val+stepsize[2]), airsim.to_quaternion(0, 0, 20)), True) currentposition.x_val+ stepsize[0] 3.0517577442878974e-07 currentposition.y_val+stepsize[1] 0.0 currentposition.z_val+stepsize[2] 21.820711135864258 #currentposition.z_val+stepsize[2] 21.820711135864258 is what i set the new position by simSetVehiclePose currentposition = airsim_client.simGetVehiclePose().position print(currentposition) { 'x_val': 3.0517577442878974e-07, 'y_val': 0.0, 'z_val': 11.820711135864258}
if there is no mismatch, currentposition = airsim_client.simGetVehiclePose().position print(currentposition) should be { 'x_val': 3.0517577442878974e-07, 'y_val': 0.0, 'z_val': 21.820711135864258} rather than print(currentposition) { 'x_val': 3.0517577442878974e-07, 'y_val': 0.0, 'z_val': 11.820711135864258}
Try using -10 instead of 10 A value of 10 means your vehicle will be 10m below its current position, which might put it back to its original position if there was a collision or something
If that works, tell me if you manage to still control your vehicle afterward and if it's a car or copter. When I use setVehiclePose I cannot control anything anymore and I'm stuck at the moment
Hi,
It seems that setVehiclePose only works in computer vision mode, maybe you can check if you have set to 'computer vision mode' in setting.json file. refer to: https://github.com/Microsoft/AirSim/blob/master/docs/image_apis.md#setting-pose-in-computer-vision-mode
My mode is set to default (I have to pick between car and copter when I launch the simulation) I'm baffled by the lack of documentation ... nowhere does it say simSetVehiclePose only works in CV mode nor how it actually works.
Where can I find its implementation in the source code ? I tried to browse it a bit but I'm lost as there is no comment blocs explaining each files
Should I just stop using AirSim and find an other simulator ? I've lost so much time over some stupid issues like that, that I doubt I will be able to finish my work in time
May I know why you use simSetVehiclePose?
If you want to move the car or copter and simulate the physics of the vehicle, you may try the move* api. refer to:
https://github.com/Microsoft/AirSim/blob/master/docs/apis.md#apis-for-multirotor
If you want to move the camera but don't want to simulate the physics of the vehicle, you can set the mode to computer vision and use the setVehiclePose api. Also, you can try https://unrealcv.org/.
I didn't try to browse the source code, so I don't know how the move* or set* is implemented.
I'm using airsim, I think it's currently the simulator who can both integrate diverse visual environments and do complex physical simulation. For other simulators, they are either limited by the number of visual environments or lack of real physical simulation.
Because I don't want to wait forever to put my drone in a specific position ? I'm trying to use AirSim for a reinforcement learning project (which I believe AirSim was built for) ... not flying around for fun, so I need some specific functionalities to automatize my learning
Also I use coordinates to navigate on my heightmap and I'm forced to put my playerstart position at (0,0,0) in unreal, because any starting position in AirSim is considered to be (0,0,0) and therefore there is only one starting position that gives me the true coordinates. Also if my (0,0,0) starting position is blocked, I cannot even use a regular flight to get to a specific position I just want to teleport to wherever I want and start whatever I'm trying to do from there
I truly liked how AirSim was presented on some youtube videos and I really thought it would be a walk in the park to use it effectively, but the lack of documentation and help I'm getting is driving me crazy
for the transformation of position from unreal engine to airsim: https://github.com/Microsoft/AirSim/blob/master/docs/apis.md#coordinate-system
Thus, it seems that there is no need to put your playerstart position at (0,0,0) in unreal if you wan to move the agent with airsim api to any position specified in unreal.
You don't understand
Wherever I place my starting position in unreal, the starting position in AirSim (from simGetVehiclePose for example) will always be (0,0,0) at the start of the simulation and future calls on simGetVehiclePose will always give a set of coordinates relative to that starting position, which is only correct if my starting position in Unreal is (0,0,0) as well. Therefore there is an offset on simGetVehiclePose that I don't have access to (at least using AirSim API and I don't know any way to access it as I'm totally new to unreal)
"Therefore there is an offset on simGetVehiclePose that I don't have access to"
The offset between position representation in unreal and airsim will always keep the same: Pu (xu, yu, zu)- Pa(xa, ya, za) = constant Pu/Pa is the representation of a world 3dposition in unreal coordinate/ airsim coordinate.
Thus you can access to the offset as long as you know your start position in unreal. And the offset is just the start position in unreal.
"Thus you can access to the offset as long as you know your start position in unreal" I'm not using a simulator/a computer to have to manually set some constants every time I want to change the scene ... Is there a variable I can access using only my python code to get the true value of the position in unreal and if so, how ?
Anyway this isn't even a big problem, as I need that "teleport" function anyway and I could easily use it to set my offset right
"I'm not using a simulator/a computer to have to manually set some constants every time I want to change the scene ..." "Is there a variable I can access using only my python code to get the true value of the position in unreal and if so, how ?"
The simulator shouldn't take the responsibility for constructing the scenes, I think this design of airsim is reasonable. But it should take the job for wrapping and reading the scenes constructed by the users who want to test the RL algorithms in the scenes they constructed.
Thus, the offset is something that you already know before run airsim when you construct you scenes. And when you run the agent of airsim, read the offset, and tell the agent its start position in unreal. That is "reading the scenes".
We can argue all we want, this still doesn't solve my problem ...
"Because I don't want to wait forever to put my drone in a specific position ?" Have you tried the move* api? eg: client.moveToPositionAsync(-10, 10, -10, 5).join() ?
I'm trying to understand what you want to do with airsim, and according to my understanding, airsim can do what you want.
It's pretty simple. I want my vehicle to INSTANTLY get to the position I want. (and it would be even better if I can set it to the STATE I want (position, orientation and speed).
The usage is pretty irrelevant but there it is : I want to build a reinforcement learning algorithm to control the vehicle using client.moveByAngleThrottleAsync(pitch, roll, throttle, yaw_rate, duration) For my algorithm to generalize my solution, I need to put it in random starting positions, or replay from some known positions
The move functions only control the vehicle to reach a destination, which takes some time and is definitely not what I want
"replay from some known positions"
Can you move the agent to some known positions with airsim move and pretend the drone restarts from this position, rather than really disconnet the airsim client and restart the game?
Using move would be extremely ineffective so no, I can't pretend and use it So there is no point trying to find a trick, I wouldn't use it I really need to put my vehicle instantly to a given state
Also by replay I don't mean disconnect everything to restart I mean get to a given state (teleportation) from my replay memory and continue playing from there
Learning to control the vehicle in low level action spaces with moveByAngleThrottleAsync and put the vehicle instantly to a given state, I feel the two demands are kind of contradictory.
Have you find any other simulator that can satisfy your project?
How are these contradictory ? These two functions would be for totally different purpose
Why would I need to wait to get to point B from point A if I only need to learn something from the surrounding of point B ?
Just because you can pick your nose with your fingers doesn't mean you can't use them for an other purpose