# Interface AutopilotProvider

interface AutopilotProvider {
adjustTarget(value: number, deviceId: string): Promise<void>;
courseCurrentPoint(deviceId: string): Promise<void>;
courseNextPoint(deviceId: string): Promise<void>;
disengage(deviceId: string): Promise<void>;
dodge(value: null | number, deviceId: string): Promise<void>;
engage(deviceId: string): Promise<void>;
getData(deviceId: string): Promise<AutopilotInfo>;
getMode(deviceId: string): Promise<null | string>;
getState(deviceId: string): Promise<null | string>;
getTarget(deviceId: string): Promise<null | number>;
gybe(direction: TackGybeDirection, deviceId: string): Promise<void>;
setMode(mode: string, deviceId: string): Promise<void>;
setState(state: string, deviceId: string): Promise<void>;
setTarget(value: number, deviceId: string): Promise<void>;
tack(direction: TackGybeDirection, deviceId: string): Promise<void>;
}

- Defined in autopilotapi.ts:127

##### Index

### Methods

adjustTarget
courseCurrentPoint
courseNextPoint
disengage
dodge
engage
getData
getMode
getState
getTarget
gybe
setMode
setState
setTarget
tack

## Methods

### adjustTarget

- adjustTarget(value: number, deviceId: string): Promise<void>

  Adjusts target for the autopilot device with the supplied identifier by the supplied value.

  #### Parameters

  - value: number

    value in radians to add to current target value.

  - deviceId: string

    identifier of the autopilot device to query.

  #### Returns Promise<void>

  #### Example

  API request

      PUT /signalk/v2/api/vessels/self/autopilots/mypilot1/target {value: 2}

  AutopilotProvider method invocation

      adjustTarget(2, 'mypilot1');

  #### Throws

  if supplied target value is outside the valid range.

  - Defined in autopilotapi.ts:281

### courseCurrentPoint

- courseCurrentPoint(deviceId: string): Promise<void>

  Instructs the autopilot device to steer for the currently set destination position.

  It is assumed that a destination has been set prior to invoking this action.

  The intended result of this action is that the autopilot device be engaged in the appropriate mode to steer to the active waypoint / position.

  #### Parameters

  - deviceId: string

    identifier of the autopilot device to query.

  #### Returns Promise<void>

  #### Example

  API request

      POST /signalk/v2/api/vessels/self/autopilots/mypilot1/courseCurrentPoint

  AutopilotProvider method invocation

      courseCurrentPoint('mypilot1');

  #### Throws

  on error.

  - Defined in autopilotapi.ts:340

### courseNextPoint

- courseNextPoint(deviceId: string): Promise<void>

  Instructs the autopilot device to advance to the next waypoint on the route.

  #### Parameters

  - deviceId: string

    identifier of the autopilot device to query.

  #### Returns Promise<void>

  #### Example

  API request

      POST /signalk/v2/api/vessels/self/autopilots/mypilot1/courseNextPoint

  AutopilotProvider method invocation

      courseNextPoint('mypilot1');

  #### Throws

  on error.

  - Defined in autopilotapi.ts:358

### disengage

- disengage(deviceId: string): Promise<void>

  `disengage(deviceId)`: This method sets the state of the autopilot device with the supplied identifier to a state that is NOT actively steering the vessel.

  #### Parameters

  - deviceId: string

    identifier of the autopilot device to query.

  #### Returns Promise<void>

  #### Example

  API request

      POST /signalk/v2/api/vessels/self/autopilots/mypilot1/disengage

  AutopilotProvider method invocation

      disengage('mypilot1');

  #### Throws

  on error.

  - Defined in autopilotapi.ts:317

### dodge

- dodge(value: null | number, deviceId: string): Promise<void>

  Instructs the autopilot device with the supplied identifier to enter / exit dodge mode and alter the current course by the supplied value (radians) direction.

  #### Parameters

  - value: null | number

    +/- value in radians 'port (-ive)' or 'starboard' to change direction. Setting the value to `null` indicates exit of dodge mode.

  - deviceId: string

    identifier of the autopilot device to query.

  #### Returns Promise<void>

  #### Example

  To address different pilot behaviour, the `dodge` function can be used in the following ways:

  1. Enter dodge mode at the current course

      // API request
      POST /signalk/v2/api/vessels/self/autopilots/mypilot1/dodge

      // _AutopilotProvider method invocation
      dodge(0, 'mypilot1');

  2. Enter dodge mode and change course

      // API request
      PUT /signalk/v2/api/vessels/self/autopilots/mypilot1/dodge {"value": 5}

      // AutopilotProvider method invocation
      dodge(5, 'mypilot1');

  3. Cancel dodge mode

      // API request
      DELETE /signalk/v2/api/vessels/self/autopilots/mypilot1/dodge

      // AutopilotProvider method invocation
      dodge(null, 'mypilot1');

  #### Throws

  on error.

  - Defined in autopilotapi.ts:435

### engage

- engage(deviceId: string): Promise<void>

  Sets the state of the autopilot device with the supplied identifier to a state that is actively steering the vessel.

  #### Parameters

  - deviceId: string

    identifier of the autopilot device to query.

  #### Returns Promise<void>

  #### Example

  API request

      POST /signalk/v2/api/vessels/self/autopilots/mypilot1/engage

  AutopilotProvider method invocation

      engage('mypilot1');

  #### Throws

  on error.

  - Defined in autopilotapi.ts:299

