DJI Mobile SDK Documentation

      class Compass

      class Compass
      Package:dji.sdk.flightcontroller
      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:
      Heading
      method
      method getHeading
      float getHeading()
      Package:dji.sdk.flightcontroller
      SDK Key:FlightControllerKey.COMPASS_HEADING
      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].

      Return:
      floatA double value of the heading, in degrees.
      Error
      method
      method hasError
      boolean hasError()
      Package:dji.sdk.flightcontroller
      SDK Key:FlightControllerKey.COMPASS_HAS_ERROR
      Description:

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

      Return:
      booleanA boolean value.
      Check Calibrating
      method
      method isCalibrating
      boolean isCalibrating()
      Package:dji.sdk.flightcontroller
      SDK Key:FlightControllerKey.COMPASS_IS_CALIBRATING
      Description:

      true if the compass is currently calibrating.

      Return:
      booleanA boolean value.
      Calibration Status
      method
      method getCalibrationState
      CompassCalibrationState getCalibrationState()
      Package:dji.sdk.flightcontroller
      SDK Key:FlightControllerKey.COMPASS_CALIBRATION_STATUS
      Description:

      Shows the calibration status.

      Return:
      CompassCalibrationStateAn enum value of CompassCalibrationState.
      Calibration
      method
      method startCalibration
      void startCalibration(@Nullable final CompletionCallback callback)
      Package:dji.sdk.flightcontroller
      SDK Key:FlightControllerKey.COMPASS_START_CALIBRATION
      Description:

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

      Input Parameters:
      @Nullable final CompletionCallback callbackCompletion callback. See DJIBaseComponent for more information about the callback and what is recommended be done with it.
      method stopCalibration
      void stopCalibration(@Nullable CompletionCallback callback)
      Package:dji.sdk.flightcontroller
      SDK Key:FlightControllerKey.COMPASS_STOP_CALIBRATION
      Description:

      Stops compass calibration.

      Input Parameters:
      @Nullable CompletionCallback callbackCompletion callback. See DJIBaseComponent for more information about the callback and what is recommended be done with it.
      State Updates
      method
      method setCalibrationStateCallback
      void setCalibrationStateCallback(@Nullable CompassCalibrationState.Callback callback)
      Package:dji.sdk.flightcontroller
      SDK Key:FlightControllerKey.COMPASS_CALIBRATION_STATUS
      Description:

      Sets the callback for compass calibration.

      Input Parameters:
      @Nullable CompassCalibrationState.Callback callbackThe callback with compass calibration state
      enum CompassCalibrationState
      @EXClassNullAway
      enum CompassCalibrationState
      Package:dji.common.flightcontroller
      SDK Key:FlightControllerKey.COMPASS_CALIBRATION_STATUS
      Description:

      An enum class representing compass calibration.

      Enum Members:
      NOT_CALIBRATINGNormal state. Compass not in calibration.
      HORIZONTALCompass horizontal calibration. The user should hold the aircraft horizontally and rotate it 360 degrees.
      VERTICALCompass vertical calibration. The user should hold the aircraft vertically, with the nose pointed towards the ground, and rotate the aircraft 360 degrees.
      SUCCESSFULCompass calibration succeeded.
      FAILEDCompass calibration failed. Make sure there are no magnets or metal objects near the compass and retry.
      UNKNOWNCompass calibration status unknown.
      Class Members:
      interface
      interface Callback
      interface Callback
      Package:dji.common.flightcontroller
      SDK Key:FlightControllerKey.COMPASS_CALIBRATION_STATUS
      Description:

      Updates compass calibration state

      Interface Methods:
      method
      method onUpdate
      void onUpdate(@NonNull CompassCalibrationState state)
      Package:dji.common.flightcontroller
      SDK Key:FlightControllerKey.COMPASS_CALIBRATION_STATUS
      Description:

      Called when calibration state is updated.

      Input Parameters:
      @NonNull CompassCalibrationState stateThe updated calibration state