TargetRelative.parse constructor

TargetRelative.parse(
  1. ByteData data_
)

Implementation

factory TargetRelative.parse(ByteData data_) {
  if (data_.lengthInBytes < TargetRelative.mavlinkEncodedLength) {
    var len = TargetRelative.mavlinkEncodedLength - data_.lengthInBytes;
    var d = data_.buffer.asUint8List() + List<int>.filled(len, 0);
    data_ = Uint8List.fromList(d).buffer.asByteData();
  }
  var timestamp = data_.getUint64(0, Endian.little);
  var x = data_.getFloat32(8, Endian.little);
  var y = data_.getFloat32(12, Endian.little);
  var z = data_.getFloat32(16, Endian.little);
  var posStd = MavlinkMessage.asFloat32List(data_, 20, 3);
  var yawStd = data_.getFloat32(32, Endian.little);
  var qTarget = MavlinkMessage.asFloat32List(data_, 36, 4);
  var qSensor = MavlinkMessage.asFloat32List(data_, 52, 4);
  var id = data_.getUint8(68);
  var frame = data_.getUint8(69);
  var type = data_.getUint8(70);

  return TargetRelative(
      timestamp: timestamp,
      x: x,
      y: y,
      z: z,
      posStd: posStd,
      yawStd: yawStd,
      qTarget: qTarget,
      qSensor: qSensor,
      id: id,
      frame: frame,
      type: type);
}