-
Notifications
You must be signed in to change notification settings - Fork 18
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
Orientation does not seem correct #7
Comments
Hi Chris I'd just like to verify that the way you're constructing the quaternion is correct: according to the documentation (http://docs.ros.org/en/jade/api/tf2/html/classtf2_1_1Quaternion.html#a4c9249826320a3aa30e88a11fc75e577), the constructor looks like:
Therefore, for your example, I would have expected the appropriate quaternion to be:
Since rotation orders are not likely to be an issue for your simple example, I shall not go into that right now. The only other thing I noticed, upon looking at the documentation and source code for tf2 (as I'm not familiar with it), is that Let me know if you need further assistance. Thanks Llyr ` |
Hi Chris Scratch that last reply - I subsequently looked over your screenshot and realized you are indeed constructing the quaternion correctly! Let me investigate further. Thanks Llyr |
Hi Chris I've gone through the conversion code (here), and what's going on is:
So I can at least confirm that we are outputting orientations in the ENU body frame. From reading the tf2 documentation, I'm not exactly sure that Step 2 above actually does what we think it should do. I'm surprised as we've been using the NCOM driver extensively for development - maybe there are two bugs cancelling each other out in our case but not in yours. I will investigate further and come back to you. Thanks Llyr |
Hi Chris I'm now relatively sure it's to do with the order in which rotations are applied, and I suspect this happens at multiple steps (including how you get the Euler angles back from the resultant quaternion). To help me further diagnose, would it be possible for you to give me the following:
This way, I can construct some unit tests to see where things are going wrong. Thanks Llyr |
Hi Chris Seeing as you're using a rosbag, perhaps what I'm suggesting won't work (in addition, we're also looking at different reference frames as NAVdisplay displays orientations in the vehicle frame). Thanks for the configuration, that'll hopefully help. I suggest a trial-and-error method to fixing this, as I unfortunately don't have much test data to hand as I'm currently remoting in from home. I've just pushed two commits to the branch I suspect there is at least one further fix to transform to ENU, but I'd like us to get at least some sensible readings in NED first before trying to solve the next problem. Thanks Llyr |
Hi Chris Just so I can elaborate on what I think is going wrong: In the OxTS ecosystem, all of our orientations follow the heading-pitch-roll convention, in such a way that the resultant orientation is the result of the following rotations:
From comparing the code in tf2 with some reference material on quaternions, I've worked out that tf2's functionality actually performs these rotations in the opposite order, i.e.:
Since rotations are not (in general) commutative, these two will yield different quaternions; this, I suspect is the root of our problem. We do also have the additional complexity of everything in the OxTS ecosystem being in a North-East-Down (NED) frame, whereas ROS works in an East-North-Up (ENU) frame. We get around this by multiplying by the following quaternion:
This is equivalent to multiplication by the following basis-vector transformation matrix:
The commits I pushed address the first issue by replacing calls to Regards Llyr |
FYI, this line causes a build error. Should be "/*"
|
Hi Chris Thanks for the feedback. I've been thinking it over and I think I'll need to dig around for a test data set that most closely resembles your setup (in particular, your INS is pointing upwards which, from memory, is potentially a gimbal lock so I'm wondering if that's what's significantly different). I'll inform you when I find something. Thanks Llyr |
Hi Chris I believe I may have misinterpreted your original question: "Can you confirm that the orientation contained in the ins/imu and ins/odometry topics is always reported in the ENU frame regardless of how the unit is physically oriented in the vehicle?" The answer here is no - the orientation contained in the However, your example has a particular issue: namely, the VAT transformation induces a gimbal lock configuration (which occurs, for the OxTS system, when pitch is +/-90 degrees). Since the configuration is (HPR) (0, 90, 0), its inverse is naturally (0, -90, 0), which also is a gimbal lock configuration. This means that applying this transformation creates a situation whereby the resultant rotation is not numerically stable (the giveaway in your example is the resultant quaternion having its real component
Plugging this back into the rotation matrix equation, we get:
So we get a pitch angle of 90, as you've found. However, this is a gimbal lock scenario, where the heading and roll do not have unique solutions (but are instead related - see my subsequent pose - so there are infinitely many solutions), hence my comment above about being numerically unstable. I still think we've found an issue with rotation orders, but this does not apply to your example for two reasons:
In terms of you getting some angles you can work with: since the above does not have a stable solution, multiplying by the VAT matrix will likely also lead to an unstable result. Hence, I would advise that you remove the conversion in the first place, by editing line 87 of This will give you what you need. I'm also fairly sure we'll need a different function to do the angle conversion as that will be in the wrong order again (which doesn't matter in your example, but will matter as soon as you introduce non-zero pitch and/or roll). In the meantime, I will raise this matter internally to see if we can have a better solution (such as adding a configuration option to govern the body/vehicle frame output), and to fix the underlying issues with rotation orders. |
Hi Chris I've just been examining the rotation matrices and I think everything looks fine except the function which recovers the angles from the quaternion. I'm basing all of this on the The following code uses the rotation matrix to compute the angles (two solutions):
I've used your example, and this is what I got:
Let's break this down, piece by piece: since we already know the pitch is expected to be +/- 90 degrees, we're in a situation where we have a singularity, so the roll and yaw angles are related. Thus, we must set one of them to zero and compute the other (for completeness, I've put in both solutions). Going back to our original
The final step is to convert NED to ENU - while a rotation matrix would suffice, it is more straightforward to model this in terms of a basis vector transformation which sends
Plugging them back into the equations, and following the algorithm above:
Which matches the results from the quaternion above:
Hopefully, this all makes sense. Feel free to use the function above in your own code to get sensible angles from your quaternions. Please let me know if you have any further questions. Thanks Llyr |
Hi Llyr, I had to put this task aside to complete some other work, but am now ready to return to it. Thanks for your detailed posts. I appreciate the thorough explanations. Unfortunately, I'm still confused. The two possible solutions you propose in your previous post seem to be in the FRD/NED frames. Solution 1 only makes sense to me in that context: there is no roll, pitch = 90 solely due to how the sensor is mounted in the vehicle (sensor x-axis pointing down), and heading = 180 in the NED frame because the vehicle is pointing south. What's confusing me here is that you talked about converting from NED to ENU in your previous post, but this solution only makes sense to me in the NED frame. I can't make sense of these values in the ENU frame, so it doesn't seem like that conversion has taken place. Some additional quesitons:
Thanks, |
Hi Chris Thanks for your reply. Just wanted to let you know I've read your reply and am working on addressing your questions. I will reply with more detail once I've had a chance to work through it. Thanks Llyr |
Hi Chris Ok, I've gone through the example again, with a couple of corrections to misconceptions I have since been corrected on - for example, there is no concept of intrinsic vs. extrinsic rotations here, so we do not have to apply inverses. I also believe I got the Vehicle-to-IMU matrix incorrect - it should correspond to a rotation of 90 degrees in pitch:
The orientation matrix of the vehicle, expressed in the vehicle frame (FRD), is:
This can be seen as the rotation matrix where a heading of 180 degrees is applied ( Transforming this matrix into the body frame, we get:
Applying the angle-recovery algorithm above, we find that:
This leads to the second misconception that I had - these angles correspond to the transformation from the local navigation (NED) frame to the body/IMU frame (FRD). Let's use your "due south" example - so we would expect a unit-scale velocity, in the local navigation frame, to be:
This makes sense, as it is a purely forward velocity in the vehicle frame. In the body/IMU frame, we have:
So as far as the IMU is concerned, this is a downwards motion, which again makes sense in relation to the configuration. So far, we have only dealt in the NED frame. In the ENU frame, we apply the change-of-basis NED -> EN(-D):
Again, applying the angle recovery formulae:
To convince ourselves that this indeed does make sense, we again use our "pure south" example:
In an FLU vehicle frame, this again makes sense. This covers the rotation matrices. I've had a look at the quaternions and they also check out:
Reversing the
Thus, when we compare the angles of
In the body/IMU frame, these do indeed make sense. To get sensible angles in vehicle frame, what you actually need to do is three-fold:
To illustrate, we start with the
So far, so good: this maps Forward to South, Right to West and Down to Down. Recovering angles of this matrix gives:
Which is exactly what we would expect, given our discussion above, in the NED frame. In the ENU frame, the only way I've been able to get this to work properly is by treating the NED frame as being synonymous with the (body) FLU frame, and then simply doing a conversion from FLU to ENU:
Recovering angles of
Which gives us the angles we would expect from a due south orientation. I think the reason why this trick works is that the matrix I'm using to left-multiply above is the change-of-basis matrix to go from a FRU frame to an ENU frame. I have spent hours deriving the calculations, and trying different ways of going from NED/ENU and this is the only one which gives us an answer that makes sense. Thanks Llyr |
I suspect that even the example is incorrect. I'm on version
The |
I'm suspecting that there is no issue with the orientation after all. It's possibly just a visualization issue. The odometry visualized in rviz is based on the pose (https://docs.ros2.org/foxy/api/nav_msgs/msg/Odometry.html), not the direction of movement. The arrow would point forward in the driving direction of the robot if the robot's |
Hi,
All of the output from the ROS2 driver now looks correct; however, I cannot correctly translate the published orientation reported in the ins/imu and ins/odometry topics to roll, pitch, yaw in a way that makes sense.
The test I conducted was driving the vehicle at a slow speed due south. There was little vehicle roll or pitch. Given that ENU frame is being used, I would therefore expect to see the following:
Roll ~ 0 degrees
Pitch ~ 0 degrees
Yaw ~ -90 degrees
You can see what the actual reported orientation looked like when I conducted this test in the bottom right section of this image.
As you can see the values are approximately:
x = - 0.5
y, z, w = 0.5
If I convert these quaternion values into RPY
the following is printed to the console:
[lv_ground_truth_republisher-1] [INFO] [1641239122.213901124] [lv_ground_truth_republisher]: r:0.00 p:1.57 y:0.00
As you can see, Pitch is equal to 90 degrees, and roll and yaw are zero.
Can you confirm that the orientation contained in the ins/imu and ins/odometry topics is always reported in the ENU frame regardless of how the unit is physically oriented in the vehicle? In other words, a coordinate transformation from the ins frame to base_link should not be necessary for orientation, unlike velocity or acceleration values, which do require a coordinate transformation (when the ins frame and base_link frames are not aligned).
I've also confirmed the reference heading is zero-ed in the ins/nav_sat_ref topic.
The text was updated successfully, but these errors were encountered: