# getDriver(driver)
Proxy to method Mep.DriverManager.getDriver(driver)
Parameters
Name | Types | Description |
---|---|---|
driver |
|
{String} - Driver name |
# require(library)
Global function to require library relative to src
directory
Parameters
Name | Types | Description |
---|---|---|
library | String |
- Path to library |
# ync()
Initialize necessary modules. Should be called only once during an application bootstrapping
# genOn(tag, action)
Helper that generates query string for .on()
Parameters
Name | Types | Description |
---|---|---|
tag |
|
{String} - Message tag |
action |
|
{String} - Message action |
Returns
string
- Generated query string for .on()
# send(tag, action, params)
Send log or command to mep-dash.
Parameters
Name | Types | Description |
---|---|---|
tag |
|
{String} - Message tag |
action |
|
{String} - Message action |
params |
|
{Object} - Additional parameters of interest to action |
# 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 | Types | 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. |
# DriverChecker()
# 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.
# getDriver(name)
Get driver instance by driver name
Parameters
Name | Types | Description |
---|---|---|
name | String |
Driver name, eg. "MotionDriver", or "ModbusDriver". |
# 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 | Types | Description |
---|---|---|
type | String |
Data type which driver can provide. Can be: position & terrain. |
# isDriverAvailable(name)
Returns true if driver is available
Parameters
Name | Types | Description |
---|---|---|
name | String |
Driver name |
# isDriverOutOfOrder(name)
Check if driver is out of order
Parameters
Name | Types | Description |
---|---|---|
name | String |
Unique name of a driver |
# putDriverOutOfOrder(name, message)
Put driver out of order
Parameters
Name | Types | Description |
---|---|---|
name | String |
Unique name of a driver |
message | String |
Describe more why the fault happened |
# _startCAN(device, bitrate)
private method
Start CAN bus device
Parameters
Name | Types | Description |
---|---|---|
device | String |
|
bitrate | Number |
# constructor(name, config, config.device, config.bitrate)
Parameters
Name | Types | 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 |
# EventEmitter()
# send(id, buffer)
Send buffer to specific ID
Parameters
Name | Types | Description |
---|---|---|
id | Number |
Device ID |
buffer | Buffer |
Data |
# EventEmitter()
# EventEmitter()
# 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 | Types | Description |
---|---|---|
r | Number |
The red color value |
g | Number |
The green color value |
b | Number |
The blue color value |
Returns
Array The HSL representation
# 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 | Types | Description |
---|---|---|
r | Number |
The red color value |
g | Number |
The green color value |
b | Number |
The blue color value |
Returns
Array The HSV representation
# start(interval)
Start reading data from sensor
Parameters
Name | Types | Description |
---|---|---|
interval | Number |
Receive RGB components every interval [ms] |
# 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.
# go(position, config, config.pollingPeriod, config.tolerance, config.timeout, config.firmwareImplementation)
Set servo to required position and get promise when position is reached
Parameters
Name | Types | Description |
---|---|---|
position |
|
{Number} - Required position in degrees |
config | Object |
Configuration options. |
config.pollingPeriod | Number |
Polling period for servo's present position in ms |
config.tolerance | Number |
Tolerated error in degrees |
config.timeout | Number |
Maximal time servo to reach a position in ms |
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). |
# TaskError()
# HBridgeDriver(config, config.cid, [email protected])
Parameters
Name | Types | Description |
---|---|---|
config | Object |
Additional parameters |
config.cid | Number |
Communication ID |
[email protected] | String |
Name of communication driver |
# TAG()
# constructor(name, config.infraredMaxDistance, config.sensorAngle, config.sensorX, config.sensorY, config.cid, config.objectSize, config['@dependencies'])
Make instance of InfraredDriver.
Check image bellow to understandsensorAngle
,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 | Types | 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 |
# EventEmitter()
# InfraredDriver()
Uses data from infrared sensors to determine where is an enemy robot and other obstacles.
# processDetection(buffer)
private method
Process detected obstacle
Parameters
Name | Types | Description |
---|---|---|
buffer |
|
{Boolean} - Object is detected or not |
# _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 | Types | Description |
---|---|---|
angle | Number |
Angle of the measurement |
distance | Number |
Distance to the closest point at given angle |
# _onDataReceived(data)
private method
Process data from lidar
Parameters
Name | Types | Description |
---|---|---|
data | Buffer |
Buffer from lidar |
# EventEmitter()
# LidarDriver()
Provides an abstraction layer on top of lidar's firmware and algorithms to determine robot's position and obstacles
# LunarCollectorDriver(config.leftTrack, config.rightTrack, config.leftHand, config.rightHand)
Parameters
Name | Types | 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 |
# TAG()
# constructor(name, config)
Creates instance of ModbusDriver
Parameters
Name | Types | Description |
---|---|---|
name |
|
{String} - Unique name of a driver |
config |
|
{Object} - Configuration presented as an associative array |
# ModbusDriverBinder()
# EventEmitter()
# _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 | Types | Description |
---|---|---|
buffer | Buffer |
Payload |
type | String |
Packet type |
# _onPReceived(buffer)
private method
Packet type P is received
Parameters
Name | Types | Description |
---|---|---|
buffer | Buffer |
Payload |
# constructor(name, config, config.startPosition, config.startOrientation, config.startSpeed, config.refreshDataPeriod, config.connectionTimeout, config.ackTimeout)
Parameters
Name | Types | Description |
---|---|---|
name | String |
Unique driver name |
config | Object |
Configuration presented as an associative array |
config.startPosition | strategy.TunedPoint |
X coordinate for start position |
config.startOrientation | strategy.TunedAngle |
Start orientation |
config.startSpeed | Number |
Initial speed |
config.refreshDataPeriod | Number |
Get state from motion driver every refreshDataPeriod in ms |
config.connectionTimeout | Number |
Connection timeout in ms |
config.ackTimeout | Number |
Acknowledgment timeout |
# goForward(millimeters)
Move robot forward or backward depending on sign
Parameters
Name | Types | Description |
---|---|---|
millimeters | Number |
# 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 | Types | 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 |
# moveToPosition(position, direction)
Move robot to absolute position
Parameters
Name | Types | Description |
---|---|---|
position | misc.Point |
Required position of the robot |
direction | Number |
Direction, can be MotionDriver.DIRECTION_FORWARD or MotionDriver.DIRECTION_BACKWARD |
# Point()
# setPositionAndOrientation(x, y, orientation)
Reset position and orientation
Parameters
Name | Types | 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 |
# setSpeed(speed)
Set default speed of the robot
Parameters
Name | Types | Description |
---|---|---|
speed | Number |
Speed (0 - 255) |
# TAG()
# constructor(name, config)
Parameters
Name | Types | Description |
---|---|---|
name |
|
{String} - Unique driver name |
config |
|
{Object} - Configuration presented as an associative array |
# MotionDriverBinder()
# MotionDriverNative()
Natively (C++) implemented driver that enables communication with Memristor's motion driver.
# MotionDriverSimulator()
MotionDriverSimulator simulation module. Has same methods as MotionDriver but this module send all commands to simulator.
# Point()
# EventEmitter()
# write(value)
Write value to given pin
Parameters
Name | Types | Description |
---|---|---|
value | Number |
[0, 1] for digital pins or [0 - 255] for analog pins |
# EventEmitter()
# 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
# _onPacketReceived(packet, type)
private method
Method will be called only if protocol is not null
and protocol generated packet.
Parameters
Name | Types | Description |
---|---|---|
packet | Buffer |
Parsed packet |
type | String |
Single character that represents type of packet |
# constructor(name, config.device, config.baudRate, config.protocol)
Parameters
Name | Types | 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 |
# fs()
# send(buffer, callback, type)
Send data to Uart
Parameters
Name | Types | 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 |
# Usage()
# add(callback)
Subscribe on event. Add callback function to queue.
Parameters
Name | Types | Description |
---|---|---|
callback | function |
- Pointer on callback function |
# CallbackQueue()
Queue of callback functions. It used when you want to allow other modules to subscribe to your events.
# notifyAll(params)
Call all callback functions from queue with same parameters.
Parameters
Name | Types | Description |
---|---|---|
params | Array |
- Params which will passed to callback functions |
# TAG()
# delay(milliseconds)
Synced setTimeout()
Parameters
Name | Types | Description |
---|---|---|
milliseconds | Number |
Milliseconds to sleep |
# constructor(startPoint, endPoint)
Parameters
Name | Types | Description |
---|---|---|
startPoint | misc.Point |
Start point of the line |
endPoint | misc.Point |
End point of the line |
# isIntersectWithLine(line)
Check if it intersect with another line
Parameters
Name | Types | Description |
---|---|---|
line | misc.Line |
Another line to check intersection with |
Returns
Boolean
True if two lines intersect
# isIntersectWithPolygon(polygon)
Check if it intersect with polygon
Parameters
Name | Types | Description |
---|---|---|
polygon | misc.Polygon |
Polygon to check intersection with |
# Point()
# constructor(x, y)
Make new point.
Parameters
Name | Types | Description |
---|---|---|
x | Number |
X coordinate |
y | Number |
Y coordinate |
# equals(point)
Check if points are equal
Parameters
Name | Types | Description |
---|---|---|
point | Point |
Another point to be compared |
# getDistance(point)
Calculate Euclidean distance between two Points
Parameters
Name | Types | Description |
---|---|---|
point | misc.Point |
Another point to compare with |
# rotate(originPoint, angleDegrees)
Rotate point around origin point
Parameters
Name | Types | Description |
---|---|---|
originPoint | misc.Point |
Origin point |
angleDegrees | Number |
Rotation angle |
# rotateAroundZero(angleDegrees)
Optimized algorithm for point rotation around coordinate beginning
Parameters
Name | Types | Description |
---|---|---|
angleDegrees |
|
{Number} |
# constructor(tag, duration, points)
Parameters
Name | Types | 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 |
# getDuration()
# getPoints()
# getTag()
# Point()
# rotate(originPoint, angleDegrees)
Rotate all points of polygon around an origin point
Parameters
Name | Types | Description |
---|---|---|
originPoint | misc.Point |
Center point of rotation |
angleDegrees | Number |
Required angle of rotation |
# rotateAroundZero(angleDegrees)
Optimized algorithm for polygon rotation around coordinate beginning
Parameters
Name | Types | Description |
---|---|---|
angleDegrees | Number |
# translate(translatePoint)
Translate all points of polygon
Parameters
Name | Types | Description |
---|---|---|
translatePoint | misc.Point |
Point which represents x and y value of translation |
# constructor(config.bufferSize, config.onDataCallback)
Parameters
Name | Types | Description |
---|---|---|
config.bufferSize |
|
{Number} - Length of receive buffer |
config.onDataCallback |
|
{Function(data, type)} - Pointer on callback which be called when data is ready |
# generate(buffer, type)
Generate packet
Parameters
Name | Types | Description |
---|---|---|
buffer |
|
{Buffer} - Payload for packet |
type |
|
{Number} - Type for packet, if it is not defined int('U') will be used |
# 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 ... | +---------------------------------------------------------------+
# push(chunkBuffer)
Push received data to receive buffer
Parameters
Name | Types | Description |
---|---|---|
chunkBuffer |
|
{Buffer} - Chunk buffer |
# _goSingleTarget(point, params, params.backward, params.tolerance, params.speed)
private method
Go to single point without advanced features
Parameters
Name | Types | Description |
---|---|---|
point | misc.Point |
Target point |
params | Object |
Additional options |
params.backward | Boolean |
Move robot backward |
params.tolerance | Number |
Max radius |
params.speed | Number |
Speed |
Returns
Promise
# go(tunedPoint, parameters, parameters.pf, parameters.backward, parameters.rerouting, parameters.relative, parameters.tolerance, parameters.speed, parameters.obstacle, parameters.friend)
Move the robot, set new position of the robot
Parameters
Name | Types | Description |
---|---|---|
tunedPoint | TunedPoint |
Point that should be reached |
parameters | Object |
Configuration options. |
parameters.pf | Boolean |
Use terrain finding algorithm. |
parameters.backward | Boolean |
Set backward robot moving. |
parameters.rerouting | Boolean |
Enable rerouting during the movement. |
parameters.relative | Boolean |
Use relative to previous position. |
parameters.tolerance | Number |
Position will consider as reached if Euclid's distance between current and required position is less than tolerance. |
parameters.speed | Number |
Speed of the robot movement in range (0, 255). |
parameters.obstacle | Number |
Time [ms] after command will be rejected (with TaskError.action === 'obstacle') if obstacle is detected in hazard region |
parameters.friend | Number |
Time [ms] after command will be rejected (with TaskError.action === 'friend') if friend is detected in hazard region |
# rotate(tunedAngle, options)
Rotate robot for an angle
Parameters
Name | Types | Description |
---|---|---|
tunedAngle | TunedAngle |
Angle to rotate |
options | Object |
Additional options |
# stop(softStop)
Stop the robot
Parameters
Name | Types | Description |
---|---|---|
softStop | Boolean |
If true robot will turn of motors |
# straight(millimeters, params, params.speed)
Move robot forward or backward depending on param millimeters
Parameters
Name | Types | Description |
---|---|---|
millimeters | Number |
Path that needs to be passed. If negative robot will go backward |
params | Object |
|
params.speed | Number |
Speed |
# TaskError()
# TAG()
# addPointBack(point, params)
Add single point at the end of the queue
Parameters
Name | Types | Description |
---|---|---|
point |
|
{misc.Point} - Point |
params |
|
{Object} - Params for target |
# addPointFront(point, params)
Add single point at the beginning of the queue
Parameters
Name | Types | Description |
---|---|---|
point | misc.Point |
Point |
params | Object |
Params for target |
# addPointsBack(points, params)
Add points at the end of the queue
Parameters
Name | Types | Description |
---|---|---|
points |
|
{Array<misc.Point>} - Array of points |
params |
|
{Object} - Params for each target |
# addPointsFront(points, params)
Add points at the beginning of the queue
Parameters
Name | Types | Description |
---|---|---|
points |
|
{Array<misc.Point>} - Array of points |
params |
|
{Object} - Params for each target |
# MotionTarget()
# Point()
# PositionService()
Implements algorithms to collect data from sensors and determine current robot's location
# k(tasks)
Algorithm to choose the best task
Parameters
Name | Types | Description |
---|---|---|
tasks | Array<strategy.Task> |
Array of available tasks |
# Task()
# EventEmitter()
# ShareService()
Automatically shares position, obstacles and task statuses between robots and provides simple API to share custom messages.
# EventEmitter()
# Point()
# TerrainService()
Class represent obstacles on the terrain and mechanism to search terrain between objects.
# constructor(maxX, minX, maxY, minY)
Creates terrain finding algorithm for an area
Parameters
Name | Types | 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 |
# PathFindingBinder()
# super.addObstacle(points)
Parameters
Name | Types | Description |
---|---|---|
points | Array<misc.Point> |
- Array of points that represent polygon |
Returns
Number
- ID of the obstacle
# super.search(start, goal)
Parameters
Name | Types | Description |
---|---|---|
start | misc.Point |
- Start point |
goal | misc.Point |
- Goal point |
Returns
Array<misc.Point>
- Array of pairs (x, y)
# kError(reason)
Run default action if there is the exception in task is not caught with try {} catch(e) {}
.
Parameters
Name | Types | Description |
---|---|---|
reason | TaskError |
Describes more about an exception |
# TAG()
# 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.
# TunedPoint()
# constructor(scheduler, parameters, parameters.weight, parameters.time, parameters.location)
Default constructor for task
Parameters
Name | Types | 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 |
# 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
# Point()
# setState(state)
Set current state
Parameters
Name | Types | Description |
---|---|---|
state | Number |
Can be Task.READY, Task.SUSPENDED, Task.ACTIVE and Task.FINISHED |
# setWeight(weight)
Change default weight of the task
Parameters
Name | Types | Description |
---|---|---|
weight |
|
{Number} |
# constructor(source, action, message, params)
Default constructor for class
Parameters
Name | Types | 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 |
# 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 | Types | Description |
---|---|---|
defaultAngle | Number |
Default point X coordinate |
# TAG()
# 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 | Types | Description |
---|---|---|
defaultX | Number |
Default point X coordinate |
defaultY | Number |
Default point Y coordinate |
# Point()
# Console()
Simplified functions for mep command prompt. All methods are accessible by using t.
prefix.
# go(x, y, config)
Go to (x, y) position.
Parameters
Name | Types | Description |
---|---|---|
x | Number |
|
y | Number |
|
config | Object |
# onRun()
# Console()
Simplified functions for mep command prompt. All methods are accessible by using t.
prefix.
# go(x, y, config)
Go to (x, y) position.
Parameters
Name | Types | Description |
---|---|---|
x | Number |
|
y | Number |
|
config | Object |