Back to Top

mep-master master

Memristor's Eurobot Platform

new Mep()

Proxy to custom require(), Log, Config, DriverManager & services.

Returns

Void

Mep.require(library)

Global function to require library relative to src directory

Parameters

Name Type Description
library String
  • Path to library

Examples

const Task = Mep.require('utils/Task');

Returns

Object

  • Required library

getDriver(driver)

Proxy to method Mep.DriverManager.getDriver(driver)

Parameters

Name Type Description
driver

{String} - Driver name

Examples

let servo = Mep.getDriver('ArmFirstAX12');

Returns

Object

  • Instance of required driver

new Telemetry()

Enables communication between mep-master and mep-dash.

Returns

Void

send(tag, action, params)

Send log or command to mep-dash.

Parameters

Name Type Description
tag

{String} - Message tag

action

{String} - Message action

params

{Object} - Additional parameters of interest to action

Returns

Void

genOn(tag, action)

Helper that generates query string for .on()

Parameters

Name Type Description
tag

{String} - Message tag

action

{String} - Message action

Returns

string

  • Generated query string for .on()

new DriverChecker()

A goal of the class is to check if drivers are correctly implemented.

Returns

Void

DriverChecker()

Returns

Void

new DriverManager()

Class manipulate drivers

DriverManager provides mechanisms to:

  • initialize and configure drivers based on config files,
  • return instance of driver by driver unique identifier,
  • filter drivers by groups,
  • check if driver is available,
  • resolve dependencies and
  • put driver out of order or recover driver if it is possible.

Each driver can be part of one or more of following groups: control, terrain & position.

Returns

Void

isDriverOutOfOrder(name)

Check if driver is out of order

Parameters

Name Type Description
name String

Unique name of a driver

Returns

Boolean

getDriver(name)

Get driver instance by driver name

Parameters

Name Type Description
name String

Driver name, eg. "MotionDriver", or "ModbusDriver".

Returns

Object

Required driver

isDriverAvailable(name)

Returns true if driver is available

Parameters

Name Type Description
name String

Driver name

Returns

Boolean

Is driver available

getDriversByGroup(type)

Get all drivers that can provide specific type of data.

Every driver that can provide a certain type of data has implemented universal mechanism for getting that data from the driver. That is extremely useful for services and in that case services implement only logic for data processing, not mechanisms for data collection from different drivers. Services are in this case also hardware independent.

Parameters

Name Type Description
type String

Data type which driver can provide. Can be: position & terrain.

Returns

Object

List of filtered drivers

callMethodByGroup(type, method, params)

Get all drivers that can provide specific type of data (or execute specific command) and call method.

Eg. imagine you have laptop and monitor. If a monitor is not available then your laptop is it totally ok with it, image will be sent only to laptop's monitor. However, if there is a monitor connected to the laptop then laptop will be aware of monitor and it will send an image to monitor too. Your laptop don't really recognize difference between displays, and it communicates between them in very similar way. To sum up, the same is for this method, method will be called to all drivers that are the part of the group.

Parameters

Name Type Description
type String

Data type which driver can provide. Can be: position & terrain.

method String

Method to be called.

params Array

Params to be passed to method.

Returns

Void

putDriverOutOfOrder(name, message)

Put driver out of order

Parameters

Name Type Description
name String

Unique name of a driver

message String

Describe more why the fault happened

Returns

Void

EventEmitter()

Returns

Void

new CanDriver()

Driver for CAN bus (Controller Area Network)

Returns

Void

CanDriver.constructor(name, config)

Parameters

Name Type Description
name String

Unique name of a driver

config Object

Configuration presented as an associative array

config.device String

Device ID

config.bitrate Number

CAN bus speed

Returns

Void

send(id, buffer)

Send buffer to specific ID

Parameters

Name Type Description
id Number

Device ID

buffer Buffer

Data

Examples

canDriver.send(0x4324234, Buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72, 0x00, 0x00]));

Returns

Void

_startCAN(device, bitrate) private method

Start CAN bus device

Parameters

Name Type Description
device String
bitrate Number

Returns

Void

EventEmitter()

Returns

Void

new CanDriverSimulator()

Driver that simulates CAN bus

Returns

Void

EventEmitter()

Returns

Void

new ColorDriver()

Driver detects color based on RGB components

Returns

Void

ColorDriver.start(interval)

Start reading data from sensor

Parameters

