Skip to content

Check if Braccio.begin() does return true. #50

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions examples/Braccio_LearnByDoing/Braccio_LearnByDoing.ino
Original file line number Diff line number Diff line change
Expand Up @@ -118,20 +118,23 @@ static mbed::FATFileSystem fs("fs");
void setup()
{
Serial.begin(115200);
while (!Serial) { }
for (auto const start = millis(); !Serial && ((millis() - start) < 5000); delay(10)) { }

// Mount file system for load/store movements
int err = fs.mount(&bd);
if (err) {
err = fs.reformat(&bd);
}

// Call Braccio.begin() for default menu or pass a function for custom menu
Braccio.begin(customMenu);
if (!Braccio.begin(customMenu)) {
if (Serial) Serial.println("Braccio.begin() failed.");
for(;;) { }
}
Serial.println("Replicate a movement");
}

void loop() {
void loop()
{
if (state == LEARN) {
Braccio.positions(idx);
idx += 6;
Expand Down
14 changes: 11 additions & 3 deletions examples/LCD_Custom_Menu/LCD_Custom_Menu.ino
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,18 @@ void customMenu(){
* SETUP/LOOP
**************************************************************************************/

void setup() {
Braccio.begin(customMenu);
void setup()
{
Serial.begin(115200);
for (auto const start = millis(); !Serial && ((millis() - start) < 5000); delay(10)) { }

if (!Braccio.begin(customMenu)) {
if (Serial) Serial.println("Braccio.begin() failed.");
for(;;) { }
}
}

void loop() {
void loop()
{

}
14 changes: 11 additions & 3 deletions examples/LCD_Menu_Joystick/LCD_Menu_Joystick.ino
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,18 @@ void customMenu(){
* SETUP/LOOP
**************************************************************************************/

void setup() {
Braccio.begin(customMenu);
void setup()
{
Serial.begin(115200);
for (auto const start = millis(); !Serial && ((millis() - start) < 5000); delay(10)) { }

if (!Braccio.begin(customMenu)) {
if (Serial) Serial.println("Braccio.begin() failed.");
for(;;) { }
}
}

void loop() {
void loop()
{

}
13 changes: 10 additions & 3 deletions examples/LCD_Motors/LCD_Motors.ino
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,19 @@ void customMenu() {
* SETUP/LOOP
**************************************************************************************/

void setup() {
Braccio.begin(customMenu);
void setup()
{
Serial.begin(115200);
for (auto const start = millis(); !Serial && ((millis() - start) < 5000); delay(10)) { }

if (!Braccio.begin(customMenu)) {
if (Serial) Serial.println("Braccio.begin() failed.");
for(;;) { }
}
}

void loop() {
void loop()
{
for (float angle = 0.0; angle <= 180.0; angle+=10.0){
Braccio.move(selected_motor).to(angle);
delay(500);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,11 @@ void setup()
Serial.begin(115200);
while(!Serial) { }

Braccio.begin();
if (!Braccio.begin()) {
Serial.println("Braccio.begin() failed.");
for(;;) { }
}

Braccio.disengage();

for (auto & servo : INITIAL_SERVO_POSITION)
Expand Down
8 changes: 6 additions & 2 deletions examples/Tools/Test_Inputs/Test_Inputs.ino
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@
void setup()
{
Serial.begin(115200);
while(!Serial){}
while(!Serial) { }

if (!Braccio.begin()) {
Serial.println("Braccio.begin() failed.");
for(;;) { }
}

Braccio.begin();
Serial.println("Press any button or move the joystick.");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,13 @@ void test_motor(int const id)
void setup()
{
Serial.begin(115200);
while(!Serial){}
while(!Serial) { }

if (!Braccio.begin()) {
Serial.println("Braccio.begin() failed.");
for(;;) { }
}

Braccio.begin();
Serial.println("Testing motor angular movement!");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ void setup()
Serial.begin(115200);
while(!Serial) { }

Braccio.begin();
if (!Braccio.begin()) {
Serial.println("Braccio.begin() failed.");
for(;;) { }
}

Serial.println("Testing motor communication!");
Serial.println("Choose motor 1 to 6 to test the connection");
Serial.print(">> ");
Expand Down