DJI Mobile SDK Documentation

      class DJICompass

      @interface DJICompass : NSObject
      Header:DJICompass.h
      Inherits From:NSObject
      Description:

      This class provides compass status information and compass calibration methods. Products with multiple compasses (like the Phantom 4) have their compass state fused into one compass class for simplicity.

      Class Members:

      State Updates

      General
      property
      property delegate
      @property(nonatomic, weak) id<DJICompassDelegate> delegate
      Header:DJICompass.h
      Description:

      Compass delegate.

      See Also:

      DJICompassDelegate

      Heading
      property
      property heading
      @property(nonatomic, readonly) double heading
      Header:DJICompass.h
      SDK Key:DJIFlightControllerKey.DJIFlightControllerParamCompassHeading
      Description:

      Represents the heading, in degrees. True North is 0 degrees, positive heading is East of North, and negative heading is West of North. Heading bounds are [-180, 180].

      Error
      property
      property hasError
      @property(nonatomic, readonly) BOOL hasError
      Header:DJICompass.h
      SDK Key:DJIFlightControllerKey.DJIFlightControllerParamCompassHasError
      Description:

      YES if the compass has an error. If YES, the compass needs calibration.

      Check Calibrating
      property
      property isCalibrating
      @property(nonatomic, readonly) BOOL isCalibrating
      Header:DJICompass.h
      SDK Key:DJIFlightControllerKey.DJIFlightControllerParamCompassIsCalibrating
      Description:

      YES if the compass is currently calibrating.

      Calibration Status
      property
      property calibrationState
      @property(nonatomic, readonly) DJICompassCalibrationState calibrationState
      Header:DJICompass.h
      SDK Key:DJIFlightControllerKey.DJIFlightControllerParamCompassCalibrationState
      Description:

      Shows the calibration status.

      See Also:

      DJICompassCalibrationState

      method startCalibrationWithCompletion
      - (void)startCalibrationWithCompletion:(DJICompletionBlock)completion
      Header:DJICompass.h
      SDK Key:DJIFlightControllerKey.DJIFlightControllerParamCompassStartCalibration
      Description:

      Starts compass calibration. Make sure there are no magnets or metal objects near the compass.

      Input Parameters:
      DJICompletionBlock completionCompletion block that receives the execution result.
      method stopCalibrationWithCompletion
      - (void)stopCalibrationWithCompletion:(DJICompletionBlock)completion
      Header:DJICompass.h
      SDK Key:DJIFlightControllerKey.DJIFlightControllerParamCompassStopCalibration
      Description:

      Stops compass calibration.

      Input Parameters:
      DJICompletionBlock completionCompletion block that receives the execution result.


      Compass State
      class
      enum DJICompassCalibrationState
      typedef NS_ENUM (NSUInteger, DJICompassCalibrationState)
      Header:DJICompassCalibrationState.h
      SDK Key:DJIFlightControllerKey.DJIFlightControllerParamCompassCalibrationState
      Description:

      Compass Calibration Status.

      Enum Members:
      DJICompassCalibrationStateNotCalibratingNormal state. Compass not in calibration.
      DJICompassCalibrationStateHorizontalCompass horizontal calibration. The user should hold the aircraft horizontally and rotate it 360 degrees.
      DJICompassCalibrationStateVerticalCompass vertical calibration. The user should hold the aircraft vertically, with the nose pointed towards the ground, and rotate the aircraft 360 degrees.
      DJICompassCalibrationStateSuccessfulCompass calibration succeeded.
      DJICompassCalibrationStateFailedCompass calibration failed. Make sure there are no magnets or metal objects near the compass and retry.
      DJICompassCalibrationStateUnknownCompass calibration status unknown.
      enum DJICompassSensorState
      typedef NS_ENUM (NSUInteger, DJICompassSensorState)
      Header:DJICompassState.h
      Description:

      Enum for Compass sensor Status.

      Enum Members:
      DJICompassSensorStateDisconnectedThe Compass sensor is disconnected from the flight controller.
      DJICompassSensorStateCalibratingThe Compass sensor is calibrating.
      DJICompassSensorStateIdleThe Compass sensor is not in calibrating.
      DJICompassSensorStateDataExceptionThe Compass sensor has a data exception. Calibrate the compass and restart the aircraft. If afterwards the status still exists, you may need to contact DJI for further assistance.
      DJICompassSensorStateSuperModulusSamllThe compass sensor super modulus is too samll.
      DJICompassSensorStateSuperModulusWeakThe compass sensor super modulus is too weak.
      DJICompassSensorStateSuperModulusDeviateThe compass sensor super modulus is deviate.
      DJICompassSensorStateCalibrationFailedThe Compass sensor is calibrating failed.
      DJICompassSensorStateInconsistentDirectionThe Compass sensor is inconsistent direction.
      DJICompassSensorStateUnknownThe IMU sensor's status is unknown.
      State Updates
      protocol
      protocol DJICompassDelegate
      @protocol DJICompassDelegate <NSObject>
      Header:DJICompass.h
      Inherits From:NSObject
      Description:

      This protocol provides delegate methods to update the compass's current state.

      Protocol Methods:

      Protocol Method

      method compass:didUpdateCalibrationState
      @optional
      - (void)compass:(DJICompass *_Nonnull)compass didUpdateCalibrationState:(DJICompassCalibrationState)state
      Header:DJICompass.h
      Description:

      Called when the compass pushes an compass calibration state update.

      Input Parameters:
      DJICompass *_Nonnull compassInstance of the compass for which the calibration state will be updated.
      DJICompassCalibrationState stateDJICompassCalibrationState state value.
      method compass:didUpdateSensorState
      @optional
      - (void)compass:(DJICompass *_Nonnull)compass didUpdateSensorState:(DJICompassState *)state
      Header:DJICompass.h
      Description:

      Called when the compass pushes an compass sensor state update.

      Input Parameters:
      DJICompass *_Nonnull compassInstance of the compass for which the compass sensor state will be updated.
      DJICompassState * stateDJICompassState state value.