<!-- Initialization procedure -->
const mycobot = require('mycobot')
const obj = mycobot.connect('COM15',115200)
<!-- Suppose a four axis manipulator is connected -->
const name = "myPallizer"
<!-- If the connected equipment is a six axis manipulator -->
if(name == "myCobot"){
<!-- Sets the angle of each of the six joints -->
obj.write(mycobot.sendAngles([-1.49,115,-153.45,30,-33.42,137.9],80))
<!-- And judge whether the coordinate is reached -->
if(obj.write(mycobot.isInPosition([-1.49,115,-153.45,30,-33.42,137.9],0)) == 1){
<!-- Resume manipulator movement -->
obj.write(mycobot.programResume())
<!-- Wait 0.5 seconds -->
settimeout(() =>{
<!-- Pause the manipulator movement -->
obj.write(mycobot.programPause())
},500)
}
}else{
<!-- Sets the angle of each of the four joints -->
obj.write(mycobot.sendAngles([-1.49,45,-23,30],80))
<!-- Sets the color of the atom indicator -->
obj.write(mycobot.setColor(0,0,50))
<!-- Wait 0.7 seconds -->
settimeout(() =>{
<!-- Set the angles of the four joints again -->
obj.write(mycobot.sendAngles([-1.49,60,11,30],80))
<!-- Sets the color of the atom indicator -->
obj.write(mycobot.setColor(0,50,0))
},700)
}
Case 2
<!-- Initialization procedure -->
const mycobot = require('mycobot')
const obj = mycobot.connect('COM15',115200)
<!-- Gets the angle of all current joints -->
const botData = obj.write(mycobot.getAngles())
<!-- Outputs the angle of all current joints -->
console.log(botdata)
<!-- Sets the angle of all current joints -->
obj.write(mycobot.sendAngles([0,0,0,0],50))
<!-- Print whether the robot arm currently reaches this position -->
console.log(obj.write(mycobot.isInPosition([0,0,0,0,0,0],0)) == 1)
<!-- Wait for 3 seconds -->
settimeout(() =>{
<!-- Sets the angle of the first joint -->
obj.write(mycobot.sendAngle(1,90,50))
},3000)
<!-- Wait two seconds -->
settimeout(() =>{
<!-- Set the second joint angle to 50 degrees -->
obj.write(mycobot.sendAngle(2,50,50))
},2000)
<!-- Wait 1.5 seconds -->
settimeout(() =>{
<!-- Set the joint triangulation to 50 degrees -->
obj.write(mycobot.sendAngle(3,-50,50))
},1500)
<!-- Wait 1.5 seconds -->
settimeout(() =>{
<!-- Set all joint angles of the manipulator -->
obj.write(mycobot.sendAngles([88.68, -138.51, 155.65, -128.05, -9.93, -15.29],50))
},1500)
<!-- Wait for 2.5 seconds -->
settimeout(() =>{
<!-- Set the manipulator to free mode -->
obj.write(mycobot.releaseAllServos())
},2500)