@@ -7,7 +7,16 @@ int power_pin = 2;
77int open_pin = 5 ;
88int out_state = 1 ;
99
10- Coords pos_init_1 = {155.10 , -55.10 , 90.10 , -179.10 , 0.10 , -90.10 }; // 初始坐标
10+ Coords pos_init_1 = {155.10 , -55.10 , 90.10 , 179.10 , 0.10 , -90.10 }; // 初始坐标
11+ Coords pos_init_2 = {255.10 , -55.10 , 90.10 , 179.10 , 0.10 , -90.10 }; // 初始坐标
12+ Coords pos_init_3 = {255.10 , 55.10 , 90.10 , 179.10 , 0.10 , -90.10 }; // 初始坐标
13+ Coords pos_init_4 = {155.10 , 55.10 , 90.10 , 179.10 , 0.10 , -90.10 }; // 初始坐标
14+ Coords pos_init_5 = {155.10 , -55.10 , 90.10 , 179.10 , 0.10 , -90.10 }; // 初始坐标
15+ Coords pos_init_6 = {155.10 , -55.10 , 150.10 , 179.10 , 0.10 , -90.10 }; // 初始坐标
16+ Coords pos_init_7 = {155.10 , 55.10 , 150.10 , 179.10 , 0.10 , -90.10 }; // 初始坐标
17+ Coords pos_init_8 = {255.10 , 55.10 , 150.10 , 179.10 , 0.10 , -90.10 }; // 初始坐标
18+ Coords pos_init_9 = {255.10 , -55.10 , 150.10 , 179.10 , 0.10 , -90.10 }; // 初始坐标
19+ Coords pos_init_10 = {155.10 , -55.10 , 150.10 , 179.10 , 0.10 , -90.10 }; // 初始坐标
1120Coords data1;
1221Angles angles_0 = {0 , 0 , 0 , 0 , 0 , 0 }; // 初始化角度
1322
@@ -28,7 +37,7 @@ void setup() { //初始化函数
2837 delay (3000 );
2938 Serial.printf (" A键控制力矩开关 |" );
3039 Serial.println (" " );
31- Serial.printf (" B键控制移动到初始坐标 |" );
40+ Serial.printf (" B键控制立方体移动 |" );
3241 Serial.println (" " );
3342 Serial.printf (" C键控制前后左右上下移动 |" );
3443 Serial.println (" " );
@@ -43,9 +52,30 @@ void loop() { //主函数
4352 reless ();
4453 }
4554 if (M5.BtnB .wasReleased ()) { // 移动到初始角度
46- myCobot.writeCoords (pos_init_1,30 );
55+ myCobot.writeCoords (pos_init_1,50 );
56+ delay (3000 );
57+ myCobot.writeCoords (pos_init_2,30 );
58+ delay (2000 );
59+ myCobot.writeCoords (pos_init_3,30 );
60+ delay (2000 );
61+ myCobot.writeCoords (pos_init_4,30 );
62+ delay (2000 );
63+ myCobot.writeCoords (pos_init_5,30 );
64+ delay (2000 );
65+ myCobot.writeCoords (pos_init_6,30 );
66+ delay (2000 );
67+ myCobot.writeCoords (pos_init_7,30 );
68+ delay (2000 );
69+ myCobot.writeCoords (pos_init_8,30 );
70+ delay (2000 );
71+ myCobot.writeCoords (pos_init_9,30 );
72+ delay (2000 );
73+ myCobot.writeCoords (pos_init_10,30 );
74+ delay (2000 );
4775 }
4876 if (M5.BtnC .wasReleased ()) { // 前后左右上下移动
77+ myCobot.writeCoords (pos_init_1,30 );
78+ delay (3000 );
4979 data1 = pos_init_1;
5080 delay (50 );
5181 move_coords (0 , 10 );
@@ -60,6 +90,18 @@ void loop() { //主函数
6090 delay (2000 );
6191 move_coords (2 , -10 );
6292 delay (2000 );
93+ move_coords (3 , -10 );
94+ delay (2000 );
95+ move_coords (3 , 10 );
96+ delay (2000 );
97+ move_coords (4 , -10 );
98+ delay (2000 );
99+ move_coords (4 , 10 );
100+ delay (2000 );
101+ move_coords (5 , -10 );
102+ delay (2000 );
103+ move_coords (5 , 10 );
104+ delay (2000 );
63105}
64106}
65107
@@ -102,19 +144,19 @@ void move_coords(int dir, int num) //控制移动方向和步数,一步等
102144{
103145 if (num > 0 ){
104146 for (int i = 0 ; i<num; i++){
105- myCobot.writeCoords (data1,15 );
106- for (int i=0 ; i<6 ; i++){
107- Serial.print (data1[i]);
108- Serial.print (" , " );
109- }
110- Serial.println (" " );
111- data1[dir] += 10 ;
112- delay (100 );
147+ myCobot.writeCoords (data1,30 );
148+ for (int i=0 ; i<6 ; i++){
149+ Serial.print (data1[i]);
150+ Serial.print (" , " );
151+ }
152+ Serial.println (" " );
153+ data1[dir] += 10 ;
154+ delay (100 );
113155 }
114156 }else {
115157 num = 0 -num;
116158 for (int i = 0 ; i<num; i++){
117- myCobot.writeCoords (data1,15 );
159+ myCobot.writeCoords (data1,30 );
118160 for (int i=0 ; i<6 ; i++){
119161 Serial.print (data1[i]);
120162 Serial.print (" , " );
0 commit comments