Home Manual Reference Source Test Repository
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: *, config: *)

Method Summary

Public Methods
public

Finish moveToCurvilinear command and prepare robot for another one

public

Get position of the robot

public

goForward(millimeters: *): *

this method was deprecated.

Move robot forward or backward depending on sign

public

init(): *

Check driver by checking checking communication with motion driver board

public

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

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

public

moveToPosition(position: *, direction: *): *

Move robot to absolute position

public

Request state, position and orientation from motion driver

public

reset()

Reset all settings in motion driver

public

rotateTo(angle: *): *

Rotate robot to given angle

public

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

Reset position and orientation

public

setRefreshInterval(interval: *)

Set required refresh interval of robot status.

public

setSpeed(speed: *)

Set default speed of the robot

public

softStop(): *

Stop robot by turning off motors.

public

stop(): *

Stop the robot.

Private Methods
private

_onDataReceived(buffer: *, type: *)

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

private

_onPReceived(buffer: *)

Packet type P is received

Public Constructors

public constructor(name: *, config: *) source

Params:

NameTypeAttributeDescription
name *

{String} - Unique driver name

config *

{Object} - Configuration presented as an associative array

Public Methods

public finishCommand() source

Finish moveToCurvilinear command and prepare robot for another one

public getPosition(): Point source

Get position of the robot

Return:

Point

Position of the robot

public goForward(millimeters: *): * source

this method was deprecated.

Move robot forward or backward depending on sign

Params:

NameTypeAttributeDescription
millimeters *

Return:

*

public init(): * source

Check driver by checking checking communication with motion driver board

Return:

*

public moveToCurvilinear(position: misc.Point, direction: 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

tolerance Number

Radius

Return:

*

public moveToPosition(position: *, direction: *): * 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 rotateTo(angle: *): * source

Rotate robot to given angle

Params:

NameTypeAttributeDescription
angle *

{Number} - Angle

Return:

*

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 setRefreshInterval(interval: *) source

Set required refresh interval of robot status. Note that it is required refresh interval and robot can choose to send or not depending on it's state.

Params:

NameTypeAttributeDescription
interval *

{Number} - Period in milliseconds

public setSpeed(speed: *) 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: *, type: *) 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: *) source

Packet type P is received

Params:

NameTypeAttributeDescription
buffer *

{Buffer} - Payload