Rotation matrix to convert AirSim local coordinates to global coordinates #4283
Replies: 18 comments
-
Hi @AngelTang190 , Things are slightly simpler when it comes to GPS points though. You specify where exactly you want your drone to spawn (X, Y and Z) within the map in settings.json (or in the Unreal Editor by moving In general, if you are trying to line up the map's North and AirSim's North visually, you might need to do that from within the environment itself. In the test below I used Droneshell to move the drone in the x-direction and it corresponded to motion in the north direction from where my OriginGeopoint/spawn-point was |
Beta Was this translation helpful? Give feedback.
-
May I know how can I know the orientation of AirSim environment? Is there an API that I can use ? |
Beta Was this translation helpful? Give feedback.
-
@AngelTang190 the getMultirotorstate and/or simGetGroundTruthKinematics APIs would provide the orientation in quaternions |
Beta Was this translation helpful? Give feedback.
-
Can you please give an example? As in when an orientation has a x value of 0 initially, what does it mean? |
Beta Was this translation helpful? Give feedback.
-
@AngelTang190 a yaw orientation of 0 means that the front of the vehicle is aligned with the World's/environment's x axis. Note that the multirotor state produces orientations in quaternions (for conversion see this) Here's an example that should clarify everything: Lets say we have a blank unreal engine environment/level: This environment would have a set of x,y and z axes that start from a point (the world origin). I'll represent the environment's top view in my diagrams with this grid: Now, when u place the AirSim plugin into the Unreal Engine project, the x-axis is considered north (keep in mind that there is no map or anything here yet, its just an empty environment, and north is just relative to the environment's coordinate system):
your drone spawn point will be set to the coordinates you enter): Again, this is all without having anything related to 'real earth' in our environment. Now, since the angle between the forward direction of the drone (the blue arrow below) and the world's x axis is 0. Your yaw value would be 0 and your orientation in quaternions would be [ 0, 0, 0, 1 ]. If the drone is spawned at an angle (pitch, yaw or roll): Now this behavior should not change regardless of what we place in the environment. For example, if I place assets in the UE environment that represents a particular area on earth but these assets/map-items are not alligned with the world coordinate system: Hope this clarifies things. I might be mistaken in how exactly the aligning works within UE but this is how my understanding of it is. |
Beta Was this translation helpful? Give feedback.
-
Alright, thank you very much! So let's say if the yaw is 0, then the rotation matrix will just be the identity matrix correct? |
Beta Was this translation helpful? Give feedback.
-
@AngelTang190 if you're refering to a 2D rotation matrix about the Z axis then yes. But if you're talking about an overall 3D rotation matrix then pitch and roll would have to be taken into consideration |
Beta Was this translation helpful? Give feedback.
-
For 3D rotation matrix, should pitch also be aligned with the North? Then which direction should roll be aligned to? |
Beta Was this translation helpful? Give feedback.
-
Pitch would be measured based on the horizon or the vehicle being upright. Same thing with roll. They would both be relative to the drone's upright orientation |
Beta Was this translation helpful? Give feedback.
-
May I know what does upright mean here? |
Beta Was this translation helpful? Give feedback.
-
I am currently using AirSim together with the Cesium for Unreal plugin. Cesium puts a real world map into the Unreal project. I used the same coordinates for the georeference origin in AirSim and Cesium. This works, the drone shows at the correct position and GPS data (PX4 SITL) is correct. But when I fly into any directions - they don't line up. I am a bit lost where I would configure that. Any hints? |
Beta Was this translation helpful? Give feedback.
-
@petergerten by 'they don't line up' do you mean there's an angle offset? or is it a distance offset? |
Beta Was this translation helpful? Give feedback.
-
@ahmed-elsaharti I need to evaluate it more closely. But it seems distance is correct but when I fly south in the airsim real-world environment - my GPS coordinates in AirSim/PX4 go east. |
Beta Was this translation helpful? Give feedback.
-
@petergerten hmmm, that probably is just a difference in rotation between airsims and cesiums coordinate systems (or atleast i hope its just that). Try rotating the playerstart object within the environment and see if that fixes things. I haven't tested cesium out yet... But this is very interesting |
Beta Was this translation helpful? Give feedback.
-
@ahmed-elsaharti I tried to change the rotation of player start - but it does not seem to have an impact on the world rotation. |
Beta Was this translation helpful? Give feedback.
-
ok, after rotating the Cesium World Terrain 90 degrees - everything lines up :) |
Beta Was this translation helpful? Give feedback.
-
@ahmed-elsaharti @petergerten I am trying to do a similar thing but linking the Cesium Georeference longitude and latitude to the AirSim OriginGeopoint settings so that the point in the planet can be configured. Do you know how this can be accomplished? |
Beta Was this translation helpful? Give feedback.
-
I know this issue is a bit old, but I am encountering a similar problem. |
Beta Was this translation helpful? Give feedback.
-
Question
What's your question?
Is there a rotation matrix to convert local AirSim coordinates to global coordinates and vice versa?
Include context on what you are trying to achieve
N/A
Context details
This question is only applicable to AirSim version only.
Include details of what you already did to find answers
I tried to search online about what is the rotation matrix to convert between AirSim coordinates and global coordinates, but I couldn't find any, seems like it needs to compare the direction of AirSim and the Earth. For example, the North of AirSim may be different from the True North (which is the Earth's North), so the rotation matrix synchronizes both the North, but I'm not sure about this. Can anyone please help? Thank you!
Beta Was this translation helpful? Give feedback.
All reactions