Drive: Drive control

更新时间:
2024-05-15
下载文档

Drive: Drive control

This module is the vehicle drive module. This module is provided in EdgerOS 2.0.0 and later, and apps need to have vehicle.drive permission to use this module.

User can use the following code to import the Drive module.

var Drive = require('vehicle/drive');

Support

The following shows Drive module APIs available for each permissions.

 User ModePrivilege Mode
Drive
drive.request
drive.release
drive.pedal
drive.steering
drive.gear
drive.epb

Drive Class

new Drive()

  • Returns: {Object} Drive object.

Create a Drive object.

Drive Object

drive.request(callback)

  • callback {Function} Callback.
    • error {Error} Specify the error message when the request is failed.

Request for vehicle drive operation. After the request is successful, App can drive the vehicle.

drive.release()

Release the current Drive object, no operation is allowed after the object is released.

The object needs to be released as soon as possible when it is no longer used.

drive.pedal(param, callback)

  • param {Object} Pedal parameter.
  • callback {Function} Callback.
    • error {Error} Specify the error message when failed.

Set vehicle pedal state, param can have the following members:

  • accel {Integer} Acceleration pedal 0 - 5
  • brake {Integer} Brake pedal 0 - 100
  • reliable {Boolean} Whether it is a reliable setting, if there are continuous control instructions behind, the intermediate instruction part reliable can be false.

drive.steering(param, callback)

  • param {Object} Steering parameter.
  • callback {Function} Callback.
    • error {Error} Specify the error message when failed.

Set vehicle steering position, param can have the following members:

  • pos {Integer} Steering position -780 R - 780 L
  • reliable {Boolean} Whether it is a reliable setting, if there are continuous control instructions behind, the intermediate instruction part reliable can be false.

drive.gear(param, callback)

  • param {Object} Steering parameter.
  • callback {Function} Callback.
    • error {Error} Specify the error message when failed.

Set vehicle gear setting, param can have the following members:

  • gear {String} 'P'|'R'|'N'|'D'|'S'

drive.epb(param, callback)

  • param {Object} Steering parameter.
  • callback {Function} Callback.
    • error {Error} Specify the error message when failed.

Set vehicle EPB setting, param can have the following members:

  • status {Integer} 0: Parking 1: Release.
文档内容是否对您有所帮助?
有帮助
没帮助