OpticalFlow.parse constructor

OpticalFlow.parse(
  1. ByteData data_
)

Implementation

factory OpticalFlow.parse(ByteData data_) {
  if (data_.lengthInBytes < OpticalFlow.mavlinkEncodedLength) {
    var len = OpticalFlow.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 flowCompMX = data_.getFloat32(8, Endian.little);
  var flowCompMY = data_.getFloat32(12, Endian.little);
  var groundDistance = data_.getFloat32(16, Endian.little);
  var flowX = data_.getInt16(20, Endian.little);
  var flowY = data_.getInt16(22, Endian.little);
  var sensorId = data_.getUint8(24);
  var quality = data_.getUint8(25);
  var flowRateX = data_.getFloat32(26, Endian.little);
  var flowRateY = data_.getFloat32(30, Endian.little);

  return OpticalFlow(
      timeUsec: timeUsec,
      flowCompMX: flowCompMX,
      flowCompMY: flowCompMY,
      groundDistance: groundDistance,
      flowX: flowX,
      flowY: flowY,
      sensorId: sensorId,
      quality: quality,
      flowRateX: flowRateX,
      flowRateY: flowRateY);
}