@@ -82,13 +82,21 @@ bool set_initial_servo_position(int const id, float const target_angle)
8282 Serial.println (msg);
8383 }
8484
85- if (!isTargetAngleReached (EPSILON)) {
86- Serial.println (" Servo did not reach target angle." );
85+ if (!isTargetAngleReached (EPSILON))
86+ {
87+ Serial.print (" Error: Servo " );
88+ Serial.print (id);
89+ Serial.print (" did not reach target angle." );
90+ Serial.println ();
8791 return false ;
8892 }
8993
90- if (isTimeout ()) {
91- Serial.println (" Timeout error." );
94+ if (isTimeout ())
95+ {
96+ Serial.print (" Error: Servo " );
97+ Serial.print (id);
98+ Serial.println (" did not reach target angle within time limit." );
99+ Serial.println ();
92100 return false ;
93101 }
94102
@@ -111,22 +119,32 @@ void setup()
111119
112120 Braccio.disengage ();
113121
122+ int success_cnt = 0 ;
114123 for (auto & servo : INITIAL_SERVO_POSITION)
115124 {
116125 Serial.print (" Servo " );
117126 Serial.print (servo.id ());
118127 Serial.print (" : Target Angle = " );
119128 Serial.print (servo.angle ());
120- Serial.print (" °" );
121129 Serial.println ();
122130
123- if (!set_initial_servo_position (servo.id (), servo.angle ())) {
124- Serial.println (" ERROR." );
125- return ;
126- }
131+ if (set_initial_servo_position (servo.id (), servo.angle ()))
132+ success_cnt++;
127133 }
128134
129- Serial.println (" SUCCESS : all servos are set to their initial position." );
135+ if (success_cnt != (SmartServoClass::NUM_MOTORS - 1 ))
136+ {
137+ Serial.println (" SUCCESS : all servos are set to their initial position." );
138+ }
139+ else
140+ {
141+ Serial.print (" ERROR: only " );
142+ Serial.print (success_cnt);
143+ Serial.print (" of " );
144+ Serial.print (SmartServoClass::NUM_MOTORS);
145+ Serial.print (" could be set to the desired initial position." );
146+ Serial.println ();
147+ }
130148}
131149
132150void loop ()
0 commit comments