Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ServoMotor

The servo motor class provides a uniform interface for using hobby type servo motors.

Hierarchy

Index

Type aliases

Static CommandValue

CommandValue: "run" | "float"

Static PolarityValue

PolarityValue: "normal" | "inversed"

Constructors

constructor

Properties

Protected _deviceIndex

_deviceIndex: number

connected

connected: boolean

deviceDirName

deviceDirName: string

Protected deviceIndexRegex

deviceIndexRegex: RegExp

deviceRoot

deviceRoot: string

Static overrideSysClassDir

overrideSysClassDir: string

Accessors

address

  • get address(): string
  • Returns the name of the port that this motor is connected to.

    Returns string

command

  • Sets the command for the servo. Valid values are run and float. Setting to run will cause the servo to be driven to the position_sp set in the position_sp attribute. Setting to float will remove power from the motor.

    Parameters

    Returns void

commandValues

  • get commandValues(): object

deviceIndex

  • get deviceIndex(): number

driverName

  • get driverName(): string
  • Returns the name of the motor driver that loaded this device. See the list of [supported devices] for a list of drivers.

    Returns string

maxPulseSp

  • get maxPulseSp(): number
  • set maxPulseSp(value: number): void
  • Used to set the pulse size in milliseconds for the signal that tells the servo to drive to the maximum (clockwise) position_sp. Default value is 2400. Valid values are 2300 to 2700. You must write to the position_sp attribute for changes to this attribute to take effect.

    Returns number

  • Used to set the pulse size in milliseconds for the signal that tells the servo to drive to the maximum (clockwise) position_sp. Default value is 2400. Valid values are 2300 to 2700. You must write to the position_sp attribute for changes to this attribute to take effect.

    Parameters

    • value: number

    Returns void

midPulseSp

  • get midPulseSp(): number
  • set midPulseSp(value: number): void
  • Used to set the pulse size in milliseconds for the signal that tells the servo to drive to the mid position_sp. Default value is 1500. Valid values are 1300 to 1700. For example, on a 180 degree servo, this would be 90 degrees. On continuous rotation servo, this is the 'neutral' position_sp where the motor does not turn. You must write to the position_sp attribute for changes to this attribute to take effect.

    Returns number

  • Used to set the pulse size in milliseconds for the signal that tells the servo to drive to the mid position_sp. Default value is 1500. Valid values are 1300 to 1700. For example, on a 180 degree servo, this would be 90 degrees. On continuous rotation servo, this is the 'neutral' position_sp where the motor does not turn. You must write to the position_sp attribute for changes to this attribute to take effect.

    Parameters

    • value: number

    Returns void

minPulseSp

  • get minPulseSp(): number
  • set minPulseSp(value: number): void
  • Used to set the pulse size in milliseconds for the signal that tells the servo to drive to the miniumum (counter-clockwise) position_sp. Default value is 600. Valid values are 300 to 700. You must write to the position_sp attribute for changes to this attribute to take effect.

    Returns number

  • Used to set the pulse size in milliseconds for the signal that tells the servo to drive to the miniumum (counter-clockwise) position_sp. Default value is 600. Valid values are 300 to 700. You must write to the position_sp attribute for changes to this attribute to take effect.

    Parameters

    • value: number

    Returns void

polarity

  • Sets the polarity of the servo. Valid values are normal and inversed. Setting the value to inversed will cause the position_sp value to be inversed. i.e -100 will correspond to max_pulse_sp, and 100 will correspond to min_pulse_sp.

    Returns PolarityValue

  • Sets the polarity of the servo. Valid values are normal and inversed. Setting the value to inversed will cause the position_sp value to be inversed. i.e -100 will correspond to max_pulse_sp, and 100 will correspond to min_pulse_sp.

    Parameters

    Returns void

polarityValues

  • get polarityValues(): object