Name Type Description
interval Number

Receive RGB components every interval[ms]

Returns

Void

ColorDriver.stop()

Stop receiving RGB components

Returns

Void

ColorDriver.getColor()

Get last read color

Returns

String

Color

ColorDriver.rgbToHsv(r, g, b)

Converts an RGB color value to HSV. Conversion formula adapted from http://en.wikipedia.org/wiki/HSV_color_space. Assumes r, g, and b are contained in the set [0, 255] and returns h, s, and v in the set [0, 1].

Parameters

Name Type Description
r Number

The red color value

g Number

The green color value

b Number

The blue color value

Returns

Array The HSV representation

ColorDriver.rgbToHsl(r, g, b)

Converts an RGB color value to HSL. Conversion formula adapted from http://en.wikipedia.org/wiki/HSL_color_space. Assumes r, g, and b are contained in the set [0, 255] and returns h, s, and l in the set [0, 1].

Parameters

Name Type Description
r Number

The red color value

g Number

The green color value

b Number

The blue color value

Returns

Array The HSL representation

TaskError()

Returns

Void

new DynamixelDriver()

Communicates with dynamixel servos (AX12 & RX24). NOTE: This class doesn't send start bytes & checksum, please make custom communicator (@dependecies.communicator) if you want these features.

Returns

Void

DynamixelDriver.go(position[, config])

Set servo to required position and get promise when position is reached

Parameters

Name Type Description
position

{Number} - Required position in degrees

config Object

Configuration options.

Optional
config.pollingPeriod Number

Polling period for servo's present position in ms

Optional
config.tolerance Number

Tolerated error in degrees

Optional
config.timeout Number

Maximal time servo to reach a position in ms

Optional
config.firmwareImplementation Boolean

Should it use firmware (true) or software (false) implementation. Firmware implementation is faster, however in that case we have to have a dedicated hardware (our actuator board supports it).

Optional

Returns

Void

TAG()

Returns

Void

new HBridgeDriver(config)

Parameters

Name Type Description
config Object

Additional parameters

config.cid Number

Communication ID

Optional
[email protected] String

Name of communication driver

Optional

Returns

Void

EventEmitter()

Returns

Void

new InfraredDriver()

Uses data from infrared sensors to determine where is an enemy robot and other obstacles.

Returns

Void

InfraredDriver.constructor(name, config'@dependencies')

Make instance of InfraredDriver.

Check image bellow to understand `sensorAngle`, `sensorX` & `sensorY`
 s1   s2   s3
  \   |   /
 |---------|
 |  Robot  |
 |_________|

 Sensor s1 params: sensorAngle~=110, sensorY~10, sensorX~=10
 Sensor s2 params: sensorAngle~=90, sensorY~=0, sensorX~=10
 Sensor s3 params: sensorAngle~=60, sensorY~=-10, sensorX~=10
 

Parameters

Name Type Description
name

{String} - Unique driver name

config.infraredMaxDistance

{Number} - Maximum distance when driver detects an object

config.sensorAngle

{Number} - Angle relative to the robot (look at the picture above)

config.sensorX

{Number} - Sensor translated on x coordinate

config.sensorY

{Number} - Sensor translated on y coordinate

config.cid

{Number} - Function ID for CAN driver

config.objectSize

{Number} - Approximation coefficient for obstacle size. Distance between edges and point of interest,

config'@dependencies'

{String} - ID of Driver can provide communication between core and electronics

Returns

Void

InfraredDriver.enable()

Enable sensor

Returns

Void

InfraredDriver.disable()

Disable sensor

Returns

Void

InfraredDriver.processDetection(buffer) private method

Process detected obstacle

Parameters

Name Type Description
buffer

{Boolean} - Object is detected or not

Returns

Void

EventEmitter()

Returns

Void

new LidarDriver()

Provides an abstraction layer on top of lidar's firmware and algorithms to determine robot's position and obstacles

Returns

Void

LidarDriver.enable()

Enable lidar driver

Returns

Void

LidarDriver.disable()

Disable lidar driver

Returns

Void

LidarDriver._addPointToPolyGenerator(angle, distance) private method

Process a measurement and try to make an obstacle approximation. It uses bounding box algorithm to make an approximation of the obstacle

Parameters

Name Type Description
angle Number

Angle of the measurement

distance Number

Distance to the closest point at given angle

Returns

Void

_onDataReceived(data) private method

Process data from lidar

