Skip to content

data mismatch between simGetVehiclePose() and simSetVehiclePose() #1246

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

Closed
husha1993 opened this issue Jul 14, 2018 · 28 comments · Fixed by #3363
Closed

data mismatch between simGetVehiclePose() and simSetVehiclePose() #1246

husha1993 opened this issue Jul 14, 2018 · 28 comments · Fixed by #3363

Comments

@husha1993
Copy link

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}

@thias15
Copy link
Contributor

thias15 commented Jul 16, 2018

Looks like you add 10 in the line "currentposition.z_val+stepsize[2]" in which case there is no mismatch.

@husha1993
Copy link
Author

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()...

@husha1993
Copy link
Author

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}

@Gotfeurdom
Copy link

Gotfeurdom commented Jul 23, 2018

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

@husha1993
Copy link
Author

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

@Gotfeurdom
Copy link

Gotfeurdom commented Jul 24, 2018

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

@husha1993
Copy link
Author

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.

@Gotfeurdom
Copy link

Gotfeurdom commented Jul 24, 2018

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

@husha1993
Copy link
Author

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.

@Gotfeurdom
Copy link

Gotfeurdom commented Jul 24, 2018

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)

@husha1993
Copy link
Author

"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.

@Gotfeurdom
Copy link

Gotfeurdom commented Jul 25, 2018

"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

@husha1993
Copy link
Author

"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".

@Gotfeurdom
Copy link

We can argue all we want, this still doesn't solve my problem ...

@husha1993
Copy link
Author

"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.

@Gotfeurdom
Copy link

Gotfeurdom commented Jul 25, 2018

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

@husha1993
Copy link
Author

"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?

@Gotfeurdom
Copy link

Gotfeurdom commented Jul 26, 2018

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

@husha1993
Copy link
Author

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?

@Gotfeurdom
Copy link

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

@husha1993
Copy link
Author

"learn something from the surrounding of point B ",
in this case, the agent in point B is controlled in low level;
'get to point B from point A instantly', then the agent from A to B is controlled in high level.
The above is what I referred as contradictory.

Actually, what your project want the airsim to do is to switch between "car"/"multirotor" mode and "computer vision" mode after click the playing button;
While airsim currently seems cannot handle the mode switching during game play:
https://github.com/Microsoft/AirSim/blob/master/docs/settings.md#simmode

@Hoshea7
Copy link

Hoshea7 commented Jul 20, 2019

Hi @Gotfeurdom,

have you find any solutions to reset the position after each episode learning?

@Gotfeurdom
Copy link

Hi @Gotfeurdom,

have you find any solutions to reset the position after each episode learning?

Hi
No since I've abandoned that simulator since I had the issue.
Also I'm not sure but I think I read somewhere that they finally implemented it

@dimikout3
Copy link

I have also noticed the same problem in using moveToPositionAsync() and simGetVehiclePose.position. Initially I am sending a multicopter to position (10, 0, -10) and then I retrieve the position using the simGetVehiclePose.position values (for x,y,z coordinates) the result is (x=15.57, y=15.55, z=-9.99). I have also noticed the same problem in other positions. I think that this is a huge bug ... Am I missing anything ?

@dimikout3
Copy link

Same error occurs if I use client.getMultirotorState().kinematics_estimated.position. This make sence since both getMultirotorState() and simGetVehiclePose() use the same function in airsim/types.py

@msb336
Copy link
Contributor

msb336 commented Oct 3, 2019

@dimikout3
moveToPositionAsync() is somewhat unreliable, as the controller converges upon some non-zero steady-state error. The coordinates that you are getting from getMultirotorState and simGetVehiclePose are ground truth, and the difference between your input goal position and your ground truth state represents the steady-state error in SimpleFlight's controller.

@rajat2004
Copy link
Contributor

Came across this issue while adding docstrings for all APIs
simSetVehiclePose() seems to work when using Multirotor also. See teleport.py for example

@madratman madratman removed the binary label Aug 6, 2020
@jonyMarino
Copy link
Collaborator

Closed due to age.
Please feel free to open a new issue (refering this one) if you still have this problem, and include the following (as requested when opening a bug issue)

*Make sure to write all reproduction steps
*Include full error message in text form
*Search issues for error message before filing issue
*Attach screenshot if applicable
*Include code to run if applicable

Thanks!

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