Skip to content

Commit 3c3cc21

Browse files
committed
fix: removing the speed function from the codes
1 parent 196949d commit 3c3cc21

File tree

4 files changed

+112
-63
lines changed

4 files changed

+112
-63
lines changed

examples/Platform_Tutorials/lessons/03-important-programming-concepts/Braccio_moving_range_angles/Braccio_moving_range_angles.ino

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,8 @@ float angles[6];
3838
void setup() {
3939
if (Braccio.begin())
4040
{
41-
/* Configure Braccio speed. */
4241
/* Warning: keep a safe distance from the robot and watch out for the robot's
4342
movement. It could be speedy and hit someone. */
44-
Braccio.speed(speed_grade_t(1000)/*SLOW*/);
4543
/* Move to home position. */
4644
Braccio.moveTo(HOME_POS[0], HOME_POS[1], HOME_POS[2], HOME_POS[3], HOME_POS[4], HOME_POS[5]);
4745
delay(TIME_DELAY);
Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
1+
/**************************************************************************************
2+
* INCLUDE
3+
**************************************************************************************/
4+
15
#include <Braccio++.h>
26

3-
// Variables
7+
/**************************************************************************************
8+
* DEFINES
9+
**************************************************************************************/
10+
11+
#define TIME_DELAY 1000
12+
13+
/**************************************************************************************
14+
* GLOBAL VARIABLES
15+
**************************************************************************************/
16+
417
// Braccio ++ joints
518
auto gripper = Braccio.get(1);
619
auto wristRoll = Braccio.get(2);
@@ -9,28 +22,28 @@ auto elbow = Braccio.get(4);
922
auto shoulder = Braccio.get(5);
1023
auto base = Braccio.get(6);
1124

12-
float initialGripper = 160.0;
1325
float initialBase = 90.0;
14-
float initialAngle = 150.0;
26+
float initialAngle = 157.5;
27+
1528
float angles[6];
1629

30+
/**************************************************************************************
31+
* SETUP/LOOP
32+
**************************************************************************************/
33+
1734
void setup() {
18-
Braccio.begin();
19-
delay(500); // Waits for the Braccio initialization
20-
21-
// Send motors initial angle
22-
gripper.move().to(initialGripper);
23-
delay(100);
24-
wristRoll.move().to(initialAngle);
25-
delay(100);
26-
wristPitch.move().to(initialAngle);
27-
delay(100);
28-
elbow.move().to(initialAngle);
29-
delay(100);
30-
shoulder.move().to(initialAngle);
31-
delay(100);
32-
base.move().to(initialBase);
33-
delay(100);
35+
if (Braccio.begin()){
36+
/* Warning: keep a safe distance from the robot and watch out for the robot's
37+
movement. It could be speedy and hit someone. */
38+
39+
/* Move to home position. */
40+
gripper.move().to(initialAngle); delay(TIME_DELAY);
41+
wristRoll.move().to(initialAngle); delay(TIME_DELAY);
42+
wristPitch.move().to(initialAngle); delay(TIME_DELAY);
43+
elbow.move().to(initialAngle); delay(TIME_DELAY);
44+
shoulder.move().to(initialAngle); delay(TIME_DELAY);
45+
base.move().to(initialBase); delay(TIME_DELAY);
46+
}
3447

3548
Serial.begin(115200);
3649
while(!Serial){}
@@ -53,5 +66,5 @@ void loop() {
5366
Serial.println("*****************************************\n\n\n\n\n");
5467
Serial.println("\n\n\n\n");
5568

56-
delay(1000);
69+
delay(TIME_DELAY);
5770
}

examples/Platform_Tutorials/projects/p01-moving-braccio/02_waving_with_Braccio/02_waving_with_Braccio.ino

Lines changed: 42 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,27 @@
1+
/**************************************************************************************
2+
* INCLUDE
3+
**************************************************************************************/
4+
15
#include <Braccio++.h>
26

7+
/**************************************************************************************
8+
* DEFINES
9+
**************************************************************************************/
10+
311
#define BUTTON_ENTER 6
12+
#define TIME_DELAY 1000
13+
14+
/**************************************************************************************
15+
* CONSTANTS
16+
**************************************************************************************/
17+
18+
float const HOME_POS[6] = {157.5, 157.5, 157.5, 157.5, 157.5, 90.0};
19+
float const WAVE_POS[6] = {180.0, 260.0, 157.5, 157.5, 157.5, 180.0};
420

21+
/**************************************************************************************
22+
* GLOBAL VARIABLES
23+
**************************************************************************************/
24+
525
// Braccio ++ joints
626
auto gripper = Braccio.get(1);
727
auto wristRoll = Braccio.get(2);
@@ -10,41 +30,41 @@ auto elbow = Braccio.get(4);
1030
auto shoulder = Braccio.get(5);
1131
auto base = Braccio.get(6);
1232

13-
/* Variables */
14-
// initialAngles[6] = {gripper, wristRoll, wristPitch, elbow, shoulder, base}
15-
float homePos[6] = {160.0, 150.0, 220.0, 220.0, 100.0, 180.0};
16-
float wavePos[6] = {180.0, 250.0, 145.0, 150.0, 150.0, 90.0};
17-
1833
bool movement = false; // Flag to initialize joints' movements
1934

35+
/**************************************************************************************
36+
* SETUP/LOOP
37+
**************************************************************************************/
38+
2039
void setup() {
21-
Braccio.begin();
22-
delay(500); // Waits for the Braccio initialization
40+
if (Braccio.begin()){
41+
/* Warning:
42+
Keep a safe distance from the robot until you make sure the code is properly
43+
working. Be mindful of the robot’s movement prior to that, as it could be
44+
speedy and accidentally hit someone.
45+
*/
2346

24-
// Set motors initial angle
25-
// Should move all the motors at once
26-
Braccio.moveTo(homePos[0], homePos[1], homePos[2], homePos[3], homePos[4], homePos[5]);
27-
delay(500);
47+
/* Move to home position. */
48+
Braccio.moveTo(HOME_POS[0], HOME_POS[1], HOME_POS[2], HOME_POS[3], HOME_POS[4], HOME_POS[5]);
49+
delay(TIME_DELAY);
50+
}
2851
}
2952

30-
// Waving whit Wrist pitch
53+
// Waving with Wrist pitch
3154
void loop() {
3255
int pressedKey = Braccio.getKey();
3356

3457
if (pressedKey == BUTTON_ENTER)
3558
movement = true; // Trigger joints' movements
3659

3760
if (movement) {
38-
Braccio.moveTo(wavePos[0], wavePos[1], wavePos[2], wavePos[3], wavePos[4], wavePos[5]);
39-
delay(1000);
40-
41-
for (int i = 1; i <= 10; i++) {
42-
wristPitch.move().to(100.0f);
43-
delay(300);
44-
wristPitch.move().to(190.0f);
45-
delay(600);
46-
wristPitch.move().to(145.0f);
47-
delay(300);
61+
Braccio.moveTo(WAVE_POS[0], WAVE_POS[1], WAVE_POS[2], WAVE_POS[3], WAVE_POS[4], WAVE_POS[5]);
62+
delay(TIME_DELAY/10);
63+
64+
for (int i = 1; i <= 5; i++) {
65+
wristPitch.move().to(120.0f); delay(TIME_DELAY/2);
66+
wristPitch.move().to(200.0f); delay(TIME_DELAY);
67+
wristPitch.move().to(WAVE_POS[3]);
4868
}
4969

5070
movement = false; // Stop joints' movements
Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,26 @@
1+
/**************************************************************************************
2+
* INCLUDE
3+
**************************************************************************************/
4+
15
#include <Braccio++.h>
26

7+
/**************************************************************************************
8+
* DEFINES
9+
**************************************************************************************/
10+
311
#define BUTTON_ENTER 6
12+
#define TIME_DELAY 1000
13+
14+
/**************************************************************************************
15+
* CONSTANTS
16+
**************************************************************************************/
17+
18+
static float const HOME_POS[6] = {157.5, 157.5, 157.5, 157.5, 157.5, 90.0};
19+
static float const AGREE_POS[6] = {160.0, 160.0, 210.0, 240.0, 100.0, 180.0};
20+
21+
/**************************************************************************************
22+
* GLOBAL VARIABLES
23+
**************************************************************************************/
424

525
// Braccio ++ joints
626
auto gripper = Braccio.get(1);
@@ -10,20 +30,21 @@ auto elbow = Braccio.get(4);
1030
auto shoulder = Braccio.get(5);
1131
auto base = Braccio.get(6);
1232

13-
/* Variables */
14-
// initialAngles[6] = {gripper, wristRoll, wristPitch, elbow, shoulder, base}
15-
float homePos[6] = {160.0, 150.0, 220.0, 220.0, 100.0, 180.0};
16-
1733
bool movement = false; // Flag to initialize joints' movements
1834

35+
/**************************************************************************************
36+
* SETUP/LOOP
37+
**************************************************************************************/
38+
1939
void setup() {
20-
Braccio.begin();
21-
delay(500); // Waits for the Braccio initialization
40+
if (Braccio.begin()){
41+
/* Warning: keep a safe distance from the robot and watch out for the robot's
42+
movement. It could be speedy and hit someone. */
2243

23-
// Set motors initial angle
24-
// Should move all the motors at once
25-
Braccio.moveTo(homePos[0], homePos[1], homePos[2], homePos[3], homePos[4], homePos[5]);
26-
delay(500);
44+
/* Move to home position. */
45+
Braccio.moveTo(HOME_POS[0], HOME_POS[1], HOME_POS[2], HOME_POS[3], HOME_POS[4], HOME_POS[5]);
46+
delay(500);
47+
}
2748
}
2849

2950
void loop() {
@@ -33,18 +54,15 @@ void loop() {
3354
movement = true; // Trigger joints' movements
3455

3556
if (movement) {
36-
Braccio.moveTo(160.0, 150.0, 220.0, 220.0, 100.0, 270.0);
37-
delay(1000);
57+
Braccio.moveTo(AGREE_POS[0], AGREE_POS[1], AGREE_POS[2], AGREE_POS[3], AGREE_POS[4], AGREE_POS[5]);
58+
delay(TIME_DELAY/10);
3859

3960
for (int i = 1; i <= 10; i++) {
40-
wristPitch.move().to(190.0f);
41-
delay(200);
42-
wristPitch.move().to(250.0f);
43-
delay(400);
44-
wristPitch.move().to(220.0f);
45-
delay(200);
61+
wristPitch.move().to(190.0f); delay(TIME_DELAY/2);
62+
wristPitch.move().to(240.0f); delay(TIME_DELAY);
63+
wristPitch.move().to(AGREE_POS[3]);
4664
}
4765

48-
movement = false; // Stop joints' moviments
66+
movement = false; // Stop joints' movements
4967
}
5068
}

0 commit comments

Comments
 (0)