Parameters

Name Type Description
data Buffer

Buffer from lidar

Returns

Void

TAG()

Returns

Void

new LunarCollectorDriver()

Parameters

Name Type Description
config.leftTrack String

Name of Dynamixel driver which runs left track

config.rightTrack String

Name of Dynamixel driver which runs right track

config.leftHand String

Name of Dynamixel driver which runs left hand

config.rightHand String

Name of Dynamixel driver which runs right hand

Returns

Void

ModbusDriverBinder()

Returns

Void

new ModbusDriver()

Driver for Modbus communication protocol.

Returns

Void

ModbusDriver.constructor(name, config)

Creates instance of ModbusDriver

Parameters

Name Type Description
name

{String} - Unique name of a driver

config

{Object} - Configuration presented as an associative array

Returns

Void

EventEmitter()

Returns

Void

new ModbusDriverSimulator()

Simulation for Modbus communication protocol

Returns

Void

Point()

Returns

Void

new MotionDriver()

Driver enables communication with Memristor's motion driver.

Returns

Void

MotionDriver.constructor(name, config)

Parameters

Name Type Description
name String

Unique driver name

config Object

Configuration presented as an associative array

config.startPosition strategy.TunedPoint

X coordinate for start position

Optional
config.startOrientation strategy.TunedAngle

Start orientation

Optional
config.startSpeed Number

Initial speed

Optional
config.refreshDataPeriod Number

Get state from motion driver every refreshDataPeriod in ms

Optional
config.connectionTimeout Number

Connection timeout in ms

Optional
config.ackTimeout Number

Acknowledgment timeout

Optional

Returns

Void

finishCommand()

Finish moveToCurvilinear command and prepare robot for another one

Returns

Void

reset()

Reset all settings in motion driver

Returns

Void

requestRefreshData()

Request state, position and orientation from motion driver

Returns

Void

setPositionAndOrientation(x, y, orientation)

Reset position and orientation

Parameters

Name Type Description
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

Returns

Void

rotateTo(angle)

Rotate robot to given angle

Parameters

Name Type Description
angle Number

Angle

Returns

Promise

rotateFor(angle)

Rotate for given angle

Parameters

Name Type Description
angle Number

Returns

Promise

goForward(millimeters)

Move robot forward or backward depending on sign

Parameters

Name Type Description
millimeters Number

Returns

Void

stop()

Stop the robot.

Returns

Void

softStop()

Stop robot by turning off motors.

Returns

Void

setSpeed(speed)

Set default speed of the robot

Parameters

Name Type Description
speed Number

Speed (0 - 255)

Returns

Void

moveToPosition(position, direction)

Move robot to absolute position

Parameters

Name Type Description
position misc.Point

Required position of the robot

direction Number

Direction, can be MotionDriver.DIRECTION_FORWARD or MotionDriver.DIRECTION_BACKWARD

Returns

Void

moveToCurvilinear(position, direction, radius, tolerance)

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

Parameters

Name Type Description
position misc.Point

Required position of the robot

direction Number

Direction, can be MotionDriver.DIRECTION_FORWARD or MotionDriver.DIRECTION_BACKWARD

radius Number
tolerance Number

Returns

Void

_onPReceived(buffer) private method

Packet type P is received

Parameters

Name Type Description
buffer Buffer

Payload

Returns

Void

_onDataReceived(buffer, type) private method

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

Parameters

Name Type Description
buffer Buffer

Payload

type String

Packet type

Returns

Void

getPosition()

Get position of the robot

Returns

misc.Point

Position of the robot

TAG()

Returns

Void

new MotionDriverController()

Remote controller for motion driver

Returns

Void

MotionDriverBinder()

Returns

Void

new MotionDriverNative()

Natively (C++) implemented driver that enables communication with Memristor's motion driver.

Returns

Void

MotionDriverNative.constructor(name, config)

Parameters

Name Type Description
name

{String} - Unique driver name

config

{Object} - Configuration presented as an associative array

Returns

Void

getPosition()

Get position of the robot

Returns

Point

  • Position of the robot

Point()

Returns

Void

new MotionDriverSimulator()

MotionDriverSimulator simulation module. Has same methods as MotionDriver but this module send all commands to simulator.

Returns

Void

EventEmitter()

Returns

Void

new PinDriver()

Communicates with pins on microcontrollers.

Returns

Void

PinDriver.getLastValue()

