myCobot Javascript Version
Programming in javascript environment
- jsmycobot is a js package for serial communication with Mycobot. If you want to use mycobot through JavaScript programming, then it will be your choice
API function introduction
2.1 Introduction to the robot arm 2.2 JOG mode and operation 2.3 Servo control 2.4 Atom IO 2.5 MDI mode and operation
API method introduction
Included classes:
- mycobot
- Coord
Import project
<!-- Import jsmycobot package -->
const mycobot = require("mycobot")
<!-- Initialize mycobot object -->
const obj = mycobot.connect("COM15",115200)
<!-- Write code to execute the robot arm power-on command -->
obj.write(mycobot.powerOn())
<!-- -->
obj.on("data",data=>{
const res = mycobot.processReceived(data)
console.log(`res:${res}`)
})
Robotic Arm Status
5.1 connect()
Description: Create an object and connect to the deviceParameters: Parameter 1: Serial port number, Parameter 2: Baud rateReturn value: None
5.2 powerOn()
Description: Power on the robotParameters: NoneReturn value: None
5.3 powerOff()
Description: Power off the robotParameters: NoneReturn value: None
5.4 isPowerOn()
Description: Determine whether the robot is powered onParameter: NoneReturn value: 1: power on 0: power off -1: error
5.6 releaseAllServos()
Description: Set the robot to free movement modeParameter: NoneReturn value: None
MDI mode and operation
6.1 getAngles
Description: Get the angles of all jointsParameter: [float] type list of all joint angles of the robotReturn value:
6.2 sendAngle
Description: Send the angle of a single joint of the robotParameters: id: robot joint number, degree: angle (number), speed: speed 0~100 (number)Return value: None
6.3 sendAngles
Description: Send the angles of all robot jointsParameters: angles: contains the sequence value list of all joint angles (Array[float]), speed: (int) 0~100Return value: None
6.4 getCoords
Description: Get the angles of all robot jointsParameters: Coordinates [float] type list mycobot: [x, y, z, rx, ry, rz]; mypalletizer: [x, y, z, θ]Return value: None
6.5 sendCoord
Description: Send the coordinates of a single joint of the robotParameters: id: robot joint id, coord: coordinate value, speed: (int) 0~100Return value: None
6.6 sendCoords
Description: Send the coordinates of all joints of the robotParameters: coords: a list of all robot joint coordinate values, speed: (int) 0~100, mode: modeReturn value: None
6.7 isInPosition
Description: Determine whether the position has been reachedParameters: 1: reached the position, 2: not reached the positionReturn value: data: parameter list, angle or coordinate, flag: mark data type - angle, -Coordinates
Jog mode and operation
7.1 jogAngle
Description: Jog control angleParameters: joinId: joint id 1~6 (int), direction: 0 decrease, 1 increase, speed: speed 0~100Return value: None
7.2 jogCoord
Description: Jog control coordinatesParameters: coordid: joint id 1~6 (int), direction: decrease increase 0~1, speed: speed 0~100Return value: None
7.3 jogStop
Description: Stop jogging movementParameters: NoneReturn value: None
7.4 programPause
Description: Pause movementParameters: NoneReturn value: None
7.5 programResume
Description: Resume movementParameters: NoneReturn value: None
7.6 stop
Description: Stop movementParameters: NoneReturn value: None
7.7 setEncoder
Description: Set a single joint rotation to a specified potential valueParameters: NoneReturn value: None
7.8 getEncoder
Description: Get the specified joint potential valueParameters: jointId: joint IDReturn value: 0~4096
7.9 setEncoders
Description: Set the six joints of the robot to execute synchronously to the specified positionParameters: encoders: encoder list, length 6; speed: speed 0~100Return value: None
7.10 getEncoders
Description: Get all joints of the robotParameters: NoneReturn value: Encoder list
Running status and settings
8.1 getSpeed
Description: Get speedParameters: NoneReturn value: speed
8.2 setSpeed
Description: Set speedParameter: number (0~100)Return value: None
8.3 getJointMin
Description: Get the minimum moving angle of the specified jointParameter: jointId: specified joint IDReturn value: None
8.4 getJointMax
Description: Get the maximum moving angle of the specified jointParameter: jointId: specified joint IDReturn value: angle value (float)
Servo control
9.1 isServoEnable
Description: Determine whether all servos are connectedParameter: servoId: servo IDReturn value: None
9.2 isAllServoEnable
Description: Determine if the specified servo is connectedParameter: NoneReturn value: 0: Disable, 1: Enable
9.3 setServoData
Description: Set the data parameters of the specified address of the servoParameter: servo_no: the serial number of the servo being set (1~6), dataId: data address, value: (0~4096)Return value: None
9.4 getServodata
Description: Read the data parameters of the specified address of the servoParameter: servo_no: the serial number of the servo, 1 - 6, dataId: data addressReturn value: 0~4096
9.5 setServoCalibration
Description: The current position of the calibration joint actuator is the angle zero point, and the corresponding point value is 2048Parameter: servo_no: the serial number of the servo, 1 - 6Return value: None
9.6 releaseServo
Description: Power off the specified servoParameter: servo_no: the serial number of the set servo (1~6)Return value: None
9.7 focusServo
Description: Turn on the power of the specified servoParameter: NoneReturn value: servo_no: the serial number of the set servo (1~6)
ATOM IO
10.1 setColor
Description: Set the color of the light on the top of the robot armParameters: r(0~255), g(0~255), b(0~255)Return value: None
10.2 setPinMode
Description: Set the state mode of the specified pin in the atomParameters: pin_no: pin number, pinMode: 0-input, 1-output, 2-input splicingReturn value: None
10.3 setDigitalOutput
Description: Set the pin signal valueParameters: pin_no: pin number, pinSingalReturn value: None
10.4 getDigitalInput
Description: Return the pin signal valueParameter: pin_no: pin numberReturn value: signal value
10.5 getGripperValue
Description: Get the gripper angleParameter: NoneReturn value: gripper angle
10.6 setGripperState
Description: Set the gripper switch stateParameter: flag: 0-open, 1-close; speed: speed (0~100)Return value: None
10.7setGripperValue
Description: Set the gripper valueParameter: value (0~100), speed (0~100)Return value: None
10.8 setGripperIni
Description: Set the current position to zeroParameter: NoneReturn value: None
10.9 isGripperMving
Description: Determine whether the gripper is movingParameter: NoneReturn value: 0: not moving, 1: moving
M5Stack-basic
11.1 setBasicOutput
Description: Set the bottom pinParameter: pin_no: pin number, pinSignal: 0 / 1Return value: None
11.2 getBasicOutput
Description: Get the bottom pinParameter: pin_no: pin numberReturn value: None