ObstacleDistance.parse constructor

ObstacleDistance.parse(
  1. ByteData data_
)

Implementation

factory ObstacleDistance.parse(ByteData data_) {
  if (data_.lengthInBytes < ObstacleDistance.mavlinkEncodedLength) {
    var len = ObstacleDistance.mavlinkEncodedLength - data_.lengthInBytes;
    var d = data_.buffer.asUint8List() + List<int>.filled(len, 0);
    data_ = Uint8List.fromList(d).buffer.asByteData();
  }
  var timeUsec = data_.getUint64(0, Endian.little);
  var distances = MavlinkMessage.asUint16List(data_, 8, 72);
  var minDistance = data_.getUint16(152, Endian.little);
  var maxDistance = data_.getUint16(154, Endian.little);
  var sensorType = data_.getUint8(156);
  var increment = data_.getUint8(157);
  var incrementF = data_.getFloat32(158, Endian.little);
  var angleOffset = data_.getFloat32(162, Endian.little);
  var frame = data_.getUint8(166);

  return ObstacleDistance(
      timeUsec: timeUsec,
      distances: distances,
      minDistance: minDistance,
      maxDistance: maxDistance,
      sensorType: sensorType,
      increment: increment,
      incrementF: incrementF,
      angleOffset: angleOffset,
      frame: frame);
}