Get last value

Examples

let value = Mep.getDriver('PinDriver').getLastState();

Returns

Number

High or low

PinDriver.read()

Read value of given pin

Examples

Mep.getDriver('PinDriver').read((value) => { console.log(value) });

Returns

Promise

PinDriver.write(value)

Write value to given pin

Parameters

Name Type Description
value Number

[0, 1] for digital pins or [0 - 255] for analog pins

Returns

Void

EventEmitter()

Returns

Void

new StarterDriver()

Detects when rope is pulled out of the robot and starts counting game time.

Returns

Void

getTime()

Get time in seconds since match is started

Returns

number

  • Seconds since match is started

getTimeMills()

Get time in milliseconds since match is started

Returns

Number

Milliseconds since match is started

waitStartSignal()

Wait a start match signal (pulled rope, pressed key or delay)

Returns

Promise

fs()

Returns

Void

new Uart()

Driver enables uart communication with electronic boards

Returns

Void

Uart.constructor(name)

Parameters

Name Type Description
name

{String} - Unique name of driver

config.device

{String} - Linux dev which will be used for serial communication

config.baudRate

{Number} - Bits per second

config.protocol

{String} - Name of protocol that will be used under the hood, check list of available protocols in misc/protocols

Returns

Void

Uart._onPacketReceived(packet, type) private method

Method will be called only if protocol is not null and protocol generated packet.

Parameters

Name Type Description
packet Buffer

Parsed packet

type String

Single character that represents type of packet

Returns

Void

Uart.send(buffer, callback, type)

Send data to Uart

Parameters

Name Type Description
buffer

{Buffer} - Buffer of data which will be sent to uart

callback

{Function} - Callback function which will be called after data is sent

type

{Number} - Type of packet, will be ignored if protocol doesn't support

Returns

Void

Usage()

Returns

Void

new UsageDriver()

Logs memory and cpu usage

Examples

...
"UsageDriver": {
    "class": "drivers/usage/UsageDriver",
    "load": true,
    "refreshPeriod": 1000
}
...

Returns

Void

TAG()

Returns

Void

new CallbackQueue()

Queue of callback functions. It used when you want to allow other modules to subscribe to your events.

Returns

Void

CallbackQueue.add(callback)

Subscribe on event. Add callback function to queue.

Parameters

Name Type Description
callback function
  • Pointer on callback function

Returns

Void

CallbackQueue.notifyAll(params)

Call all callback functions from queue with same parameters.

Parameters

Name Type Description
params Array
  • Params which will passed to callback functions

Returns

Void

new CircularBuffer()

Implementation of circular buffer using Node.js's Buffer

Returns

Void

Point()

Returns

Void

new Line()

Line in 2D space

Returns

Void

Line.constructor(startPoint, endPoint)

Parameters

Name Type Description
startPoint misc.Point

Start point of the line

endPoint misc.Point

End point of the line

Returns

Void

Line.getStartPoint()

Get start point

Returns

misc.Point

Line.getEndPoint()

Get end point

Returns

misc.Point

Line.isIntersectWithLine(line)

Check if it intersect with another line

Parameters

Name Type Description
line misc.Line

Another line to check intersection with

Returns

Boolean

True if two lines intersect

Line.isIntersectWithPolygon(polygon)

Check if it intersect with polygon

Parameters

Name Type Description
polygon misc.Polygon

Polygon to check intersection with

Returns

Boolean

True if line intersect polygon

new Point()

Point in 2D space

Returns

Void

Point.constructor(x, y)

Make new point.

Parameters

Name Type Description
x Number

X coordinate

y Number

Y coordinate

Returns

Void

Point.getDistance(point)

Calculate Euclidean distance between two Points

Parameters

Name Type Description
point misc.Point

Another point to compare with

Returns

number

Distance between two Points

Point.equals(point)

Check if points are equal

Parameters

Name Type Description
point Point

Another point to be compared

Returns

Boolean

Point.translate(translatePoint)

Translate point

Parameters

Name Type Description
translatePoint

Returns

Void

Point.rotate(originPoint, angleDegrees)

Rotate point around origin point

Parameters

Name Type Description
originPoint misc.Point

Origin point

angleDegrees Number

Rotation angle

Returns

misc.Point

Point.rotateAroundZero(angleDegrees)

Optimized algorithm for point rotation around coordinate beginning

Parameters

Name Type Description
angleDegrees

