Expand description
The value encoding of MAVLink PARAM_SET and PARAM_VALUE.
Both messages carry the value in one 4-byte float field. ArduPilot casts
every value to float, integer parameters included. PX4 instead copies an
integer parameter’s bytes into the field (bytewise encoding), so the float
it sends for the INT32 value 5 is the bit pattern of the integer 5, not
5.0. Reading or writing a PX4 integer parameter as a float corrupts it:
5 written as a float lands as 1084227584. The router’s decode and the
control surface’s encode share this one codec so the two never disagree.
Structs§
- Encoded
- A value ready for a
PARAM_SET: the float field to send, and the value the vehicle will hold once it applies it (what itsPARAM_VALUEecho decodes to).
Constants§
- MAV_
PARAM_ TYPE_ INT8 - MAV_
PARAM_ TYPE_ INT16 - MAV_
PARAM_ TYPE_ INT32 - MAV_
PARAM_ TYPE_ INT64 - MAV_
PARAM_ TYPE_ REAL32 - MAV_
PARAM_ TYPE_ REAL64 - MAV_
PARAM_ TYPE_ UINT8 - The
MAV_PARAM_TYPEvalues the codec distinguishes. - MAV_
PARAM_ TYPE_ UINT16 - MAV_
PARAM_ TYPE_ UINT32 - MAV_
PARAM_ TYPE_ UINT64
Functions§
- decode
- The value a
PARAM_VALUEreported, decoded from its wire field. Withbytewise, UINT8 through INT32 are read from the field’s low bytes as that integer type; every other case is the float itself. - echo_
matches - Whether a cached echo matches the value a write expects the vehicle to hold. The echo travelled as a 32-bit float, so equality is judged at that precision rather than at f64’s.
- encode
- Encode
valuefor a parameter ofparam_type. An integer type takes the rounded value and refuses one outside the type’s range; withbytewise, UINT8 through INT32 are written into the field’s low bytes (the rest zero). A float type refuses a value that overflows a 32-bit float. - is_
known_ type - Whether
param_typeis a definedMAV_PARAM_TYPE(UINT8 through REAL64). - uses_
bytewise - Whether a vehicle whose HEARTBEAT names
autopilotpacks integer parameters bytewise. PX4 does; ArduPilot casts.