@@ -82,13 +82,21 @@ bool set_initial_servo_position(int const id, float const target_angle)
82
82
Serial.println (msg);
83
83
}
84
84
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 ();
87
91
return false ;
88
92
}
89
93
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 ();
92
100
return false ;
93
101
}
94
102
@@ -111,22 +119,32 @@ void setup()
111
119
112
120
Braccio.disengage ();
113
121
122
+ int success_cnt = 0 ;
114
123
for (auto & servo : INITIAL_SERVO_POSITION)
115
124
{
116
125
Serial.print (" Servo " );
117
126
Serial.print (servo.id ());
118
127
Serial.print (" : Target Angle = " );
119
128
Serial.print (servo.angle ());
120
- Serial.print (" °" );
121
129
Serial.println ();
122
130
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++;
127
133
}
128
134
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
+ }
130
148
}
131
149
132
150
void loop ()
0 commit comments