Skip to main content

Module param_codec

Module param_codec 

Source
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 its PARAM_VALUE echo 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_TYPE values the codec distinguishes.
MAV_PARAM_TYPE_UINT16
MAV_PARAM_TYPE_UINT32
MAV_PARAM_TYPE_UINT64

Functions§

decode
The value a PARAM_VALUE reported, decoded from its wire field. With bytewise, 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 value for a parameter of param_type. An integer type takes the rounded value and refuses one outside the type’s range; with bytewise, 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_type is a defined MAV_PARAM_TYPE (UINT8 through REAL64).
uses_bytewise
Whether a vehicle whose HEARTBEAT names autopilot packs integer parameters bytewise. PX4 does; ArduPilot casts.