@cbenson @dialfonzo and allā¦
Looks like I am running into another issue with the servos firmwareā¦
I have code in my WIP where I was trying to detect if the servos were externally configured and if so donāt need to configureā¦
So I thought I would test the Gyre of the coxas knowing that half of them will need to be set different than defaultā¦
So have a method:
//============================================================================================
// Check to see if the servos have been configured properly
//============================================================================================
void ServoDriver::checkAndInitServosConfig(bool force_defaults)
{
use_servos_moveT = false;
// lets see if we need to set the Origin and GYRE...
// start off if the GYRE does not match what we believe we need... Set everything
if (!force_defaults) {
Serial.println(">>> Check Servo Settings <<<");
for (uint8_t leg = 0; leg < COUNT_LEGS; leg++) {
myLSS.setServoID(cPinTable[FIRSTCOXAPIN+leg]);
// BUGBUG we did reset but session did not equal config...
LSS_ConfigGyre cgyre_session = myLSS.getGyre(LSS_QuerySession);
LSS_ConfigGyre cgyre_config = myLSS.getGyre(LSS_QueryConfig);
if (myLSS.getLastCommStatus() == LSS_CommStatus_ReadSuccess) {
Serial.printf("%d:%d:%d:%d ", myLSS.getServoID(), cGyreTable[FIRSTCOXAPIN+leg], cgyre_session, cgyre_config);
if (cGyreTable[FIRSTCOXAPIN+leg] != cgyre_config) {
Serial.println("\n *** checkAndInitServosConfig: Need to configure servos ***");
force_defaults = true; // reuse variable
break;
}
}
}
}
// Either the caller to setup defaults or quick check above said to...
// First lets try broadcasts for the LSS=0 crud
myLSS.setServoID(LSS_BroadcastID);
myLSS.setMotionControlEnabled(0);
delay(5);
myLSS.setAngularHoldingStiffness(4, LSS_SetSession);
delay(5);
myLSS.setAngularStiffness(-4, LSS_SetSession);
delay(5);
myLSS.setFilterPositionCount(5, LSS_SetSession);
delay(5);
for (uint8_t leg = 0; leg < COUNT_LEGS; leg++) {
legs[leg].leg_found = true;
myLSS.setServoID(cPinTable[FIRSTCOXAPIN+leg]);
if (myLSS.getStatus() == LSS_StatusUnknown) legs[leg].leg_found = false;
if (force_defaults) {
Serial.print("@");
myLSS.setGyre(cGyreTable[FIRSTCOXAPIN+leg], LSS_SetSession);
myLSS.setOriginOffset(cDefaultServoOffsets[FIRSTCOXAPIN+leg], LSS_SetSession);
}
myLSS.setServoID(cPinTable[FIRSTFEMURPIN+leg]);
if (myLSS.getStatus() == LSS_StatusUnknown) legs[leg].leg_found = false;
if (force_defaults) {
myLSS.setGyre(cGyreTable[FIRSTFEMURPIN+leg], LSS_SetSession);
myLSS.setOriginOffset(cDefaultServoOffsets[FIRSTFEMURPIN+leg], LSS_SetSession);
}
myLSS.setServoID(cPinTable[FIRSTTIBIAPIN+leg]);
if (myLSS.getStatus() == LSS_StatusUnknown) legs[leg].leg_found = false;
if (force_defaults) {
myLSS.setGyre(cGyreTable[FIRSTTIBIAPIN+leg], LSS_SetSession);
myLSS.setOriginOffset(cDefaultServoOffsets[FIRSTTIBIAPIN+leg], LSS_SetSession);
}
if (legs[leg].leg_found) Serial.printf("Servos for Leg %s **found**\n", legs[leg].leg_name);
else Serial.printf("Servos for Leg %s **NOT found**\n", legs[leg].leg_name);
}
}
Before this code is called the init function broadcasts a servo resetā¦
// Reset all servos in case any are in error state
Serial.println("ServoDriver::Init - reset all servos");
myLSS.setServoID(LSS_BroadcastID);
myLSS.reset();
delay(1500); // make sure all servos reset.
I am running into a few issuesā¦
If I run the above code just after powering upā¦
You will see output showing:
Program Start
ServoDriver::Init - reset all servos
Servo(0): 8 -11
Servo(1): 14 1
Servo(2): 2 9
Servo(3): 7 -6
Servo(4): 13 5
Servo(5): 1 3
Servo(6): 10 864
Servo(7): 16 859
Servo(8): 4 823
Servo(9): 9 -859
Servo(10): 15 -856
Servo(11): 3 -862
Servo(12): 12 525
Servo(13): 18 515
Servo(14): 6 519
Servo(15): 11 -521
Servo(16): 17 -510
Servo(17): 5 -521
>>> Check Servo Settings <<<
8:-1:1:1
*** checkAndInitServosConfig: Need to configure servos ***
@Servos for Leg Right Rear **found**
@Servos for Leg Right Middle **found**
@Servos for Leg Right Front **found**
@Servos for Leg Left Rear **found**
@Servos for Leg Left Middle **found**
@Servos for Leg Left Front **found**
Notice the last part with the 8:01:1:1 saying it needs to configure servosā¦
Now if I restart the program you see:
>>> Check Servo Settings <<<
8:-1:-1:-1 14:-1:-1:-1 2:-1:-1:-1 7:1:1:1 13:1:1:1 1:1:1:1 Servos for Leg Right Rear **found**
Note: just put in the main part hereā¦
You see it cycled through all 6 coxa pins, and said they were all initialized properly?
Two issues:
First issue: Reset of servo I thought was supposed to revert everything back to what is stored in EEPROMā¦
Second issue: The init code I showed above does if thinks it needs to to set the Gyre for the sessionā¦
So why after reboot. does it show the Config setting as changedā¦ Note: If power off and back on they again show that this value has not changed on the EEPROMā¦
Another issue I have been running into is sending settings to broadcast IDs is not always workingā¦ That is again in the code above we have:
myLSS.setServoID(LSS_BroadcastID);
myLSS.setMotionControlEnabled(0);
delay(5);
myLSS.setAngularHoldingStiffness(4, LSS_SetSession);
delay(5);
myLSS.setAngularStiffness(-4, LSS_SetSession);
delay(5);
myLSS.setFilterPositionCount(5, LSS_SetSession);
delay(5);
At the start of my current offsets command code, I print out settings, to see what is going on:
for (sSN = 0; sSN < NUMSERVOS; sSN++) {
asOffsets[sSN] = 0;
myLSS.setServoID(cPinTable[sSN]);
Serial.print("Servo: ");
Serial.print(apszLegs[sSN % CNT_LEGS]);
Serial.print(apszLJoints[sSN / CNT_LEGS]);
Serial.print("(");
Serial.print(cPinTable[sSN], DEC);
Serial.print(") Pos:");
Serial.print(myLSS.getPosition(), DEC);
Serial.print("\tG:");
Serial.print(myLSS.getGyre(), DEC);
Serial.print("\tEMC:");
Serial.print(myLSS.getIsMotionControlEnabled(), DEC);
Serial.print("\tFPC:");
Serial.print(myLSS.getFilterPositionCount(), DEC);
Serial.print("\tAS:");
Serial.print(myLSS.getAngularStiffness(), DEC);
Serial.print("\tAH:");
Serial.print(myLSS.getAngularHoldingStiffness(), DEC);
Serial.print("\tO:");
Serial.print(myLSS.getOriginOffset(), DEC);
Serial.print("\tAR:");
Serial.println(myLSS.getAngularRange(), DEC);
}
In this last run I see:
Serial Cmd Line:o<eol>
Servo: RR Coxa(8) Pos:-2 G:-1 EMC:0 FPC:5 AS:0 AH:4 O:0 AR:1800
Servo: RM Coxa(14) Pos:-1 G:-1 EMC:0 FPC:5 AS:0 AH:4 O:0 AR:1800
Servo: RF Coxa(2) Pos:-4 G:-1 EMC:0 FPC:5 AS:0 AH:4 O:0 AR:1800
Servo: LR Coxa(7) Pos:-2 G:1 EMC:0 FPC:5 AS:0 AH:4 O:0 AR:1800
Servo: LM Coxa(13) Pos:2 G:1 EMC:0 FPC:5 AS:0 AH:4 O:0 AR:1800
Servo: LF Coxa(1) Pos:3 G:1 EMC:0 FPC:5 AS:0 AH:4 O:0 AR:1800
Servo: RR Femur(10) Pos:9 G:-1 EMC:0 FPC:5 AS:0 AH:4 O:-104 AR:1800
Servo: RM Femur(16) Pos:10 G:-1 EMC:0 FPC:5 AS:0 AH:4 O:-104 AR:1800
Servo: RF Femur(4) Pos:5 G:-1 EMC:0 FPC:5 AS:0 AH:4 O:-104 AR:1800
Servo: LR Femur(9) Pos:104 G:1 EMC:0 FPC:5 AS:0 AH:4 O:-104 AR:1800
Servo: LM Femur(15) Pos:8 G:1 EMC:0 FPC:5 AS:0 AH:4 O:-104 AR:1800
Servo: LF Femur(3) Pos:7 G:1 EMC:0 FPC:5 AS:0 AH:4 O:-104 AR:1800
Servo: RR Tibia(12) Pos:3 G:-1 EMC:0 FPC:5 AS:0 AH:4 O:-137 AR:1800
Servo: RM Tibia(18) Pos:3 G:-1 EMC:0 FPC:5 AS:0 AH:4 O:-137 AR:1800
Servo: RF Tibia(6) Pos:5 G:-1 EMC:0 FPC:5 AS:0 AH:4 O:-137 AR:1800
Servo: LR Tibia(11) Pos:7 G:1 EMC:0 FPC:5 AS:0 AH:4 O:-137 AR:1800
Servo: LM Tibia(17) Pos:6 G:1 EMC:0 FPC:5 AS:0 AH:4 O:-137 AR:1800
Servo: LF Tibia(5) Pos:4 G:1 EMC:0 FPC:5 AS:0 AH:4 O:-137 AR:1800
Find Servo Zeros.
$-Exit, +- changes, *-change servo
0-n Chooses a leg, C-Coxa, F-Femur, T-Tibia
Servo: RR Coxa(8)
In this case the AngularHoldingā¦ does not appear to have been processed.
In other runs some servos miss one or more of the settings.
Now back to playing (or pulling hair out)