Collision.parse constructor

Collision.parse(
  1. ByteData data_
)

Implementation

factory Collision.parse(ByteData data_) {
  if (data_.lengthInBytes < Collision.mavlinkEncodedLength) {
    var len = Collision.mavlinkEncodedLength - data_.lengthInBytes;
    var d = data_.buffer.asUint8List() + List<int>.filled(len, 0);
    data_ = Uint8List.fromList(d).buffer.asByteData();
  }
  var id = data_.getUint32(0, Endian.little);
  var timeToMinimumDelta = data_.getFloat32(4, Endian.little);
  var altitudeMinimumDelta = data_.getFloat32(8, Endian.little);
  var horizontalMinimumDelta = data_.getFloat32(12, Endian.little);
  var src = data_.getUint8(16);
  var action = data_.getUint8(17);
  var threatLevel = data_.getUint8(18);

  return Collision(
      id: id,
      timeToMinimumDelta: timeToMinimumDelta,
      altitudeMinimumDelta: altitudeMinimumDelta,
      horizontalMinimumDelta: horizontalMinimumDelta,
      src: src,
      action: action,
      threatLevel: threatLevel);
}