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 device
  • Parameters: Parameter 1: Serial port number, Parameter 2: Baud rate
  • Return value: None

5.2 powerOn()

  • Description: Power on the robot
  • Parameters: None
  • Return value: None

5.3 powerOff()

  • Description: Power off the robot
  • Parameters: None
  • Return value: None

5.4 isPowerOn()

  • Description: Determine whether the robot is powered on
  • Parameter: None
  • Return value: 1: power on 0: power off -1: error

5.6 releaseAllServos()

  • Description: Set the robot to free movement mode
  • Parameter: None
  • Return value: None

MDI mode and operation

6.1 getAngles

  • Description: Get the angles of all joints
  • Parameter: [float] type list of all joint angles of the robot
  • Return value:

6.2 sendAngle

  • Description: Send the angle of a single joint of the robot
  • Parameters: 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 joints
  • Parameters: angles: contains the sequence value list of all joint angles (Array[float]), speed: (int) 0~100
  • Return value: None

6.4 getCoords

  • Description: Get the angles of all robot joints
  • Parameters: 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 robot
  • Parameters: id: robot joint id, coord: coordinate value, speed: (int) 0~100
  • Return value: None

6.6 sendCoords

  • Description: Send the coordinates of all joints of the robot
  • Parameters: coords: a list of all robot joint coordinate values, speed: (int) 0~100, mode: mode
  • Return value: None

6.7 isInPosition

  • Description: Determine whether the position has been reached
  • Parameters: 1: reached the position, 2: not reached the position
  • Return value: data: parameter list, angle or coordinate, flag: mark data type - angle, -Coordinates

Jog mode and operation

7.1 jogAngle

  • Description: Jog control angle
  • Parameters: joinId: joint id 1~6 (int), direction: 0 decrease, 1 increase, speed: speed 0~100
  • Return value: None

7.2 jogCoord

  • Description: Jog control coordinates
  • Parameters: coordid: joint id 1~6 (int), direction: decrease increase 0~1, speed: speed 0~100
  • Return value: None

7.3 jogStop

  • Description: Stop jogging movement
  • Parameters: None
  • Return value: None

7.4 programPause

  • Description: Pause movement
  • Parameters: None
  • Return value: None

7.5 programResume

  • Description: Resume movement
  • Parameters: None
  • Return value: None

7.6 stop

  • Description: Stop movement
  • Parameters: None
  • Return value: None

7.7 setEncoder

  • Description: Set a single joint rotation to a specified potential value
  • Parameters: None
  • Return value: None

7.8 getEncoder

  • Description: Get the specified joint potential value
  • Parameters: jointId: joint ID
  • Return value: 0~4096

7.9 setEncoders

  • Description: Set the six joints of the robot to execute synchronously to the specified position
  • Parameters: encoders: encoder list, length 6; speed: speed 0~100
  • Return value: None

7.10 getEncoders

  • Description: Get all joints of the robot
  • Parameters: None
  • Return value: Encoder list

Running status and settings

8.1 getSpeed

  • Description: Get speed
  • Parameters: None
  • Return value: speed

8.2 setSpeed

  • Description: Set speed
  • Parameter: number (0~100)
  • Return value: None

8.3 getJointMin

  • Description: Get the minimum moving angle of the specified joint
  • Parameter: jointId: specified joint ID
  • Return value: None

8.4 getJointMax

  • Description: Get the maximum moving angle of the specified joint
  • Parameter: jointId: specified joint ID
  • Return value: angle value (float)

Servo control

9.1 isServoEnable

  • Description: Determine whether all servos are connected
  • Parameter: servoId: servo ID
  • Return value: None

9.2 isAllServoEnable

  • Description: Determine if the specified servo is connected
  • Parameter: None
  • Return value: 0: Disable, 1: Enable

9.3 setServoData

  • Description: Set the data parameters of the specified address of the servo
  • Parameter: 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 servo
  • Parameter: servo_no: the serial number of the servo, 1 - 6, dataId: data address
  • Return 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 2048
  • Parameter: servo_no: the serial number of the servo, 1 - 6
  • Return value: None

9.6 releaseServo

  • Description: Power off the specified servo
  • Parameter: 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 servo
  • Parameter: None
  • Return 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 arm
  • Parameters: 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 atom
  • Parameters: pin_no: pin number, pinMode: 0-input, 1-output, 2-input splicing
  • Return value: None

10.3 setDigitalOutput

  • Description: Set the pin signal value
  • Parameters: pin_no: pin number, pinSingal
  • Return value: None

10.4 getDigitalInput

  • Description: Return the pin signal value
  • Parameter: pin_no: pin number
  • Return value: signal value

10.5 getGripperValue

  • Description: Get the gripper angle
  • Parameter: None
  • Return value: gripper angle

10.6 setGripperState

  • Description: Set the gripper switch state
  • Parameter: flag: 0-open, 1-close; speed: speed (0~100)
  • Return value: None

10.7setGripperValue

  • Description: Set the gripper value
  • Parameter: value (0~100), speed (0~100)
  • Return value: None

10.8 setGripperIni

  • Description: Set the current position to zero
  • Parameter: None
  • Return value: None

10.9 isGripperMving

  • Description: Determine whether the gripper is moving
  • Parameter: None
  • Return value: 0: not moving, 1: moving

M5Stack-basic

11.1 setBasicOutput

  • Description: Set the bottom pin
  • Parameter: pin_no: pin number, pinSignal: 0 / 1
  • Return value: None

11.2 getBasicOutput

  • Description: Get the bottom pin
  • Parameter: pin_no: pin number
  • Return value: None

results matching ""

    No results matching ""