Can not receive message ATTITUDE_QUATERNION using pymavlink

Currently I am attempting to acquire some general system information from an aircraft. I am using the pymavlink library in python to interact with copter. I have no issue receviing GPS and basic ATTITUDE information (Mentioned also in an issue post in github). However, when I attempt to filter for ATTITUDE_QUATERNION, I get nothing in return. My question is, do I need to enable a feature in MissionPlanner to obtain this additional information?

You will need to tell us what FW version you are using. But AFAIK ATTITUDE_QUATERNION is not yet implemented in ardupilot. You can test in ArduCopter 4.1.0-dev version though.
And you do need to request it with SET_MESSAGE_INTERVAL first.

ArduPilot can’t emit ATTITUDE_QUATERNION ATM.

You have a use case in mind for it?

It’s a relatively straight-forward patch but would need testing. I can
show you where to add the code in ArduPilot or you can test a patch I
make…

Yes, with this orientation we can apply it to formulas such as Poynting vector. I ask about the quaternion because there is ambiguity in pitch/roll/yaw. Are they taken with respect to local axes? If not, the order in which they’re applied matters - what is that order? There is no such ambiguity with quaternions.

I would gladly like to work with a patch. I have no problem with modifying the module if needed.

Curious, is it simply that such messages are not intercepted because of a feature within the common.xml not enabled? I saw a similar issue with Rust about certain messages not appearing.

I’ve created a PR (https://github.com/ArduPilot/ardupilot/pull/16798) which allows you to retrieve this message from the autopilot. You will need to request it using MAV_CMD_REQUEST_MESSAGE or MAV_CMD_SET_MESSAGE_INTERVAL.

I’ve only done minimal testing on it - its entirely possible it doesn’t actually give you back the correct roll/pitch/yaw :slight_smile: That’s why it has “NeedsTesting” on it…

1 Like

Oh I see this PR was for the ArduPilot and not for pymavlink. I am fairly new to the unmanned open source world. At this moment I would like to avoid modifying the copter’s FW (currently running on ArduCopter 4.0.3), and only tasked to parse raw information from the copter (GPS, attitude,…).

A work around is maybe to calculate the quaternion from the pymavlink library (post of function)

Lets say I have acquired the roll, pitch, and yaw from the messages and attempt to calculate the quaternion:

from pymavlink import quaternion

roll = -0.003070452716201544
pitch = -0.0003263792023062706
yaw = -1.6623866558074951
q = quaternion.QuaternionBase([roll, pitch, yaw])
>>> print(q)
[ 0.6739937  -0.00115529  0.00102414 -0.73873548]

If this is fine, I can be satisfied with this workaround.

ArduCopter 4.0.7 stable is out for quite some time now, and there are important critical bugfixes.
Software versions are NOT Port wine. They do not get better when they age, they get better when one updates them.

But apart from that small rant, yes, doing it in pymavlink is probably OK… :slight_smile:

Oh I see this PR was for the ArduPilot and not for pymavlink. I am fairly new to the unmanned open source world. At this moment I would like to avoid
modifying the copter’s FW (currently running on ArduCopter 4.0.3), and only tasked to parse raw information from the copter (GPS, attitude,…).

There are a few significant flaws with 4.0.3 - I suggest you read the
release notes for more recent stable releases and decide if they’re right
for you.

A work around is maybe to calculate the quaternion from the pymavlink library (post of function)

Sure, you can do that. But you can’t void the gimbal lock problem you
were concerned with that way.