T tried this 6-claw robot:
but I couldn't understand these code:
switch (servonum) {
case 6:
case 7:
case 9: servos[servonum]->write(position);
break;
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
case 8:
case 10:
case 11: servos[servonum]->write(180 - position);
break;
}
it was in this function:
void setServo(int servonum, int position) {
if (position != ServoPos[servonum]) {
ServoTime[servonum] = millis();
}
ServoPos[servonum] = position; // keep data on where the servo was last commanded to go
if (TrimInEffect && servonum < LEG_DOF) {
//Console.print("Trim leg "); Console.print(servonum); Console.print(" "); Console.println(ServoTrim[servonum] - TRIM_ZERO);
int p = map(position, 0, 180, SERVOMIN, SERVOMAX);
p += ServoTrim[servonum] - TRIM_ZERO; // adjust microseconds by trim value which is renormalized to the range -127 to 128
position = map(p, SERVOMIN, SERVOMAX, 0, 180);
}
if (!deferServoSet && servos[servonum]->attached()) {
#ifdef __VORPAL_FRAME__
servos[servonum]->write(position);
#else
switch (servonum) {
case 6:
case 7:
case 9: servos[servonum]->write(position);
break;
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
case 8:
case 10:
case 11: servos[servonum]->write(180 - position);
break;
}
#endif
}
// DEBUG: Uncomment the next line to debug setservo problems. It causes some lagginess due to all the printing
//Console.print("SS:");Console.print(servonum);Console.print(":");Console.println(position);
}
is here anyone know why the servonum in switch was not symmetrical?3 write(position) vs. 9 write(180 - position).