{Number}

Returns

misc.Point

Point.clone()

Clone the point

Returns

misc.Point

Cloned point

Point.setY(y)

Set Y coordinate

Parameters

Name Type Description
y Number

Y coordinate

Returns

Void

Point.setX(x)

Set X coordinate

Parameters

Name Type Description
x Number

X coordinate

Returns

Void

Point.getX()

Return x coordinate

Returns

Number

Point.getY()

Returns y coordinate

Returns

Number

Point()

Returns

Void

new Polygon()

Describes an polygon

Returns

Void

Polygon.constructor(tag, duration, points)

Parameters

Name Type Description
tag String

Additional information about polygon to describe it

duration Number

Polygon will be destroyed after given number of milliseconds

points Array.<misc.Point>

Array of points which can describe an polygon

Returns

Void

Polygon.translate(translatePoint)

Translate all points of polygon

Parameters

Name Type Description
translatePoint misc.Point

Point which represents x and y value of translation

Returns

Void

Polygon.rotate(originPoint, angleDegrees)

Rotate all points of polygon around an origin point

Parameters

Name Type Description
originPoint misc.Point

Center point of rotation

angleDegrees Number

Required angle of rotation

Returns

Void

Polygon.getPoints()

Returns

Array.<misc.Point>

Get an array of points which describe a polygon

Polygon.getDuration()

Returns

Number

Get duration of milliseconds after the polygon will be destroyed

Polygon.getTag()

Returns

String

Get unique identifier of polygon

Polygon.clone()

Clone a polygon

Returns

misc.Polygon

Cloned polygon

Polygon.rotateAroundZero(angleDegrees)

Optimized algorithm for polygon rotation around coordinate beginning

Parameters

Name Type Description
angleDegrees Number

Returns

misc.Polygon

new PLLSP()

Packetized Low-Level Secured Protocol

0                   1                   2                   3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+--------------+-------+-------+---------------+----------------+
|  Start Byte  | Header|Payload|  Packet type  | Payload length |
|    (0x3C)    |    Checksum   |               |                |
+-------------------------------- - - - - - - - - - - - - - - - +
:                     Payload Data continued ...                :
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
|                     Payload Data continued ...                |
+---------------------------------------------------------------+

Returns

Void

PLLSP.constructor()

Parameters

Name Type Description
config.bufferSize

{Number} - Length of receive buffer

config.onDataCallback

{Function(data, type)} - Pointer on callback which be called when data is ready

Returns

Void

PLLSP.generate(buffer, type)

Generate packet

Parameters

Name Type Description
buffer

{Buffer} - Payload for packet

type

{Number} - Type for packet, if it is not defined int('U') will be used

Returns

Buffer

  • Packet as buffer of bytes

PLLSP.push(chunkBuffer)

Push received data to receive buffer

Parameters

Name Type Description
chunkBuffer

{Buffer} - Chunk buffer

Returns

Void

TaskError()

Returns

Void

new MotionService()

Provides a very abstract way to control and estimate robot position

Returns

Void

MotionService.go(tunedPoint[, parameters])

Move the robot, set new position of the robot

Parameters

Name Type Description
tunedPoint TunedPoint

Point that should be reached

parameters Object

Configuration options.

Optional
parameters.pf Boolean

Use terrain finding algorithm.

Optional
parameters.backward Boolean

Set backward robot moving.

Optional
parameters.rerouting Boolean

Enable rerouting during the movement.

Optional
parameters.relative Boolean

Use relative to previous position.

Optional
parameters.tolerance Number

Position will consider as reached if Euclid's distance between current and required position is less than tolerance.

Optional
parameters.speed Number

Speed of the robot movement in range (0, 255).

Optional
parameters.obstacle Number

Time [ms] after command will be rejected (with TaskError.action === 'obstacle') if obstacle is detected in hazard region

Optional
parameters.friend Number

Time [ms] after command will be rejected (with TaskError.action === 'friend') if friend is detected in hazard region

Optional

Returns

Promise

MotionService._goSingleTarget(point, params) private method

Go to single point without advanced features

Parameters

Name Type Description
point misc.Point

Target point

params Object

Additional options

params.backward Boolean

Move robot backward

Optional
params.tolerance Number

Max radius

Optional
params.speed Number

Speed

Optional

Returns

Promise

MotionService.stop(softStop)

Stop the robot

Parameters

Name Type Description
softStop Boolean

