Skip to content

glumb/mrcl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mrcl

mrcl

GitHub license Travis npm Codecov

🤖 microPede robot control library. A lightweight JavaScript library that uses mrcp to control the robot.

import {Transport, MRCL, MRIL, MRCP, protocolDefinitions as pd } from 'mrcl'

const trans = new Transport.Serial({port:'/dev/tty', baud: 3600})
const mrcl = new MRCL(trans)

const moveInstruction = new MRIL('M00 X10 Y-10 Z 15 A0 B-3.1 C3.1')
const command1 = new MRCP(pd.MRCP.QUEUE, moveInstruction)

const getPosInstruction = new MRIL('X Y Z A B C')
const command2 = new MRCP(pd.MRCP.EXECUTE, getPosInstruction)


mrcl.send(command1)
mrcl.send(command2)
import {Transport, MRCL, MRIL, MRCP, protocolDefinitions as pd } from 'mrcl'

const trans = new Transport.Serial({port:'/dev/tty', baud: 3600})
const mrcl = new MRCL(trans)

// read file and send to robot
for ( const line of fs.readLinesOfFile('./prog1.mril')){
  const mril = new MRIL(line)
  const cmd = new MRCP(pd.MRCP.QUEUE, mril)
  mrcl.send(cmd)
}

MRIB - Instruction Builder

The Instruction Builder is used to programmatically construct MRIL instructions.

import {MRIB, Transport} from 'mrcl'

const trans = new Transport.Serial({port:'/dev/tty', baud: 3600})
const mrib = new MRIB(trans)

mrib.queue() // queue in. execute(). write().
    .setVelocity(15)
    .moveLinear(10, 10, 15, 3.1, 0, -3.1)
    .moveX(15, ()=>console.log('moved to X 15'))
    .moveP2P(20, 5, 0)
    .moveRelativeX(1)

Methods

SerialTransport(config)

config

{
port: '', // serial port
baudRate: 3600,
}

MRIL(instruction)

Prepares the MRIL instruction for transmission. This involves removing whitespace/comments and adding a command number to be able to monitor the commands execution state. If an instruction with a command number is passed, the number will be removed.

const mril = new MRIL("X15 Y-10 Z5")

instruction

MRIL instruction string

.on(event, callback)

mril.on('executed', ()=>console.log('executed'))

event

Used to monitor the MRILs state.

  • sending - transmission started
  • sent - transmission finished
  • executing - execution on MRC started
  • executed - command executed on MRC

callback

Called when event triggers.

.getRawInstruction()

Returns the instruction passed to the constructor.

.getInstruction()

Returns the prepared instruction. (no comments/whitespace, added command number)

MRCP(executionType, mril)

const mrcp = new MRCP(protocol.MRCP.WRITE, mril)

executionType

How to execute the instruction on MRC. Available options defined in protocolDefinitions import {protocol} from MRIL.

  • protocol.MRCP.EXECUTE - execute immediately, useful for queries like 'get x position'
  • protocol.MRCP.QUEUE - queue in
  • protocol.MRCP.WRITE - write to EEPROM

mril

MRIL object.

MRCL(transport, options)

const mrcl = new MRCL(transport)

transport

Transport object

options (optional)

{
  autoTransmit: true, // default true. If false, call mrcl.transmit() to start sending
}

.send(mrcl)

Transmit instruction.

.getFreeReceiveBuffer()

Returns free MRC receive buffer.

.getSentCommands()

.getCommands()

todo

  • documentation

About

🤖 microPede robot control library. A lightweight JavaScript library that uses mrcp to control the robot.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published