Reference Source Test
public class | source

MotionDriver

Extends:

src/drivers/motion/MotionDriverSimulator.js~EventEmitter → MotionDriver

Driver enables communication with Memristor's motion driver.

Constructor Summary

Public Constructor
public

constructor(name: String, config: Object)

Method Summary

Public Methods
public

Finish moveToCurvilinear command and prepare robot for another one

public

getPosition(): misc.Point

Get position of the robot

public

goForward(millimeters: Number): *

this method was deprecated.

Move robot forward or backward depending on sign

public

async init(): *

Check driver by checking checking communication with motion driver board

public

moveToCurvilinear(position: misc.Point, direction: Number, radius: Number, tolerance: Number): *

Move robot to absolute position but robot make curves to speed up motion.

public

moveToPosition(position: misc.Point, direction: Number): *

Move robot to absolute position

public

Request state, position and orientation from motion driver

public

reset()

Reset all settings in motion driver

public

Rotate for given angle

public

Rotate robot to given angle

public

setPositionAndOrientation(x: *, y: *, orientation: *)

Reset position and orientation

public

setSpeed(speed: Number)

Set default speed of the robot

public

softStop(): *

Stop robot by turning off motors.

public

stop(): *

Stop the robot.

Private Methods
private

_onDataReceived(buffer: Buffer, type: String)

Callback will be called when new packet is arrived and it will dispatch event to new callback depending on packet type

private

_onPReceived(buffer: Buffer)

Packet type P is received

Public Constructors

public constructor(name: String, config: Object) source

Params:

NameTypeAttributeDescription
name String

Unique driver name

config Object

Configuration presented as an associative array

config.startPosition strategy.TunedPoint
  • optional

X coordinate for start position

config.startOrientation strategy.TunedAngle
  • optional

Start orientation

config.startSpeed Number
  • optional

Initial speed

config.refreshDataPeriod Number
  • optional

Get state from motion driver every refreshDataPeriod in ms

config.connectionTimeout Number
  • optional

Connection timeout in ms

config.ackTimeout Number
  • optional

Acknowledgment timeout

Public Methods

public finishCommand() source

Finish moveToCurvilinear command and prepare robot for another one

public getPosition(): misc.Point source

Get position of the robot

Return:

misc.Point

Position of the robot

public goForward(millimeters: Number): * source

this method was deprecated.

Move robot forward or backward depending on sign

Params:

NameTypeAttributeDescription
millimeters Number

Return:

*

public async init(): * source

Check driver by checking checking communication with motion driver board

Return:

*

public moveToCurvilinear(position: misc.Point, direction: Number, radius: Number, tolerance: Number): * source

Move robot to absolute position but robot make curves to speed up motion. This command requires finishCommand() before next motion command.

Params:

NameTypeAttributeDescription
position misc.Point

Required position of the robot

direction Number

Direction, can be MotionDriver.DIRECTION_FORWARD or MotionDriver.DIRECTION_BACKWARD

radius Number
tolerance Number

Return:

*

public moveToPosition(position: misc.Point, direction: Number): * source

Move robot to absolute position

Params:

NameTypeAttributeDescription
position misc.Point

Required position of the robot

direction Number

Direction, can be MotionDriver.DIRECTION_FORWARD or MotionDriver.DIRECTION_BACKWARD

Return:

*

public requestRefreshData() source

Request state, position and orientation from motion driver

public reset() source

Reset all settings in motion driver

public rotateFor(angle: Number): Promise source

Rotate for given angle

Params:

NameTypeAttributeDescription
angle Number

Return:

Promise

public rotateTo(angle: Number): Promise source

Rotate robot to given angle

Params:

NameTypeAttributeDescription
angle Number

Angle

Return:

Promise

public setPositionAndOrientation(x: *, y: *, orientation: *) source

Reset position and orientation

Params:

NameTypeAttributeDescription
x *

{Number} - New X coordinate relative to start position of the robot

y *

{Number} - New Y coordinate relative to start position of the robot

orientation *

{Number} - New robot's orientation

public setSpeed(speed: Number) source

Set default speed of the robot

Params:

NameTypeAttributeDescription
speed Number

Speed (0 - 255)

public softStop(): * source

Stop robot by turning off motors.

Return:

*

public stop(): * source

Stop the robot.

Return:

*

Private Methods

private _onDataReceived(buffer: Buffer, type: String) source

Callback will be called when new packet is arrived and it will dispatch event to new callback depending on packet type

Params:

NameTypeAttributeDescription
buffer Buffer

Payload

type String

Packet type

private _onPReceived(buffer: Buffer) source

Packet type P is received

Params:

NameTypeAttributeDescription
buffer Buffer

Payload