positionSp

  • get positionSp(): number
  • set positionSp(value: number): void
  • Reading returns the current position_sp of the servo. Writing instructs the servo to move to the specified position_sp. Units are percent. Valid values are -100 to 100 (-100% to 100%) where -100 corresponds to min_pulse_sp, 0 corresponds to mid_pulse_sp and 100 corresponds to max_pulse_sp.

    Returns number

  • Reading returns the current position_sp of the servo. Writing instructs the servo to move to the specified position_sp. Units are percent. Valid values are -100 to 100 (-100% to 100%) where -100 corresponds to min_pulse_sp, 0 corresponds to mid_pulse_sp and 100 corresponds to max_pulse_sp.

    Parameters

    • value: number

    Returns void

rateSp

  • get rateSp(): number
  • set rateSp(value: number): void
  • Sets the rate_sp at which the servo travels from 0 to 100.0% (half of the full range of the servo). Units are in milliseconds. Example: Setting the rate_sp to 1000 means that it will take a 180 degree servo 2 second to move from 0 to 180 degrees. Note: Some servo controllers may not support this in which case reading and writing will fail with -EOPNOTSUPP. In continuous rotation servos, this value will affect the rate_sp at which the speed ramps up or down.

    Returns number

  • Sets the rate_sp at which the servo travels from 0 to 100.0% (half of the full range of the servo). Units are in milliseconds. Example: Setting the rate_sp to 1000 means that it will take a 180 degree servo 2 second to move from 0 to 180 degrees. Note: Some servo controllers may not support this in which case reading and writing will fail with -EOPNOTSUPP. In continuous rotation servos, this value will affect the rate_sp at which the speed ramps up or down.

    Parameters

    • value: number

    Returns void

state

  • get state(): string[]
  • Returns a list of flags indicating the state of the servo. Possible values are:

    • running: Indicates that the motor is powered.

    Returns string[]

Methods

connect

  • connect(driverName: string, nameConvention?: string, propertyConstraints?: object): void
  • Parameters

    • driverName: string
    • Optional nameConvention: string
    • Optional propertyConstraints: object
      • [propertyName: string]: any

    Returns void

Protected constructPropertyPath

  • constructPropertyPath(property: string, deviceRoot?: string): string

readNumber

  • readNumber(property: string, deviceRoot?: string): number
  • Parameters

    • property: string
    • Optional deviceRoot: string

    Returns number

readProperty

  • readProperty(property: string, deviceRoot?: string): any

readString

  • readString(property: string, deviceRoot?: string): string
  • Parameters

    • property: string
    • Optional deviceRoot: string

    Returns string

readStringArray

  • readStringArray(property: string, deviceRoot?: string): string[]

readStringArrayAsType

  • readStringArrayAsType<T>(property: string, deviceRoot?: string): T[]

readStringAsType

  • readStringAsType<T>(property: string, deviceRoot?: string): T

readStringSelector

  • readStringSelector(property: string, deviceRoot?: string): string

registerEventCallback

  • registerEventCallback(callbackFunction: function, eventPredicate: function, firstTriggerOnly?: boolean, userCallbackData?: any): void
  • Parameters

    • callbackFunction: function
        • (err?: Error, userData?: any): void
        • Parameters

          • Optional err: Error
          • Optional userData: any

          Returns void

    • eventPredicate: function
        • (userData?: any): boolean
        • Parameters

          • Optional userData: any

          Returns boolean

    • Default value firstTriggerOnly: boolean = false
    • Optional userCallbackData: any

    Returns void

registerEventPromise

  • registerEventPromise(eventPredicate: function, userCallbackData?: any): Promise<any>
  • Parameters

    • eventPredicate: function
        • (userData?: any): boolean
        • Parameters

          • Optional userData: any

          Returns boolean

    • Optional userCallbackData: any

    Returns Promise<any>

set

  • set(propertyDefs: any): void
  • Parameters

    • propertyDefs: any

    Returns void

setNumber

  • setNumber(property: string, value: number): void

setProperty

  • setProperty(property: string, value: any): any

setString

  • setString(property: string, value: string): void

Generated using TypeDoc