Memristor's Eurobot Platform
Global function to require library relative to src
directory
Name | Type | Description | |
---|---|---|---|
library |
String
|
|
const Task = Mep.require('utils/Task');
Object
Proxy to method Mep.DriverManager.getDriver(driver)
Name | Type | Description | |
---|---|---|---|
driver | {String} - Driver name |
let servo = Mep.getDriver('ArmFirstAX12');
Object
Send log or command to mep-dash.
Name | Type | Description | |
---|---|---|---|
tag | {String} - Message tag |
||
action | {String} - Message action |
||
params | {Object} - Additional parameters of interest to action |
Void
Helper that generates query string for .on()
Name | Type | Description | |
---|---|---|---|
tag | {String} - Message tag |
||
action | {String} - Message action |
string
A goal of the class is to check if drivers are correctly implemented.
Void
Class manipulate drivers
DriverManager provides mechanisms to:
Each driver can be part of one or more of following groups: control, terrain & position.
Void
Check if driver is out of order
Name | Type | Description | |
---|---|---|---|
name |
String
|
Unique name of a driver |
Boolean
Get driver instance by driver name
Name | Type | Description | |
---|---|---|---|
name |
String
|
Driver name, eg. "MotionDriver", or "ModbusDriver". |
Object
Required driver
Returns true if driver is available
Name | Type | Description | |
---|---|---|---|
name |
String
|
Driver name |
Boolean
Is driver available
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.
Name | Type | Description | |
---|---|---|---|
type |
String
|
Data type which driver can provide. Can be: position & terrain. |
Object
List of filtered drivers
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.
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. |
Void
Put driver out of order
Name | Type | Description | |
---|---|---|---|
name |
String
|
Unique name of a driver |
|
message |
String
|
Describe more why the fault happened |
Void
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 |
Void
Send buffer to specific ID
Name | Type | Description | |
---|---|---|---|
id |
Number
|
Device ID |
|
buffer |
Buffer
|
Data |
canDriver.send(0x4324234, Buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72, 0x00, 0x00]));
Void
Start CAN bus device
Name | Type | Description | |
---|---|---|---|
device |
String
|
||
bitrate |
Number
|
Void
Start reading data from sensor
Name | Type | Description | |
---|---|---|---|
interval |
Number
|
Receive RGB components every |
Void
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].
Name | Type | Description | |
---|---|---|---|
r |
Number
|
The red color value |
|
g |
Number
|
The green color value |
|
b |
Number
|
The blue color value |
Array The HSV representation
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].
Name | Type | Description | |
---|---|---|---|
r |
Number
|
The red color value |
|
g |
Number
|
The green color value |
|
b |
Number
|
The blue color value |
Array The HSL representation
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.
Void
Set servo to required position and get promise when position is reached
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 |
Void
Name | Type | Description | |
---|---|---|---|
config |
Object
|
Additional parameters |
|
config.cid |
Number
|
Communication ID |
Optional |
[email protected] |
String
|
Name of communication driver |
Optional |
Void
Uses data from infrared sensors to determine where is an enemy robot and other obstacles.
Void
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
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 |
Void
Process detected obstacle
Name | Type | Description | |
---|---|---|---|
buffer | {Boolean} - Object is detected or not |
Void
Provides an abstraction layer on top of lidar's firmware and algorithms to determine robot's position and obstacles
Void
Process a measurement and try to make an obstacle approximation. It uses bounding box algorithm to make an approximation of the obstacle
Name | Type | Description | |
---|---|---|---|
angle |
Number
|
Angle of the measurement |
|
distance |
Number
|
Distance to the closest point at given angle |
Void
Process data from lidar
Name | Type | Description | |
---|---|---|---|
data |
Buffer
|
Buffer from lidar |
Void
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 |
Void
Creates instance of ModbusDriver
Name | Type | Description | |
---|---|---|---|
name | {String} - Unique name of a driver |
||
config | {Object} - Configuration presented as an associative array |
Void
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 |
Optional |
config.connectionTimeout |
Number
|
Connection timeout in ms |
Optional |
config.ackTimeout |
Number
|
Acknowledgment timeout |
Optional |
Void
Reset position and orientation
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 |
Void
Rotate robot to given angle
Name | Type | Description | |
---|---|---|---|
angle |
Number
|
Angle |
Promise
Rotate for given angle
Name | Type | Description | |
---|---|---|---|
angle |
Number
|
Promise
Move robot forward or backward depending on sign
Name | Type | Description | |
---|---|---|---|
millimeters |
Number
|
Void
Set default speed of the robot
Name | Type | Description | |
---|---|---|---|
speed |
Number
|
Speed (0 - 255) |
Void
Move robot to absolute position
Name | Type | Description | |
---|---|---|---|
position |
misc.Point
|
Required position of the robot |
|
direction |
Number
|
Direction, can be MotionDriver.DIRECTION_FORWARD or MotionDriver.DIRECTION_BACKWARD |
Void
Move robot to absolute position but robot make curves to speed up motion. This
command requires finishCommand()
before next motion command.
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
|
Void
Packet type P is received
Name | Type | Description | |
---|---|---|---|
buffer |
Buffer
|
Payload |
Void
Callback will be called when new packet is arrived and it will dispatch event to new callback depending on packet type
Name | Type | Description | |
---|---|---|---|
buffer |
Buffer
|
Payload |
|
type |
String
|
Packet type |
Void
Natively (C++) implemented driver that enables communication with Memristor's motion driver.
Void
Name | Type | Description | |
---|---|---|---|
name | {String} - Unique driver name |
||
config | {Object} - Configuration presented as an associative array |
Void
MotionDriverSimulator simulation module. Has same methods as MotionDriver but this module send all commands to simulator.
Void
Get last value
let value = Mep.getDriver('PinDriver').getLastState();
Number
High or low
Read value of given pin
Mep.getDriver('PinDriver').read((value) => { console.log(value) });
Promise
Write value to given pin
Name | Type | Description | |
---|---|---|---|
value |
Number
|
[0, 1] for digital pins or [0 - 255] for analog pins |
Void
Detects when rope is pulled out of the robot and starts counting game time.
Void
Get time in seconds since match is started
number
Get time in milliseconds since match is started
Number
Milliseconds since match is started
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 |
Void
Method will be called only if protocol is not null
and protocol generated packet.
Name | Type | Description | |
---|---|---|---|
packet |
Buffer
|
Parsed packet |
|
type |
String
|
Single character that represents type of packet |
Void
Send data to Uart
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 |
Void
Logs memory and cpu usage
...
"UsageDriver": {
"class": "drivers/usage/UsageDriver",
"load": true,
"refreshPeriod": 1000
}
...
Void
Queue of callback functions. It used when you want to allow other modules to subscribe to your events.
Void
Subscribe on event. Add callback function to queue.
Name | Type | Description | |
---|---|---|---|
callback |
function
|
|
Void
Call all callback functions from queue with same parameters.
Name | Type | Description | |
---|---|---|---|
params |
Array
|
|
Void
Name | Type | Description | |
---|---|---|---|
startPoint |
misc.Point
|
Start point of the line |
|
endPoint |
misc.Point
|
End point of the line |
Void
Check if it intersect with another line
Name | Type | Description | |
---|---|---|---|
line |
misc.Line
|
Another line to check intersection with |
Boolean
True if two lines intersect
Check if it intersect with polygon
Name | Type | Description | |
---|---|---|---|
polygon |
misc.Polygon
|
Polygon to check intersection with |
Boolean
True if line intersect polygon
Make new point.
Name | Type | Description | |
---|---|---|---|
x |
Number
|
X coordinate |
|
y |
Number
|
Y coordinate |
Void
Calculate Euclidean distance between two Points
Name | Type | Description | |
---|---|---|---|
point |
misc.Point
|
Another point to compare with |
number
Distance between two Points
Check if points are equal
Name | Type | Description | |
---|---|---|---|
point |
Point
|
Another point to be compared |
Boolean
Translate point
Name | Type | Description | |
---|---|---|---|
translatePoint |
Void
Rotate point around origin point
Name | Type | Description | |
---|---|---|---|
originPoint |
misc.Point
|
Origin point |
|
angleDegrees |
Number
|
Rotation angle |
misc.Point
Optimized algorithm for point rotation around coordinate beginning
Name | Type | Description | |
---|---|---|---|
angleDegrees | {Number} |
misc.Point
Set Y coordinate
Name | Type | Description | |
---|---|---|---|
y |
Number
|
Y coordinate |
Void
Set X coordinate
Name | Type | Description | |
---|---|---|---|
x |
Number
|
X coordinate |
Void
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 |
Void
Translate all points of polygon
Name | Type | Description | |
---|---|---|---|
translatePoint |
misc.Point
|
Point which represents x and y value of translation |
Void
Rotate all points of polygon around an origin point
Name | Type | Description | |
---|---|---|---|
originPoint |
misc.Point
|
Center point of rotation |
|
angleDegrees |
Number
|
Required angle of rotation |
Void
Number
Get duration of milliseconds after the polygon will be destroyed
Optimized algorithm for polygon rotation around coordinate beginning
Name | Type | Description | |
---|---|---|---|
angleDegrees |
Number
|
misc.Polygon
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 ... | +---------------------------------------------------------------+
Void
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 |
Void
Generate packet
Name | Type | Description | |
---|---|---|---|
buffer | {Buffer} - Payload for packet |
||
type | {Number} - Type for packet, if it is not defined int('U') will be used |
Buffer
Push received data to receive buffer
Name | Type | Description | |
---|---|---|---|
chunkBuffer | {Buffer} - Chunk buffer |
Void
Provides a very abstract way to control and estimate robot position
Void
Move the robot, set new position of the robot
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 |
Promise
Go to single point without advanced features
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 |
Promise
Stop the robot
Name | Type | Description | |
---|---|---|---|
softStop |
Boolean
|
If true robot will turn of motors |
Void
Move robot forward or backward depending on param millimeters
Name | Type | Description | |
---|---|---|---|
millimeters |
Number
|
Path that needs to be passed. If negative robot will go backward |
|
params |
Object
|
||
params.speed |
Number
|
Speed |
Optional |
Promise
Rotate robot for an angle
Name | Type | Description | |
---|---|---|---|
tunedAngle |
TunedAngle
|
Angle to rotate |
|
options |
Object
|
Additional options |
Promise
Get all targets
Array.<services.motion.MotionTarget>
Add points at the end of the queue
Name | Type | Description | |
---|---|---|---|
points | {Array<misc.Point>} - Array of points |
||
params | {Object} - Params for each target |
Void
Add single point at the end of the queue
Name | Type | Description | |
---|---|---|---|
point | {misc.Point} - Point |
||
params | {Object} - Params for target |
Void
Add points at the beginning of the queue
Name | Type | Description | |
---|---|---|---|
points | {Array<misc.Point>} - Array of points |
||
params | {Object} - Params for each target |
Void
Add single point at the beginning of the queue
Name | Type | Description | |
---|---|---|---|
point |
misc.Point
|
Point |
|
params |
Object
|
Params for target |
Void
Get target at the front of queue
services.motion.MotionTarget
Get target at the end of the queue
services.motion.MotionTarget
Make line between current position and target if path finding is enabled
misc.Line
Get final target of path finding algorithm if path finding is enabled
MotionTarget
Implements algorithms to collect data from sensors and determine current robot's location
Void
Get current robot's orientation
Number
Orientation in degrees
Algorithm to choose the best task
Name | Type | Description | |
---|---|---|---|
tasks |
Array.<strategy.Task>
|
Array of available tasks |
strategy.Task
Automatically shares position, obstacles and task statuses between robots and provides simple API to share custom messages.
Mep.Share.send('ROBOT_ARRIVED_TO_POSITION');
Mep.Share.on('message', (message) => { console.log(message); });
Void
Provides sharing based on UDP protocol. Same prototype should be used for other protocols.
Void
Class represent obstacles on the terrain and mechanism to search terrain between objects.
Void
Creates terrain finding algorithm for an area
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 |
Void
Default scheduler class describes general task scheduling and robot behaviour
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
}
}
Void
Run default action if there is the exception in task is not caught with try {} catch(e) {}
.
Name | Type | Description | |
---|---|---|---|
reason |
TaskError
|
Describes more about an exception |
Void
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.
Shortcut.make();
Void
Default task class describes general task robot behaviour during task execution
Void
Default constructor for task
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 |
Void
Get current state
Number
Can be Task.READY, Task.SUSPENDED, Task.ACTIVE and Task.FINISHED
Set current state
Name | Type | Description | |
---|---|---|---|
state |
Number
|
Can be Task.READY, Task.SUSPENDED, Task.ACTIVE and Task.FINISHED |
Void
Change default weight of the task
Name | Type | Description | |
---|---|---|---|
weight | {Number} |
Void
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
Boolean
Returns true if task is ready to be executed
Default constructor for class
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 |
Void
Tunable angle. Angle is chosen depends on table name in configuration.
new TuneAngle(
150,
[151, 'table_1'],
[148, 'table_2']
);
Void
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!
Name | Type | Description | |
---|---|---|---|
defaultAngle |
Number
|
Default point X coordinate |
Void
Get angle depending on the chosen table in configuration.
Number
Angle
Tunable Point. Point coordinates are choose depends on table name in configuration.
new TunePoint(
150, 129,
[151, 129, 'table_1'],
[148, 128, 'table_2']
);
Void
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!
Name | Type | Description | |
---|---|---|---|
defaultX |
Number
|
Default point X coordinate |
|
defaultY |
Number
|
Default point Y coordinate |
Void
Get point depending on the chosen table in configuration.
Point
Point
Simplified functions for mep command prompt. All methods are accessible by using t.
prefix.
Void
List all available drivers for current current configuration
mep > t.drivers()
Void
List driver properties for driver with id
Name | Type | Description | |
---|---|---|---|
id |
String
|
mep > t.driver('MotionDriver')
Void
Simplified functions for mep command prompt. All methods are accessible by using t.
prefix.
Void
List all available drivers for current current configuration
mep > t.drivers()
Void
List driver properties for driver with id
Name | Type | Description | |
---|---|---|---|
id |
String
|
mep > t.driver('MotionDriver')
Void