Simstate.parse constructor

Simstate.parse(
  1. ByteData data_
)

Implementation

factory Simstate.parse(ByteData data_) {
  if (data_.lengthInBytes < Simstate.mavlinkEncodedLength) {
    var len = Simstate.mavlinkEncodedLength - data_.lengthInBytes;
    var d = data_.buffer.asUint8List() + List<int>.filled(len, 0);
    data_ = Uint8List.fromList(d).buffer.asByteData();
  }
  var roll = data_.getFloat32(0, Endian.little);
  var pitch = data_.getFloat32(4, Endian.little);
  var yaw = data_.getFloat32(8, Endian.little);
  var xacc = data_.getFloat32(12, Endian.little);
  var yacc = data_.getFloat32(16, Endian.little);
  var zacc = data_.getFloat32(20, Endian.little);
  var xgyro = data_.getFloat32(24, Endian.little);
  var ygyro = data_.getFloat32(28, Endian.little);
  var zgyro = data_.getFloat32(32, Endian.little);
  var lat = data_.getInt32(36, Endian.little);
  var lng = data_.getInt32(40, Endian.little);

  return Simstate(
      roll: roll,
      pitch: pitch,
      yaw: yaw,
      xacc: xacc,
      yacc: yacc,
      zacc: zacc,
      xgyro: xgyro,
      ygyro: ygyro,
      zgyro: zgyro,
      lat: lat,
      lng: lng);
}