Options
All
  • Public
  • Public/Protected
  • All
Menu

Class SabertoothUSB

Controls USB-enabled Sabertooth motor drivers running in Packet Serial mode.

See https://www.dimensionengineering.com/datasheets/USBSabertoothPacketSerialReference.pdf

Note: Only Checksum protection is implemented, not CRC.

Hierarchy

  • SabertoothUSB

Index

Constructors

  • Create an object to control a motor driver.

    A connection to the motor driver will be attempted upon creation but this is asynchronous and is not available immediately after creation. If the connection fails reconnection will be attempted automatically.

    Parameters

    • path: string

      the path to the (USB) serial port. eg /dev/ttyACM0 or COM1.

    • Optional options: Options

      Optional connection options. See Options type for details.

    Returns SabertoothUSB

Properties

address: number

The address of the Sabertooth.

debug: boolean

Flag indicating if console.log debug messages are enabled.

maxGetAttemptCount: number

The number of retry attempts for get requests.

maxMotorOutputRate: number

Maximum motor output as proportion of battery input.

motorCurrentDenoiseAlpha: number

Motor current denoise exponential moving average factor.

path: string

The path for the USB serial port this SabertoothUSB is connected to.

timeout: number

The timeout for get requests, in ms.

Methods

  • getBatteryVoltage(): Promise<number>
  • Get the battery/source voltage.

    Returns Promise<number>

  • getLastError(): Error
  • Get the last error that occurred in the connection to the motor driver.

    Returns Error

  • Get the output current for the specified motor channel, in Amps. This is a noisy signal and may vary by up to several amps. Positive current values indicate energy is being drawn from the battery, and negative values indicate energy is being regenerated into the battery.

    Parameters

    Returns Promise<number>

  • getMotorDriverOutputRate(channel: SingleChannel): Promise<number>
  • Get the output rate for the specified motor channel, in range [-1, 1].

    Parameters

    Returns Promise<number>

  • getMotorDriverOutputTemperature(channel: SingleChannel): Promise<number>
  • Get the output transistor temperature for the specified motor channel, in degrees centigrade.

    Parameters

    Returns Promise<number>

  • isConnected(): boolean
  • Returns true iff the USB serial connection to the motor driver is open and working.

    Returns boolean

  • setCurrentLimit(channel: Channel, currentLimit: number): void
  • Sets the current limit for the specified motor output channel.

    Parameters

    • channel: Channel

      the motor channel(s), either 1, 2, or * for all channels.

    • currentLimit: number

      the new current limit on Amps, in range (0, 100], or -1 to use the default limit.

    Returns void

  • setDrive(rate: number): void
  • Controls the mixed-mode (differential) drive rate. Note that the given rate is scaled by the maxMotorOutputRate.

    Parameters

    • rate: number

      the new drive rate for the motors, in range [-1, 1] for maximum reverse to maximum forward respectively.

    Returns void

  • setFreewheel(channel: Channel, enableFreewheel: boolean): void
  • Enables or disables freewheeling for the specified motor output(s).

    Parameters

    • channel: Channel

      the motor channel(s), either 1, 2, or * for all motors.

    • enableFreewheel: boolean

      True to enable freewheeling, false to disable freewheeling.

    Returns void

  • setMotor(channel: Channel, rate: number): void
  • Controls the specified motor output(s). This sets the output of the motor channel as a fraction of the battery voltage. Note that the given rate is scaled by the maxMotorOutputRate.

    Parameters

    • channel: Channel

      the motor channel(s), either 1, 2, or * for all motors.

    • rate: number

      the new rate for the motor(s), in range [-1, 1] for maximum reverse to maximum forward respectively.

    Returns void

  • setPower(channel: Channel, rate: number): void
  • Controls the specified power output, if the power output is configured as a controllable output.

    Parameters

    • channel: Channel

      the power channel(s), either 1, 2, or * for all channels.

    • rate: number

      the new rate for the power output(s), in range [-1, 1]

    Returns void

  • setRamping(channel: Channel, ramping: number): void
  • Sets the ramping for the specified motor output channel.

    Parameters

    • channel: Channel

      the motor channel(s), either 1, 2, or * for all channels.

    • ramping: number

      The ramping value, between -16383 (fast) and 2047 (slow).

    Returns void

  • setTurn(rate: number): void
  • Controls the mixed-mode (differential) turn rate.

    Parameters

    • rate: number

      the new turn rate for the motors, in range [-1, 1] for maximum left to maximum right respectively.

    Returns void

  • Shuts down motor or power output(s).

    Parameters

    • type: Motor | Power

      The type of output to shutdown, either SetType.Motor or SetType.Power

    • channel: Channel

      the channel(s), either 1, 2, or * for all channels.

    • shutdownEnabled: boolean

    Returns void

Generated using TypeDoc