-
Notifications
You must be signed in to change notification settings - Fork 993
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
Frame conversions #317
Frame conversions #317
Conversation
…correct frame conversion between ENU<->NED
return tf::Vector3(x, y, z); | ||
}; | ||
|
||
static tf::Vector3 convert_velocity(float _vx, float _vy, float _vz){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why have different functions that perform the same conversion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just naming types
6354923
to
8cd9fa7
Compare
I suggest that the naming should be changed to "transform_frame" and no need to make 5x copies of the same function, since we have the exact same conversion for all data from NED to ENU and back. |
Ok why not
This was just a naming convention, as we also have functions to convert attitude (rpy and q). Like this we can name different functions for different physical variables (position, velocity, acceleration, ...). If not, how to call it? I created a |
I don't see why you really need different function for each type. And if you use same conversion do one general func and call it in inlined pos, att etc. funcs. Also as i see, there no more difference between body and local? |
Ok i'll launch a general conversion function then. But as you say that there's no need to multiple functions to different types, i don't see why we have to say the direction since the conversion is exactly the same. The direction is marked on comments as you can see. From flight tests done by @BlackCoder, it seems that there's no need to differentiate local from body frames. Mocap and vision plugins already flight tested. Just have to be sure that imu plugin data corresponds to what is expect (which it should since the rotation matrix values correspond to the previous transformations applied to pitch and yaw values). As to ENU to NED conversions used on plugins, it's all good to go, since it was tested and confirmed using a mocap system. |
37d325e
to
41f22ee
Compare
Best documentation is the code itself. Commenting each entry worse, than two inlined ned_enu, enu_ned variants. |
And i see, that there difference in general and rpy. Why? |
Also a note, that those functions are best target for unit tests. Now test exist only for libmavconn, because most plugins require real FCU (at least SITL), write test for them little complex. |
I still can't find a use to tell the direction on the function name, as the conversion is exactly the same. |
Where did you find 7x7 covariance? geometry_msgs/PoseWithCovariance uses 6x6. |
Well 7x7 pose matrices exists and can be used. Check MRPT: http://www.mrpt.org/tutorials/programming/maths-and-geometry/2d_3d_geometry/#4_Conversions_between_classes. Quaternion covariance also exists. Check page 7 of this paper. So I assume a 7x7 covariance matrix can be built, even though ROS doesn't support it yet, but many applications may depend on a covariance matrix like this. The problem is that the propagation of covariance in quaternion representation is not so trivial. |
…on; general doxygen comment cleanup
fd511f0
to
a22439d
Compare
0cbb971
to
ef12e98
Compare
@@ -207,13 +206,12 @@ class IMUPubPlugin : public MavRosPlugin { | |||
|
|||
auto imu_msg = boost::make_shared<sensor_msgs::Imu>(); | |||
|
|||
// PX4 NED (w x y z) -> ROS ENU (x -y -z w) (body-fixed) | |||
tf::Quaternion orientation(att_q.q2, -att_q.q3, -att_q.q4, att_q.q1); | |||
tf::Quaternion orientation(att_q.q1, att_q.q2, att_q.q3, att_q.q4); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NO! You missed that FCU and ROS use different field convention.
It still should be orientation(q2, q3, q4, q1)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FCU: w x y z
ROS: x y z w
right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
magn_msg->magnetic_field.x = imu_hr.ymag * GAUSS_TO_TESLA; | ||
magn_msg->magnetic_field.y = imu_hr.xmag * GAUSS_TO_TESLA; | ||
magn_msg->magnetic_field.z = -imu_hr.zmag * GAUSS_TO_TESLA; | ||
auto mag_field = UAS::transform_frame_ned_enu_xyz(imu_hr.xmag, imu_hr.ymag, imu_hr.zmag); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There bee GAUSS units, not milliTESLA.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it
Finally, after some tinkering with @BlackCoder, we were able to get to the proper conversions to position and orientation between ROS ENU and PX4 NED frames.
So, as this is a common code for many plugins, I decided to create a specific lib file where all the functions for frame conversions are installed. This functions are called by the plugins to do the conversions online.
ADD: This PR also updates some comments and doxygen documentation on plugins.
Right now, I think I'm just missing:
uas_frame_conversions.cpp
(partially)Update: Relative to covariance conversions, I'm still missing:
transform_frame_covariance_pose6x6()
can also be used to other covariances matrices, (p.e., lin_vel + RPY, ang_vel+RPY, and why not position+lin_vel since the conversion is the same - not very used)Update2: I will leave the above covariances conversions to another PR.
This PR Fix #194, #148 (please continue list).