### getData

- getData(deviceId: string): Promise<AutopilotInfo>

  This method returns an AutopilotInfo object containing the current data values and valid options for the supplied autopilot device identifier.

  Note

  It is the responsibility of the autopilot provider plugin to map the value of `engaged` to the current `state`.

  Additionally, the plugin can maintain a list of `availableActions` that can be taken in the current operational state.

  #### Parameters

  - deviceId: string

    identifier of the autopilot device to query.

  #### Returns Promise<AutopilotInfo>

  #### Example

  API request:

      GET /signalk/v2/api/vessels/self/autopilots/mypilot1

  AutopilotProvider method invocation:

      getData('mypilot1');

      // Returns:
      {
         options: {
          states: [
              {
                  name: 'auto' // autopilot state name
                  engaged: true // actively steering
              },
              {
                  name: 'standby' // autopilot state name
                  engaged: false // not actively steering
              }
          ]
          modes: ['compass', 'gps', 'wind'],  // supported modes of operation
          actions: [
          {
             id: 'tack',
             name: 'Tack',
             available: true
          },
          {
             id: 'gybe',
             name: 'Gybe',
             available: false
          }
           ]  // actions the autopilot supports
      },
        target: 0.326
        mode: 'compass'
        state: 'auto'
        engaged: true
      }

  - Defined in autopilotapi.ts:183

### getMode

- getMode(deviceId: string): Promise<null | string>

  #### Parameters

  - deviceId: string

  #### Returns Promise<null | string>

  - Defined in autopilotapi.ts:223

### getState

- getState(deviceId: string): Promise<null | string>

  Returns the current state of the supplied autopilot device identifier. If the autopilot device is not connected or unreachable then `off-line` should be returned.

  #### Parameters

  - deviceId: string

    identifier of the autopilot device to query.

  #### Returns Promise<null | string>

  #### Example

  API request

      GET /signalk/v2/api/vessels/self/autopilots/mypilot1/state

  AutopilotProvider method invocation

      await getState('mypilot1'); // Returns: 'auto'

  - Defined in autopilotapi.ts:201

### getTarget

- getTarget(deviceId: string): Promise<null | number>

  #### Parameters

  - deviceId: string

  #### Returns Promise<null | number>

  - Defined in autopilotapi.ts:242

### gybe

- gybe(direction: TackGybeDirection, deviceId: string): Promise<void>

  `gybe(direction, deviceId)`: This method instructs the autopilot device with the supplied identifier to perform a gybe in the supplied direction.

  #### Parameters

  - direction: TackGybeDirection

    `port` or `starboard`

  - deviceId: string

    identifier of the autopilot device to query.

  #### Returns Promise<void>

  #### Example

  API request

      POST /signalk/v2/api/vessels/self/autopilots/mypilot1/gybe/starboard

  AutopilotProvider method invocation

      gybe('starboard', 'mypilot1');

  #### Throws

  on error.

  - Defined in autopilotapi.ts:396

### setMode

- setMode(mode: string, deviceId: string): Promise<void>

  Sets the autopilot device with the supplied identifier to the supplied mode value.

  #### Parameters

  - mode: string

    Must be a valid mode value.

  - deviceId: string

    identifier of the autopilot device to query.

  #### Returns Promise<void>

  #### Example

  API request

      PUT /signalk/v2/api/vessels/self/autopilots/mypilot1/mode {value: "gps"}

  AutopilotProvider method invocation

      setMode('gps', 'mypilot1');

  #### Throws

  if supplied mode value is invalid.

  - Defined in autopilotapi.ts:241

### setState

- setState(state: string, deviceId: string): Promise<void>

  Sets the autopilot device with the supplied identifier to the supplied state value.

  #### Parameters

  - state: string

    state value to set. Must be a valid state value.

  - deviceId: string

    identifier of the autopilot device to query.

  #### Returns Promise<void>

  #### Example

  API request

      PUT /signalk/v2/api/vessels/self/autopilots/mypilot1/state {value: "standby"}

  AutopilotProvider method invocation

      setState('standby', 'mypilot1');

  #### Throws

  if supplied state value is invalid.

  - Defined in autopilotapi.ts:221

### setTarget

- setTarget(value: number, deviceId: string): Promise<void>

  Sets target for the autopilot device with the supplied identifier to the supplied value.

  #### Parameters

  - value: number

    target value in radians.

  - deviceId: string

    identifier of the autopilot device to query.

  #### Returns Promise<void>

  #### Example

  API request

      PUT /signalk/v2/api/vessels/self/autopilots/mypilot1/target {value: 129}

  // AutopilotProvider method invocation

      setTarget(129, 'mypilot1');

  #### Throws

  if supplied target value is outside the valid range.

  - Defined in autopilotapi.ts:262

### tack

- tack(direction: TackGybeDirection, deviceId: string): Promise<void>

  Instructs the autopilot device with the supplied identifier to perform a tack in the supplied direction.

  #### Parameters

  - direction: TackGybeDirection

    `port` or `starboard`

  - deviceId: string

    identifier of the autopilot device to query.

  #### Returns Promise<void>

  #### Example

  API request

      POST /signalk/v2/api/vessels/self/autopilots/mypilot1/tack/port

  AutopilotProvider method invocation

      tack('port', 'mypilot1');

  #### Throws

  on error.

  - Defined in autopilotapi.ts:377