NiVO / BY TECHNOGISGermany · Indonesia
Flight data workflows

MAVLink Quaternion Component Order: A Drone Log Review Tutorial

Check scalar-first MAVLink attitude values before importing drone logs into SciPy, with explicit frame, validity and display-offset review steps.

MAVLink Quaternion Component Order: A Drone Log Review Tutorial

Identify the message before reading four numbers

A drone log export can contain four adjacent attitude values without preserving the explanation that makes them useful. A spreadsheet column called quaternion is especially easy to pass between tools as an ordinary array. For a NiVO integration or survey handoff review, begin with the original message identity and export schema. Establish whether the record actually comes from MAVLink ATTITUDE_QUATERNION, another message, or a vendor-defined representation. This tutorial concerns the first case and a read-only analysis workflow. It does not establish which messages a particular NiVO aircraft records or recommend changing flight-controller parameters.

Keep the accepted log unchanged and make a separate analysis copy. Record the exporter, its version, selected fields, timestamp definition and any transformations it performs. Preserve system and component identifiers when available so that records from different senders cannot quietly merge. A file containing several aircraft or controller sessions needs an explicit grouping rule. The original message documentation and the exporter documentation should both agree with the resulting columns. If that relationship is unknown, stop the numerical interpretation at the schema question; a rotation library cannot reconstruct information that the export omitted.

Separate component order from frame meaning

The MAVLink common message reference defines ATTITUDE_QUATERNION with q1, q2, q3 and q4 corresponding to w, x, y and z. It describes a right-handed aeronautical frame with front, right and downward axes, and gives the identity representation as one followed by three zeros. These facts describe the named message; they are not a rule for every four-value field found in every drone file. Preserve those field names when creating a table. Renaming them to anonymous columns makes the scalar component harder to recognize and increases the risk of an incorrect import.

Array order answers where the scalar lives. Frame interpretation answers what the rotation means, which axes it uses and which direction an application needs. Keep those decisions in separate notes. For example, a camera analysis may require relationships among aircraft body axes, a local reference, a gimbal and an optical frame. Correctly loading the aircraft quaternion supplies only one part of that chain. Do not label the resulting matrix as a camera-to-map transformation without documented mounting relationships and transform direction. A clean numerical matrix can still describe the wrong physical relationship for the intended analysis.

NiVO VTOL V7 with a white fuselage, lift rotors, and yellow wing tips
NiVO VTOL V7 with a white fuselage, lift rotors, and yellow wing tips.Source: NiVO / TechnoGIS catalogue materials supplied by the site owner · Catalogue photo
Product context only; this photograph does not depict the constructed examples in this article.

Import a constructed identity case explicitly

SciPy documents Rotation.from_quat as an active-rotation constructor. Its default array order places the scalar last; the scalar_first argument selects the alternate order. The constructor also normalizes quaternion inputs. The example below therefore chooses the order explicitly rather than depending on a library default. It uses a constructed identity record, checks finite values and rejects a zero norm before construction. Run it only in a separate analysis environment with an installed SciPy version supporting the displayed interface. The code does not connect to a drone, parse an actual log or modify an aircraft.

Read the expected outcome before replacing the example with real records: the constructed input should produce an identity matrix. A different result is a reason to inspect the interface, input layout and environment before continuing. An identity test is useful because it exposes a simple scalar-placement mistake without requiring a flight interpretation. It remains a software representation check, not an independent validation of navigation or attitude accuracy. Keep the test input and result alongside the environment version so that the next analyst can reproduce the import assumption instead of relying on an undocumented notebook state.

# Constructed representation check; no aircraft connection.
import numpy as np
from scipy.spatial.transform import Rotation

q_wxyz = np.array([1.0, 0.0, 0.0, 0.0])
if not np.isfinite(q_wxyz).all():
    raise ValueError("Non-finite quaternion")
norm = np.linalg.norm(q_wxyz)
if not np.isfinite(norm) or norm == 0:
    raise ValueError("Invalid quaternion norm")
r = Rotation.from_quat(q_wxyz, scalar_first=True)
print(r.as_matrix())  # Expected: 3 x 3 identity matrix

Review validity before accepting normalization

Normalization can make a usable rotation from an input whose magnitude differs from one, but that convenience should not erase evidence about the source. Record the original components and their norm before conversion. Decide how the project will handle missing values, non-finite values, an all-zero vector and unexpectedly large magnitude departures. Establish that rule from the data specification and analytical purpose rather than inventing a universal tolerance. A row that fails the rule should retain its original timestamp and rejection reason. Dropping failed rows silently can hide gaps that matter when aligning attitude with image events.

A quaternion and its negative represent the same spatial rotation. Consequently, a component sign reversal between adjacent rows does not alone establish an abrupt aircraft maneuver. Inspect the represented orientations and the time separation before interpreting a component plot physically. If a later interpolation workflow needs a consistent sign choice, document that processing step and retain the source values. Likewise, a continuous-looking component trace is not sufficient evidence that the frame, clock or sender selection is correct. Representation validity, temporal continuity and physical plausibility answer different review questions and should remain separately traceable.

Keep display offsets and payload geometry explicit

ATTITUDE_QUATERNION includes a display-related extension named repr_offset_q. The reference describes an offset for rotating attitude and angular-speed presentation and uses a zero-filled value when that field is unsupported. Treat that sentinel according to its field definition. It is not permission to accept an all-zero primary attitude quaternion as a valid rotation. Identify whether an exporter supplies the extension, omits it or has already applied a display convention. The message reference gives a tailsitter illustration, but it does not demonstrate the behavior of a particular NiVO configuration or justify applying that illustration to another airframe.

For a payload-facing review, draw the sequence of documented relationships from the recorded attitude to the quantity being requested. Label each arrow with its source, target, units where relevant and transform direction. State whether the task concerns an aircraft display, a lever-arm calculation or a camera orientation. Preserve any known mounting revision with that sketch. If a required relationship is absent, mark the derived quantity unresolved instead of trying alternate signs until one screenshot looks convincing. This keeps a component-order correction from being mistaken for a complete sensor integration or calibration result.

Deliver a reproducible attitude interpretation record

A useful handoff contains the original log identity, selected message and sender, export schema, component order, frame notes, clock interpretation and analysis environment. Add counts of accepted and rejected rows and a small set of traceable timestamps that another reviewer can locate in the source. Include the constructed identity check as a software import example, clearly separated from any actual observations. If the receiving application uses a different array order, name that interface and show the conversion in the record. Avoid a generic statement that quaternions were fixed; explain the exact representation decision.

Before using the interpreted attitude in a survey calculation, review its event timing and the remaining physical relationships against independent project evidence. This may reveal that a mathematically valid import still lacks the mounting or synchronization information needed for the requested output. Preserve that limitation in the delivery rather than allowing it to disappear behind a plot. For NiVO technical discussions, the resulting record makes the open question concrete: which message, which four fields, which frame and which application interface are involved. It supports a focused review without claiming a flight test, payload compatibility or achieved survey accuracy.

Technical references

  1. MAVLink common message reference — ATTITUDE_QUATERNION ↗
  2. SciPy Rotation.from_quat — order, active rotations and normalization ↗
  3. SciPy Rotation.as_quat — equivalent quaternion signs ↗
← All articles

Related articles

All articles ↗
LET’S TAKE FLIGHT

Your next mission
starts with a conversation.

Talk to our team