Giter VIP home page Giter VIP logo

mrcl's Introduction

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

mrcl's People

Contributors

glumb avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.