If true robot will turn of motors

Returns

Void

MotionService.straight(millimeters, params)

Move robot forward or backward depending on param millimeters

Parameters

Name Type Description
millimeters Number

Path that needs to be passed. If negative robot will go backward

params Object
params.speed Number

Speed

Optional

Returns

Promise

MotionService.rotate(tunedAngle, options)

Rotate robot for an angle

Parameters

Name Type Description
tunedAngle TunedAngle

Angle to rotate

options Object

Additional options

Returns

Promise

TAG()

Returns

Void

new MotionTarget()

Target (point & params) that robot has to reach

Returns

Void

MotionTarget()

Returns

Void

new MotionTargetQueue()

Queue of targets (points) that robot has to reach.

Returns

Void

MotionTargetQueue.getTargets()

Get all targets

Returns

Array.<services.motion.MotionTarget>

  • List of all targets

MotionTargetQueue.addPointsBack(points, params)

Add points at the end of the queue

Parameters

Name Type Description
points

{Array<misc.Point>} - Array of points

params

{Object} - Params for each target

Returns

Void

MotionTargetQueue.addPointBack(point, params)

Add single point at the end of the queue

Parameters

Name Type Description
point

{misc.Point} - Point

params

{Object} - Params for target

Returns

Void

MotionTargetQueue.addPointsFront(points, params)

Add points at the beginning of the queue

Parameters

Name Type Description
points

{Array<misc.Point>} - Array of points

params

{Object} - Params for each target

Returns

Void

MotionTargetQueue.addPointFront(point, params)

Add single point at the beginning of the queue

Parameters

Name Type Description
point misc.Point

Point

params Object

Params for target

Returns

Void

MotionTargetQueue.getTargetFront()

Get target at the front of queue

Returns

services.motion.MotionTarget

MotionTargetQueue.getTargetBack()

Get target at the end of the queue

Returns

services.motion.MotionTarget

MotionTargetQueue.getPfLine()

Make line between current position and target if path finding is enabled

Returns

misc.Line

MotionTargetQueue.getPfTarget()

Get final target of path finding algorithm if path finding is enabled

Returns

MotionTarget

MotionTargetQueue.removeFront()

Remove target from front of queue

Returns

Void

MotionTargetQueue.removeBack()

Remove target from back of queue

Returns

Void

MotionTargetQueue.isEmpty()

Check if queue is empty

Returns

Void

MotionTargetQueue.empty()

Delete all items from queue

Returns

Void

Point()

Returns

Void

new PositionService()

Implements algorithms to collect data from sensors and determine current robot's location

Returns

Void

PositionService.getPosition()

Get current robot's position

Returns

misc.Point

Current position

PositionService.getOrientation()

Get current robot's orientation

Returns

Number

Orientation in degrees

Task()

Returns

Void

new SchedulerService()

Implements algorithms to schedule task execution

Returns

Void

SchedulerService.recommendNextTask(tasks)

Algorithm to choose the best task

Parameters

Name Type Description
tasks Array.<strategy.Task>

Array of available tasks

Returns

strategy.Task

EventEmitter()

Returns

Void

new ShareService()

Automatically shares position, obstacles and task statuses between robots and provides simple API to share custom messages.

Examples

Mep.Share.send('ROBOT_ARRIVED_TO_POSITION');
Mep.Share.on('message', (message) => { console.log(message); });

Returns

Void

EventEmitter()

Returns

Void

new Udp()

Provides sharing based on UDP protocol. Same prototype should be used for other protocols.

Returns

Void

Point()

Returns

Void

new TerrainService()

Class represent obstacles on the terrain and mechanism to search terrain between objects.

Returns

Void

PathFindingBinder()

Returns

Void

constructor(maxX, minX, maxY, minY)

Creates terrain finding algorithm for an area

Parameters

Name Type Description
maxX

{Number} - Maximal value of X coordinate

minX

{Number} - Minimal value of X coordinate

maxY

{Number} - Maximal value of Y coordinate

minY

{Number} - Minimal value of Y coordinate

Returns

Void

TAG()

Returns

Void

new Scheduler()

Default scheduler class describes general task scheduling and robot behaviour

Examples

class MyScheduler extends Scheduler {
 constructor() {
     this.tasks = [
         new InitTask(this, { weight: 10000, time: 10, location: new Point(0, 0) })
     ];
 }
 runNextTask() {
     // Here you can override default scheduler
 }
}

