Skip to content

PRIArobotics/CRCLJS-WS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CRCLJS-WS

Browser Websocket implementation of the queued streaming robot motion interface CRCL-JS, an adapted minimal JSON-based version of CRCL.

There are also two specific implementations:

  • a general Javascript implementation with the reference: CRCL-JS
  • a Node-JS specific implementation: CRCL-JS-Node

CRCLJS Websocket Communication Interface

The implemented SocketIORobotConnection can connect to the websocket of the CRCLJS WS Adapter which forwards the CRCLJS commands to the robots. This enables CRCLJS robot communication in the browser since it does not depend on TCP.

Private Dependencies

Use npm link to resolve the following private dependencies:

Usage

import {Tools} from "@babylonjs/core";
import {CommandFactory, RobotInterface} from 'crcljs';
import {quaternionToEuler} from 'eulerutil';
import {SocketIORobotConnection} fron './src/SocketIORobotConnection.mjs'

const ROBOTSERVER = 'http://localhost:3000'
console.log(`Connecting to crcljs ws adapter at ${ROBOTSERVER}`);
const robotServerConnection = io(ROBOTSERVER, {reconnection: false});

robotServerConnection.on('connect', () => {
    console.log(`Connected to RobotServer`)
    const robotname = 'Kuka'
    const robotInterface = new RobotInterface(new SocketIORobotConnection(robotname, robotServerConnection))
    if (!robotInterface.connected){
        console.log("RobotInterface disconnected")
        return
    }
    try{
        this.robotInterface.send(CommandFactory.SetEndEffectorParameters("Using Gripper 0", 0))
        this.robotInterface.send(CommandFactory.SetTransSpeed('Set speed to 10 percent', 0.1)
        
        const rotation = quaternionToEuler(myrotationQuaternion, 'XYZ').asArray().map(Tools.ToDegrees).reverse()
        const position = newtcp.position.scale(1000).asArray() // meter to millimeter
        const cmd = CommandFactory.MoveTo('Moving', position, rotation, false, false)
        
        const [queued, working, done] = robotInterface.send(cmd)
        await queued
        await working
        await done
    } catch (e){
        console.log(e.message)
    }
}

About

CRCLJS Websocket Communication Interface

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published