Skip to content
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

Clarification: Home Position Q #1839

Closed
flybrianfly opened this issue May 9, 2022 · 2 comments · Fixed by #1843
Closed

Clarification: Home Position Q #1839

flybrianfly opened this issue May 9, 2022 · 2 comments · Fixed by #1843

Comments

@flybrianfly
Copy link

I'm writing code for my MAVLink library for my company's flight stack to send the home position when the vehicle is armed. This is actually to facilitate a companion path planning computer to know the origin of the NED frame to convert mission items from a global to a local NED frame.

The home position message specifies q as a normal vector perpendicular to the surface and aligned with the heading. This makes sense and I assume that q is a quaternion. Is there more information or an example for how q should be computed? Of course quaternions can come in multiple orders (i.e. rotation first, rotation last, etc), so I think a little more clarity would help with general applicability of this message across flight stacks.

Also the approach_x, approach_y, and approach_z variables are a little confusing and seem to imply that for a fixed-wing aircraft, takeoff and landing should happen in opposite directions? Which doesn't make sense to me.

@hamishwillee
Copy link
Collaborator

Hi @flybrianfly

Yes, q is a quaternion, but I don't know how it should work "for certain".

HOME_POSITION used to be set SET_HOME_POSITION which would allow you to set q directly. That is deprecated but is now set using MAV_CMD_DO_SET_HOME which does not have the quaternion. Further, in some flight stacks the home position is stored in a slot for the first mission item as a waypoint, and that does not have a quaternion. Upshot, possibly you cannot set it directly.

The implementation in PX4 is here: https://github.com/PX4/PX4-Autopilot/blob/master/src/modules/mavlink/streams/HOME_POSITION.hpp

matrix::Quatf q(matrix::Eulerf(0.f, 0.f, home.yaw));
q.copyTo(msg.q);

msg.approach_x = 0.f;
msg.approach_y = 0.f;
msg.approach_z = 0.f;

ArduPilot sets it to [1,0,0,0] here: https://github.com/ArduPilot/ardupilot/blob/master/libraries/GCS_MAVLink/GCS_Common.cpp#L2495

const float q[4] = {1.0f, 0.0f, 0.0f, 0.0f};

I don't understand quaternions. To me that means the value is unreliable and should probably be deprecated. I'll see if I can get a better answer.

@auturgy @julianoes If you have any thoughts on this, I'd appreciate them!

@hamishwillee
Copy link
Collaborator

Discussed in the MAV call. First shot at addressing it: #1843

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

Successfully merging a pull request may close this issue.

2 participants