Skip to content

Commit 9623b03

Browse files
committed
updata new examples
1 parent 2a0b856 commit 9623b03

File tree

3 files changed

+84
-39
lines changed

3 files changed

+84
-39
lines changed

Arduino/MycobotBasic/examples/SimpleTest/SimpleTest.ino renamed to Arduino/MycobotBasic/examples/AnglesTest/AnglesTest.ino

Lines changed: 38 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,38 @@
1-
#include <MycobotBasic.h>
2-
#include <ParameterList.h>
3-
4-
MycobotBasic myCobot;
5-
6-
//设定容器数量
7-
Angles angles = { -0.0, -0.0, -0.0, -0.0, -0.0, -0.0 };
8-
9-
10-
void setup() {
11-
myCobot.setup();
12-
//打开扭矩输出
13-
myCobot.powerOn();
14-
//赋值容器内部元素
15-
for(auto &val : angles)
16-
val = 0.0;
17-
//关节回到原点
18-
myCobot.WriteAngles(angles, 50);
19-
delay(5000);
20-
}
21-
22-
void loop() {
23-
for(int i = 1; i < 7; i++) //run
24-
{
25-
myCobot.setLEDRGB(0XFF, 0, 0); // set RGB show red
26-
delay(50);
27-
//myCobot.WriteAngle(i,angle,0-100);
28-
myCobot.WriteAngle(i, -90, 100); // set joint angle -90 degree
29-
delay(4000);
30-
myCobot.setLEDRGB(0, 0XFF, 0); // set RGB show blue
31-
delay(50);
32-
myCobot.WriteAngle(i, 90, 100); // set joint angle 90 degree
33-
delay(4000);
34-
myCobot.setLEDRGB(0, 0, 0XFF); // set RGB show green
35-
delay(50);
36-
myCobot.WriteAngle(i, 0, 100); // set joint angle 0 degree
37-
delay(4000);
38-
}
39-
}
1+
#include <MycobotBasic.h>
2+
#include <ParameterList.h>
3+
4+
MycobotBasic myCobot;
5+
6+
//定义一个Angles类型的变量angles,内容如下
7+
Angles angles = { -0.0, -0.0, -0.0, -0.0, -0.0, -0.0 };
8+
9+
10+
void setup() {
11+
12+
//打开通讯串口
13+
myCobot.setup();
14+
15+
//链接atom
16+
myCobot.powerOn();
17+
18+
//赋值angles为{ 0, 0, 0, 0, 0, 0 };
19+
for(auto &val : angles)
20+
val = 0.0;
21+
22+
//关节回到原点
23+
myCobot.WriteAngles(angles, 50);
24+
delay(5000);
25+
}
26+
27+
void loop() {
28+
for(int i = 1; i < 7; i++) //依次设定关节正反转90°
29+
{
30+
//myCobot.WriteAngle(i,angle,0-100);
31+
myCobot.WriteAngle(i, -90, 100); // set joint angle -90 degree
32+
delay(4000);
33+
myCobot.WriteAngle(i, 90, 100); // set joint angle 90 degree
34+
delay(4000);
35+
myCobot.WriteAngle(i, 0, 100); // set joint angle 0 degree
36+
delay(4000);
37+
}
38+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#include <MycobotBasic.h>
2+
#include <ParameterList.h>
3+
4+
MycobotBasic myCobot;
5+
6+
void setup() {
7+
// 打开Atom链接
8+
myCobot.setup();
9+
myCobot.powerOn();
10+
Serial.begin(9600);
11+
}
12+
void loop() {
13+
Serial.println("check setEncoder()...");
14+
myCobot.SetEncoder(Joint::J1, 2048);
15+
delay(5000);
16+
17+
Serial.println("check getEncoder()...");
18+
Serial.print("current J1 encoder is: ");
19+
Serial.println(myCobot.GetEncoder(Joint::J1));
20+
delay(5000);
21+
22+
Serial.println("check setEncoders()...");
23+
Angles encoders;
24+
for(auto &val : encoders)
25+
val = 2048;
26+
myCobot.SetEncoders(encoders, 50);
27+
delay(5000);
28+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include <MycobotBasic.h>
2+
#include <ParameterList.h>
3+
4+
MycobotBasic myCobot;
5+
6+
void setup() {
7+
myCobot.setup();
8+
myCobot.powerOn();
9+
}
10+
11+
void loop() {
12+
myCobot.setLEDRGB(0XFF, 0, 0); // set RGB show red
13+
delay(2000);
14+
myCobot.setLEDRGB(0, 0XFF, 0); // set RGB show blue
15+
delay(2000);
16+
myCobot.setLEDRGB(0, 0, 0XFF); // set RGB show green
17+
delay(2000);
18+
}

0 commit comments

Comments
 (0)