This is javascript API for mycobot.
Catalogue:
Import to your project:
// basic demo
var mycobot = require("mycobot")
// obj Based on SerialPort
var obj = mycobot.connect("COM15",115200)
obj.write(mycobot.powerOn())
obj.on("data",(data)=>{
res = mycobot.processReceived(data)
console.log("res:", res)
})
-
Prototype:
connect(port, baud)
-
Description:Create objects, connect devices (default open).
-
Prototype:
powerOn()
-
Description:Atom open communication (default open).
-
Prototype:
powerOff()
-
Description: Atom turn off communication.
-
Prototype:
isPowerOn()
-
Description: Adjust robot arm whether power on.
-
Returns
1
: power on0
: power off
-
Prototype:
releaseAllServos()
-
Description: Set robot arm into free moving mode.
-
Prototype:
getAngles()
-
Description: Get the degree of all joints.
-
Returns:
object
: A float list of all degree.
-
Prototype:
sendAngle(id, degree, speed)
-
Description: Send one degree of joint to robot arm.
-
Parameters
id
: Joint iddegree
: degree value(number
)speed
: (number
) 0 ~ 100
-
Example
obj.write(mycobot.sendAngle(1,50,50))
-
Prototype:
sendAngles(angles, speed)
-
Description: Send the degrees of all joints to robot arm.
-
Parameters
-
degrees
: a list of degree value(Array
). -
speed
: (number
) 0 ~ 100
-
-
Example
obj.write(mycobot.sendAngles([0,0,0,0,0,0],60))
-
Prototype:
getCoords()
-
Description: Get the Coords from robot arm, coordinate system based on base.
-
Returns:
object
: A float list of coord -mycobot:[x, y, z, rx, ry, rz]; mypalletizer:[x, y, z, θ]
-
Prototype:
sendCoord(id, coord, speed)
-
Description: Send one coord to robot arm.
-
Parameters
id
: coord idcoord
: coord value(number
)speed
: (number
) 0 ~ 100
-
Example
obj.write(mycobot.sendCoord(x,20,50))
-
Prototype:
sendCoords(coords, speed, mode)
-
Description: Send all coords to robot arm.
-
Parameters
coords
: a list of coords value(Array
).speed
: (number
) 0 ~ 100mode
:0
- angular,1
- linear
-
Example
obj.write(mycobot.sendCoords([160, 160, 160, 0, 0, 0], 70, 0))
-
Prototype:
isInPosition(data, flag)
-
Description: Judge whether in the position.
-
Parameters
data
: A data list, angles or coords.flag
: Tag the data type,0
- angles,1
- coords.
-
Returns
1
- true0
- false
-
Prototype:
jogAngle(jointId, direction, speed)
-
Description: Jog control angle
-
Parameters
jointId
: (int
) 1 ~ 6direction
:0
- decrease,1
- increasespeed
: 0 ~ 100
-
Prototype:
jogCoord(coordId, direction, speed)
-
Description: Jog control coord.
-
Parameters
coordId
: (int
) 1 ~ 6direction
:0
- decrease,1
- increasespeed
: 0 ~ 100
-
Prototype:
jogStop()
-
Description: Stop jog moving.
-
Prototype:
programPause()
-
Description: Pause movement.
-
Prototype:
programResume()
-
Description: Recovery movement.
-
Prototype:
stop()
-
Description: Stop moving.
-
Prototype:
setEncoder(jointId, encoder)
-
Description: Set a single joint rotation to the specified potential value.
-
Parameters
jointId
: 1 ~ 6encoder
: 0 ~ 4096
-
Prototype:
getEncoder(jointId)
-
Description:Obtain the specified joint potential value.
-
Parameters:
jointId
: 1 ~ 6 -
Returns:
encoder
: 0 ~ 4096
-
Prototype:
setEncoders(encoders, speed)
-
Description: Set the six joints of the manipulator to execute synchronously to the specified position.
-
Parameters:
encoders
: A encoder list, length 6.speed
: 0 - 100
-
Prototype:
getEncoders()
-
Description: Get the all joints of the manipulator.
-
Returns: the list of encoder (
Array
)
-
Prototype:
getSpeed()
-
Description: Get speed.
-
Returns: speed
-
Prototype:
setSpeed(speed)
-
Description: Set speed.
-
Parameters: speed: 0 ~ 100
-
Prototype:
getJointMin(jointId)
-
Description: Gets the minimum movement angle of the specified joint
-
Parameters:
jointId
-
Returns: angle value (
float
)
-
Prototype:
getJointMax(jointId)
-
Description: Gets the maximum movement angle of the specified joint
-
Parameters:
jointId
-
Returns: angle value (
float
)
-
Prototype:
isServoEnable(servoId)
-
Description: Determine whether all steering gears are connected
-
Parameters:
servoId
1 ~ 6 -
Returns
0
: disable1
: enable
-
Prototype:
isAllServoEnable()
-
Description: Determine whether the specified steering gear is connected
-
Returns
0
: disable1
: enable
-
Prototype:
setServoData(servo_no, dataId, value)
-
Description: Set the data parameters of the specified address of the steering gear.
-
Parameters:
servo_no
: Serial number of articulated steering gear, 1 - 6.dataId
: Data address.value
: 0 - 4096
-
Prototype:
getServodata(servo_no, dataId)
-
Description: Read the data parameter of the specified address of the steering gear.
-
Parameters:
servo_no
: Serial number of articulated steering gear, 1 - 6.dataId
: Data address.
-
Returns:
value
: 0 - 40960
: disable1
: enable-1
: error
-
Prototype:
setServoCalibration(servo_no)
-
Description: The current position of the calibration joint actuator is the angle zero point, and the corresponding potential value is 2048.
-
Parameters:
servo_no
: Serial number of articulated steering gear, 1 - 6.
-
Prototype:
releaseServo(servoId)
-
Description: Power off designated servo
-
Parameters:
servoId
: 1 ~ 6
-
Prototype:
focusServo(servoId)
-
Description: Power on designated servo
-
Parameters:
servoId
: 1 ~ 6
-
Prototype:
setColor(r, g, b)
-
Description: Set the color of the light on the top of the robot arm.
-
Parameters
r
: 0 ~ 255g
: 0 ~ 255b
: 0 ~ 255
-
Prototype:
setPinMode(pin_no, pinMode)
-
Description: Set the state mode of the specified pin in atom.
-
Parameters
pin_no
: Pin number.pinMode
: 0 - input, 1 - output, 2 - inputPullup
-
Parameters
pin_no
:pinSignal
: 0 / 1
-
Parameters:
pin_no
-
Return: signal value
-
Prototype:
getGripperValue()
-
Description: Get gripper value
-
Return: gripper value
-
Prototype:
setGripperState(flag, speed)
-
Description: Set gripper switch state
-
Parameters
flag
: 0 - open, 1 - closespeed
: 0 ~ 100
-
Prototype:
setGripperValue(value, speed)
-
Description: Set gripper value
-
Parameters
value
: 0 ~ 100speed
: 0 ~ 100
-
Prototype:
setGripperIni()
-
Description: Set the current position to zero, set current position value is
2048
.
-
Prototype:
isGripperMving()
-
Description: Judge whether the gripper is moving or not
-
Returns
0
: not moving1
: is moving
-
Prototype:
setBasicOutput(pin_no, pinSignal)
-
Description: Set bottom pin.
-
Parameters
pin_no
: Pin number.pinSignal
: 0 / 1
-
Prototype:
getBasicOutput(pin_no)
-
Description: get bottom pin.
-
Parameters
pin_no
: Pin number.
More demo can go to here.