DistanceSensor.parse constructor

DistanceSensor.parse(
  1. ByteData data_
)

Implementation

factory DistanceSensor.parse(ByteData data_) {
  if (data_.lengthInBytes < DistanceSensor.mavlinkEncodedLength) {
    var len = DistanceSensor.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 minDistance = data_.getUint16(4, Endian.little);
  var maxDistance = data_.getUint16(6, Endian.little);
  var currentDistance = data_.getUint16(8, Endian.little);
  var type = data_.getUint8(10);
  var id = data_.getUint8(11);
  var orientation = data_.getUint8(12);
  var covariance = data_.getUint8(13);
  var horizontalFov = data_.getFloat32(14, Endian.little);
  var verticalFov = data_.getFloat32(18, Endian.little);
  var quaternion = MavlinkMessage.asFloat32List(data_, 22, 4);
  var signalQuality = data_.getUint8(38);

  return DistanceSensor(
      timeBootMs: timeBootMs,
      minDistance: minDistance,
      maxDistance: maxDistance,
      currentDistance: currentDistance,
      type: type,
      id: id,
      orientation: orientation,
      covariance: covariance,
      horizontalFov: horizontalFov,
      verticalFov: verticalFov,
      quaternion: quaternion,
      signalQuality: signalQuality);
}