Attitude.parse constructor

Attitude.parse(
  1. ByteData data_
)

Implementation

factory Attitude.parse(ByteData data_) {
  if (data_.lengthInBytes < Attitude.mavlinkEncodedLength) {
    var len = Attitude.mavlinkEncodedLength - data_.lengthInBytes;
    var d = data_.buffer.asUint8List() + List<int>.filled(len, 0);
    data_ = Uint8List.fromList(d).buffer.asByteData();
  }
  var timeBootMs = data_.getUint32(0, Endian.little);
  var roll = data_.getFloat32(4, Endian.little);
  var pitch = data_.getFloat32(8, Endian.little);
  var yaw = data_.getFloat32(12, Endian.little);
  var rollspeed = data_.getFloat32(16, Endian.little);
  var pitchspeed = data_.getFloat32(20, Endian.little);
  var yawspeed = data_.getFloat32(24, Endian.little);

  return Attitude(
      timeBootMs: timeBootMs,
      roll: roll,
      pitch: pitch,
      yaw: yaw,
      rollspeed: rollspeed,
      pitchspeed: pitchspeed,
      yawspeed: yawspeed);
}