ObstacleDistance3d.parse constructor

ObstacleDistance3d.parse(
  1. ByteData data_
)

Implementation

factory ObstacleDistance3d.parse(ByteData data_) {
  if (data_.lengthInBytes < ObstacleDistance3d.mavlinkEncodedLength) {
    var len = ObstacleDistance3d.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 x = data_.getFloat32(4, Endian.little);
  var y = data_.getFloat32(8, Endian.little);
  var z = data_.getFloat32(12, Endian.little);
  var minDistance = data_.getFloat32(16, Endian.little);
  var maxDistance = data_.getFloat32(20, Endian.little);
  var obstacleId = data_.getUint16(24, Endian.little);
  var sensorType = data_.getUint8(26);
  var frame = data_.getUint8(27);

  return ObstacleDistance3d(
      timeBootMs: timeBootMs,
      x: x,
      y: y,
      z: z,
      minDistance: minDistance,
      maxDistance: maxDistance,
      obstacleId: obstacleId,
      sensorType: sensorType,
      frame: frame);
}