Returns

Void

Scheduler.onUnhandledTaskError(reason)

Run default action if there is the exception in task is not caught with try {} catch(e) {}.

Parameters

Name Type Description
reason TaskError

Describes more about an exception

Returns

Void

Scheduler.getTasks()

Get all registered task

Returns

Array

Array of tasks type Task

TunedPoint()

Returns

Void

new Shortcut()

Populates global space with short functions and variables in order to provide easier and faster way to write strategies. NOTE: Polluting a global space generally is not a good way to go, however after a year of experience in this case it is a good solution.

Examples

Shortcut.make();

Returns

Void

Point()

Returns

Void

new Task()

Default task class describes general task robot behaviour during task execution

Returns

Void

constructor(scheduler, parameters)

Default constructor for task

Parameters

Name Type Description
scheduler

{Scheduler} Reference to strategy's scheduler

parameters Object

Additional params

parameters.weight Number

Importance of the task, initial order

parameters.time Number

Predicted time to be executed

parameters.location misc.Point

Predicted area of execution

Returns

Void

finish()

Finish this task and run next one

Returns

Void

suspend()

Suspend this task and run next one

Returns

Void

getWeight()

Get weight of current task

Returns

Number

getTime()

Get predicted time of current task

Returns

Number

getState()

Get current state

Returns

Number

Can be Task.READY, Task.SUSPENDED, Task.ACTIVE and Task.FINISHED

setState(state)

Set current state

Parameters

Name Type Description
state Number

Can be Task.READY, Task.SUSPENDED, Task.ACTIVE and Task.FINISHED

Returns

Void

setWeight(weight)

Change default weight of the task

Parameters

Name Type Description
weight

{Number}

Returns

Void

plusPriority()

Change priority during runtime

Returns

number

run()

Run current task and change a state

Returns

Void

onRun()

This method will be executed as soon as mep run this task

Returns

Void

isAvailable()

Condition which will be checked by SchedulerService to decide to run task or not. Eg. Release lunar modules only if there is lunar modules inside robot

Returns

Boolean

Returns true if task is ready to be executed

new TaskError()

Describes an error during strategy execution (eg. robot stuck)

Returns

Void

TaskError.constructor(source, action, message, params)

Default constructor for class

Parameters

Name Type Description
source String

Name of module which thrown an error

action String

Unique identifier for task error

message String

Describes more about task error

params Object

Additional parameters to describe an error

Returns

Void

TAG()

Returns

Void

new TunedAngle()

Tunable angle. Angle is chosen depends on table name in configuration.

Examples

new TuneAngle(
     150,
     [151, 'table_1'],
     [148, 'table_2']
);

Returns

Void

TunedAngle.constructor(defaultAngle)

Add multiple angles, add angle for each table. It must has at least one angle which will be used as default. Other angles must have tag!

Parameters

Name Type Description
defaultAngle Number

Default point X coordinate

Returns

Void

TunedAngle.getAngle()

Get angle depending on the chosen table in configuration.

Returns

Number

Angle

Point()

Returns

Void

new TunedPoint()

Tunable Point. Point coordinates are choose depends on table name in configuration.

Examples

new TunePoint(
     150, 129,
     [151, 129, 'table_1'],
     [148, 128, 'table_2']
);

Returns

Void

TunedPoint.constructor(defaultX, defaultY)

Add multiple Points, add Points for each table. It must has at least one Point which will be used as default. Other Points must have tag!

Parameters

Name Type Description
defaultX Number

Default point X coordinate

defaultY Number

Default point Y coordinate

Returns

Void

TunedPoint.getPoint()

Get point depending on the chosen table in configuration.

Returns

Point

Point

new Console()

Simplified functions for mep command prompt. All methods are accessible by using t. prefix.

Returns

Void

drivers()

List all available drivers for current current configuration

Examples

mep > t.drivers()

Returns

Void

driver(id)

List driver properties for driver with id

Parameters

Name Type Description
id String

Examples

mep > t.driver('MotionDriver')

Returns

Void

new Console()

Simplified functions for mep command prompt. All methods are accessible by using t. prefix.

Returns

Void

drivers()

List all available drivers for current current configuration

Examples

mep > t.drivers()

Returns

Void

driver(id)

List driver properties for driver with id

Parameters

Name Type Description
id String

Examples

mep > t.driver('MotionDriver')

Returns

Void