Example use of I2CTransaction class. In this example, the master mbed is talking to 3 legs of the SIPPC3B robot.
LegInterface.cpp
00001 00002 /* 00003 Interface for communication to the set of legs for the OU SIPPC Robot (version 3B and beyond). 00004 00005 Note: this interface is talking to very custom hardware. As a result, it serves more as an 00006 example of how to use the I2CTransaction library. 00007 00008 Author: Andrew H. Fagg (May, 2014) 00009 00010 More documentation to come... 00011 00012 */ 00013 00014 00015 #include "LegInterface.h" 00016 00017 const int LegInterface::LegAddress[] = {I2C_ADDR_WEST, I2C_ADDR_EAST, I2C_ADDR_SOUTH}; 00018 00019 /** 00020 Constructor: create all of the packets that can be sent + the associated transactions 00021 */ 00022 00023 LegInterface::LegInterface(Serial *pc) 00024 { 00025 // ESTOP transactions 00026 transactionEstop[LEG_W] = new I2CTransaction(I2C_ADDR_WEST, (char*) &legPacketEstop, 4); 00027 transactionEstop[LEG_E] = new I2CTransaction(I2C_ADDR_EAST, (char*) &legPacketEstop, 4); 00028 transactionEstop[LEG_S] = new I2CTransaction(I2C_ADDR_SOUTH, (char*) &legPacketEstop, 4); 00029 00030 // Query state transactions 00031 legPacketQuery.type = nsPacketsLeg::QUERY_STATE; 00032 transactionQueryState[LEG_W] = new I2CTransaction(I2C_ADDR_WEST, (char*) &legPacketQuery, 4, 00033 (char*) &(legState[LEG_W]), sizeof(LegState_t)); 00034 transactionQueryState[LEG_E] = new I2CTransaction(I2C_ADDR_EAST, (char*) &legPacketQuery, 4, 00035 (char*) &(legState[LEG_E]), sizeof(LegState_t)); 00036 transactionQueryState[LEG_S] = new I2CTransaction(I2C_ADDR_SOUTH, (char*) &legPacketQuery, 4, 00037 (char*) &(legState[LEG_S]), sizeof(LegState_t)); 00038 00039 // Query leg parameter transactions. Note: shared outgoing packet structure 00040 legPacketQueryLiftParams.type = nsPacketsLeg::GET_LIFT_PARAMS; 00041 transactionQueryLiftParams[LEG_W] = new I2CTransaction(I2C_ADDR_WEST, (char*) &legPacketQueryLiftParams, 4, 00042 (char *) &legLiftParams, sizeof(LegControlParams_t)); 00043 transactionQueryLiftParams[LEG_E] = new I2CTransaction(I2C_ADDR_EAST, (char*) &legPacketQueryLiftParams, 4, 00044 (char *) &legLiftParams, sizeof(LegControlParams_t)); 00045 transactionQueryLiftParams[LEG_S] = new I2CTransaction(I2C_ADDR_SOUTH, (char*) &legPacketQueryLiftParams, 4, 00046 (char *) &legLiftParams, sizeof(LegControlParams_t)); 00047 00048 legPacketQueryWheelParams.type = nsPacketsLeg::GET_WHEEL_PARAMS; 00049 transactionQueryWheelParams[LEG_W] = new I2CTransaction(I2C_ADDR_WEST, (char*) &legPacketQueryWheelParams, 4, 00050 (char *) &legWheelParams, sizeof(LegControlParams_t)); 00051 transactionQueryWheelParams[LEG_E] = new I2CTransaction(I2C_ADDR_EAST, (char*) &legPacketQueryWheelParams, 4, 00052 (char *) &legWheelParams, sizeof(LegControlParams_t)); 00053 transactionQueryWheelParams[LEG_S] = new I2CTransaction(I2C_ADDR_SOUTH, (char*) &legPacketQueryWheelParams, 4, 00054 (char *) &legWheelParams, sizeof(LegControlParams_t)); 00055 00056 00057 // Set leg parameter transactions 00058 // Note: shared packet structure across transactions (since we are setting one at a time) 00059 legPacketSetLiftParams.type = nsPacketsLeg::SET_LIFT_PARAMS; 00060 transactionSetLiftParams[LEG_W] = new I2CTransaction(I2C_ADDR_WEST, (char*) &legPacketSetLiftParams, 4+sizeof(LegControlParams_t)); 00061 transactionSetLiftParams[LEG_E] = new I2CTransaction(I2C_ADDR_EAST, (char*) &legPacketSetLiftParams, 4+sizeof(LegControlParams_t)); 00062 transactionSetLiftParams[LEG_S] = new I2CTransaction(I2C_ADDR_SOUTH, (char*) &legPacketSetLiftParams, 4+sizeof(LegControlParams_t)); 00063 00064 legPacketSetWheelParams.type = nsPacketsLeg::SET_WHEEL_PARAMS; 00065 transactionSetWheelParams[LEG_W] = new I2CTransaction(I2C_ADDR_WEST, (char*) &legPacketSetWheelParams, 4+sizeof(LegControlParams_t)); 00066 transactionSetWheelParams[LEG_E] = new I2CTransaction(I2C_ADDR_EAST, (char*) &legPacketSetWheelParams, 4+sizeof(LegControlParams_t)); 00067 transactionSetWheelParams[LEG_S] = new I2CTransaction(I2C_ADDR_SOUTH, (char*) &legPacketSetWheelParams, 4+sizeof(LegControlParams_t)); 00068 00069 // Goal set 00070 legPacketSetGoal[LEG_W].type = nsPacketsLeg::SET_GOAL; 00071 transactionSetGoal[LEG_W] = new I2CTransaction(I2C_ADDR_WEST, (char*) &(legPacketSetGoal[LEG_W]), 4+sizeof(Goal_t)); 00072 00073 legPacketSetGoal[LEG_E].type = nsPacketsLeg::SET_GOAL; 00074 transactionSetGoal[LEG_E] = new I2CTransaction(I2C_ADDR_EAST, (char*) &(legPacketSetGoal[LEG_E]), 4+sizeof(Goal_t)); 00075 00076 legPacketSetGoal[LEG_S].type = nsPacketsLeg::SET_GOAL; 00077 transactionSetGoal[LEG_S] = new I2CTransaction(I2C_ADDR_SOUTH, (char*) &(legPacketSetGoal[LEG_S]), 4+sizeof(Goal_t)); 00078 00079 // Other initialziations 00080 this->pc = pc; 00081 Leg leg = LEG_S; 00082 pc->printf("codes: %d %d\n\r", transactionSetLiftParams[leg]->getStatus(0), transactionSetLiftParams[leg]->getStatus(1)); 00083 00084 } 00085 00086 /** 00087 Attempt to send an estop to all legs. 00088 00089 @param estop true = stop all motion; false = enable motion 00090 00091 @return true = transaction successfully scheduled, false = prior attempt at sending had not completed. 00092 */ 00093 00094 bool LegInterface::sendEstop(bool estop) 00095 { 00096 // Has the prior attempt at sending the estop completed? 00097 if(!transactionEstop[LEG_W]->completed() || 00098 !transactionEstop[LEG_E]->completed() || 00099 !transactionEstop[LEG_S]->completed()) { 00100 // No: do not attempt 00101 return false; 00102 } 00103 00104 // Yes - configure the packet (all packets are the same in this case) 00105 legPacketEstop.type = estop?nsPacketsLeg::ESTOP_ON:nsPacketsLeg::ESTOP_OFF; 00106 00107 // Schedule the transactions 00108 transactionEstop[LEG_W]->initiateTransaction(); 00109 transactionEstop[LEG_E]->initiateTransaction(); 00110 transactionEstop[LEG_S]->initiateTransaction(); 00111 00112 // Complete 00113 return true; 00114 } 00115 00116 bool LegInterface::queryStateInitiate() 00117 { 00118 /* 00119 transactionQueryState[LEG_W]->checkTransaction(); 00120 transactionQueryState[LEG_E]->checkTransaction(); 00121 transactionQueryState[LEG_S]->checkTransaction(); 00122 */ 00123 00124 // Has the prior attempt at sending the estop completed? 00125 if(!queryStateCompleted()) { 00126 // No: do not attempt 00127 return false; 00128 } 00129 00130 //this->pc->printf("########################## FOO @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n\r"); 00131 // Magic numbers 00132 for(int i= 0; i < NUM_LEGS; ++i) { 00133 this->legState[i].magic = 0; 00134 } 00135 00136 // Query last had completed 00137 // Schedule the transactions 00138 transactionQueryState[LEG_W]->initiateTransaction(); 00139 transactionQueryState[LEG_E]->initiateTransaction(); 00140 transactionQueryState[LEG_S]->initiateTransaction(); 00141 00142 return true; 00143 } 00144 00145 bool LegInterface::queryStateWaitForCompletion(int timeout) 00146 { 00147 for(int i = 0; i < NUM_LEGS; ++i) { 00148 if(!transactionQueryState[i]->waitForCompletion(timeout)) { 00149 return false; 00150 } 00151 } 00152 return true; 00153 } 00154 00155 /** 00156 Check if the query of leg state has been completed (successful or not) 00157 00158 @return true if completed 00159 */ 00160 00161 bool LegInterface::queryStateCompleted() 00162 { 00163 for(int i = 0; i < NUM_LEGS; ++i) { 00164 if(!transactionQueryState[i]->completed()) { 00165 return false; 00166 } 00167 } 00168 return true; 00169 } 00170 00171 /** 00172 Check if the query of leg state has been successfully completed 00173 00174 @return true if successfully completed 00175 */ 00176 00177 bool LegInterface::queryStateSuccess() 00178 { 00179 for(int i = 0; i < NUM_LEGS; ++i) { 00180 if(!transactionQueryState[i]->success()) { 00181 return false; 00182 } 00183 } 00184 return true; 00185 } 00186 00187 /** 00188 Print out the internal magic numbers 00189 */ 00190 00191 void LegInterface::queryStateReportMagic() 00192 { 00193 for(int i = 0; i < NUM_LEGS; ++i) { 00194 pc->printf("%x ", legState[i].magic); 00195 } 00196 pc->printf("\n\r"); 00197 } 00198 /** 00199 Check if the query of estop has been completed (successful or not) 00200 00201 @return true if completed 00202 */ 00203 00204 bool LegInterface::queryEstopCompleted() 00205 { 00206 for(int i = 0; i < NUM_LEGS; ++i) { 00207 if(!transactionEstop[i]->completed()) { 00208 return false; 00209 } 00210 } 00211 return true; 00212 } 00213 00214 /** 00215 Check if the query of estop has been successfully completed 00216 00217 @return true if successfully completed 00218 */ 00219 00220 bool LegInterface::queryEstopSuccess() 00221 { 00222 for(int i = 0; i < NUM_LEGS; ++i) { 00223 if(!transactionEstop[i]->success()) { 00224 return false; 00225 } 00226 } 00227 return true; 00228 } 00229 00230 void LegInterface::queryStateTest(Serial *pc) 00231 { 00232 for(int i = 0; i < NUM_LEGS; ++i) { 00233 pc->printf("Status %d: %d %d\n\r", i, transactionQueryState[i]->getStatus(0), transactionQueryState[i]->getStatus(1)); 00234 } 00235 } 00236 00237 00238 bool LegInterface::queryStateCopy(LegState_t legState[NUM_LEGS]) 00239 { 00240 // Has the prior attempt at querying the state completed? 00241 if(!queryStateCompleted()) { 00242 // No: do not attempt 00243 return false; 00244 } 00245 00246 // Transaction complete: copy the state of the legs only if the magic number is correct 00247 if(this->legState[LEG_W].magic == I2C_MAGIC_NUMBER) 00248 legState[LEG_W] = this->legState[LEG_W]; 00249 if(this->legState[LEG_E].magic == I2C_MAGIC_NUMBER) 00250 legState[LEG_E] = this->legState[LEG_E]; 00251 if(this->legState[LEG_S].magic == I2C_MAGIC_NUMBER) 00252 legState[LEG_S] = this->legState[LEG_S]; 00253 00254 return true; 00255 } 00256 00257 /** 00258 Copy the state of the legs from the LegInterface structure to usable structures. In order for the data to be copied, the 00259 transaction must be successful, and the leg packet must have a valid magic number (the latter is evalulated on a leg-by-leg 00260 basis). 00261 00262 The input parameters are destructively modified only if the data are valid. The exception is the "magic" parameter. This is 00263 only changed if the set of transactions was successful. 00264 00265 @param liftPosition Lift position of each of the legs (m above the ground) 00266 @param liftVelocity Velocity of the lifts (m/s) 00267 @param wheelPosition Position of each of the wheels (m) 00268 @param wheelVelocity Velocity of the wheels (m/s) 00269 @param cliff Cliff sensors 00270 @param limit Limit sensors (lifts) 00271 @param estop Estop state of each of the legs 00272 @param magic Magic number from each leg 00273 00274 @return true if Some data were updated; false if no change 00275 00276 */ 00277 00278 bool LegInterface::queryStateCopy(float liftPosition[NUM_LEGS], float liftVelocity[NUM_LEGS], float wheelPosition[NUM_LEGS], float wheelVelocity[NUM_LEGS], 00279 bool cliff[NUM_LEGS], bool limit[NUM_LEGS], bool estop[NUM_LEGS], uint8_t magic[NUM_LEGS]) 00280 { 00281 // Has the prior attempt at getting state completed? 00282 if(!queryStateSuccess()) { 00283 // No: do not attempt the copy 00284 return false; 00285 } 00286 00287 // Transaction complete: copy the state of the legs 00288 for(int i = 0; i < NUM_LEGS; ++i) { 00289 if(this->legState[i].magic == I2C_MAGIC_NUMBER) { 00290 // Only copy if the magic number matches 00291 liftPosition[i] = this->legState[i].lift.pos / LIFT_TICKS_PER_METER - LIFT_OFFSET; 00292 liftVelocity[i] = this->legState[i].lift.vel / LIFT_TICKS_PER_METER; 00293 wheelPosition[i] = this->legState[i].wheel.pos / TICKS_PER_METER; 00294 wheelVelocity[i] = this->legState[i].wheel.vel / TICKS_PER_METER; 00295 cliff[i] = this->legState[i].cliff; 00296 limit[i] = this->legState[i].limit; 00297 estop[i] = this->legState[i].estop; 00298 00299 } 00300 // Also copy the magic number 00301 magic[i] = this->legState[i].magic; 00302 //pc->printf("%x ", magic[i]); 00303 } 00304 //pc->printf("\n\r"); 00305 00306 return true; 00307 } 00308 00309 void LegInterface::displayLegState(LegState_t *legState) 00310 { 00311 pc->printf("Cliff = %d, Limit = %d\n\r", legState->cliff, legState->limit); 00312 pc->printf("Wheel: pos=%d, vel=%d\n\r", legState->wheel.pos, legState->wheel.vel); 00313 pc->printf("Lift: pos=%d, vel=%d\n\r", legState->lift.pos, legState->lift.vel); 00314 } 00315 00316 00317 bool LegInterface::queryLegParams(Leg leg, LegControlParams_t *liftParams, LegControlParams_t *wheelParams) 00318 { 00319 /* 00320 if(pc != NULL) { 00321 pc->printf("completed: %d %d %d %d\n\r", transactionQueryLiftParams[leg]->completed(), transactionQueryWheelParams[leg]->completed(), 00322 transactionSetLiftParams[leg]->completed(), transactionSetWheelParams[leg]->completed()); 00323 pc->printf("codes: %d %d\n\r", transactionSetLiftParams[leg]->getStatus(0), transactionSetLiftParams[leg]->getStatus(1)); 00324 } 00325 */ 00326 00327 // Has the prior attempt at querying/setting leg parameters completed? 00328 if(!transactionQueryLiftParams[leg]->completed() || !transactionQueryWheelParams[leg]->completed() 00329 || !transactionSetLiftParams[leg]->completed() || !transactionSetWheelParams[leg]->completed()) { 00330 // No: do not attempt 00331 return false; 00332 } 00333 00334 // Yes: initiate the transactions 00335 transactionQueryLiftParams[leg]->initiateTransaction(); 00336 transactionQueryWheelParams[leg]->initiateTransaction(); 00337 //pc->printf("codes: %d %d\n\r", transactionQueryWheelParams[leg]->getStatus(0), transactionQueryWheelParams[leg]->getStatus(1)); 00338 00339 if(transactionQueryLiftParams[leg]->waitForCompletion() && transactionQueryWheelParams[leg]->waitForCompletion()) { 00340 // Completed 00341 *liftParams = this->legLiftParams; 00342 *wheelParams = this->legWheelParams; 00343 return true; 00344 } 00345 // A timeout happened (no copy) 00346 return false; 00347 } 00348 00349 void LegInterface::displayParams(LegControlParams_t *params) 00350 { 00351 pc->printf("Kp = %d\t Kv = %d\t Ki=%d\n\r", params->Kp, params->Kv, params->Ki); 00352 pc->printf("deadband = %d\n\r", params->deadband); 00353 pc->printf("Control signal range = [%d, %d]\n\r", params->min_val, params->max_val); 00354 pc->printf("Max error = %d, max error accum = %d\n\r", params->max_error, params->max_error_accum); 00355 pc->printf("Max acceleration = %d\n\r", params->max_accel); 00356 } 00357 00358 bool LegInterface::setLegParams(Leg leg, LegControlParams_t *liftParams, LegControlParams_t *wheelParams) 00359 { 00360 00361 00362 // Has the prior attempt at querying/setting leg parameters completed? 00363 if(!transactionQueryLiftParams[leg]->completed() || !transactionQueryWheelParams[leg]->completed() 00364 || !transactionSetLiftParams[leg]->completed() || !transactionSetWheelParams[leg]->completed()) { 00365 // No: do not attempt 00366 return false; 00367 } 00368 00369 // Copy provided parameters into structure to send 00370 this->legLiftParams = *liftParams; 00371 this->legWheelParams = *wheelParams; 00372 00373 // Yes: initiate the transactions 00374 transactionSetLiftParams[leg]->initiateTransaction(); 00375 transactionSetWheelParams[leg]->initiateTransaction(); 00376 00377 if(transactionQueryLiftParams[leg]->waitForCompletion() && transactionQueryWheelParams[leg]->waitForCompletion()) { 00378 // Completed 00379 return true; 00380 } 00381 // A timeout happened (no copy) 00382 return false; 00383 } 00384 00385 /** 00386 Set the goals for all the legs 00387 */ 00388 00389 bool LegInterface::setLegGoal(int32_t liftPos[NUM_LEGS], int32_t wheelVel[NUM_LEGS]) 00390 { 00391 // Has the previous attempt completed? 00392 if(!transactionSetGoal[LEG_W]->completed() || 00393 !transactionSetGoal[LEG_E]->completed() || 00394 !transactionSetGoal[LEG_S]->completed()) { 00395 // No: refuse to send 00396 00397 // Debugging 00398 pc->putc('{'); 00399 pc->putc('0' + transactionSetGoal[LEG_W]->completed()); 00400 pc->putc('0' + transactionSetGoal[LEG_E]->completed()); 00401 pc->putc('0' + transactionSetGoal[LEG_S]->completed()); 00402 pc->putc('-'); 00403 00404 /* 00405 // For offending legs: clear the I2C status (next attempt will be seen as completed) 00406 for(int i = 0; i < NUM_LEGS; ++i) { 00407 if(!transactionSetGoal[i]->completed()) { 00408 transactionSetGoal[i]->clearStatus(); 00409 } 00410 } 00411 */ 00412 00413 pc->putc('0' + transactionSetGoal[LEG_W]->completed()); 00414 pc->putc('0' + transactionSetGoal[LEG_E]->completed()); 00415 pc->putc('0' + transactionSetGoal[LEG_S]->completed()); 00416 pc->putc('}'); 00417 return false; 00418 } 00419 00420 // Copy goals into structures to send and initiate 00421 for(int i = 0; i < LegInterface::NUM_LEGS; ++i) { 00422 legPacketSetGoal[i].contents.as_goal.liftPos = liftPos[i]; 00423 legPacketSetGoal[i].contents.as_goal.wheelVel = wheelVel[i]; 00424 transactionSetGoal[i]->initiateTransaction(); 00425 } 00426 00427 // Indicate success 00428 return true; 00429 } 00430 00431 00432 00433 bool LegInterface::setLegGoal(float liftPos[NUM_LEGS], float wheelVel[NUM_LEGS]) 00434 { 00435 int32_t lift[NUM_LEGS]; 00436 int32_t wheel[NUM_LEGS]; 00437 00438 for(int i = 0; i < NUM_LEGS; ++i) { 00439 wheel[i] = (int32_t) (wheelVel[i] * TICKS_PER_METER); 00440 lift[i] = (int32_t) ((liftPos[i] + LIFT_OFFSET) * LIFT_TICKS_PER_METER); 00441 } 00442 00443 return setLegGoal(lift, wheel); 00444 } 00445 00446 /** 00447 Check the completion status of the Set Leg Goal transaction. 00448 00449 @return true if the last leg goal set was completed. 00450 */ 00451 00452 bool LegInterface::getLegGoalCompleted() 00453 { 00454 return(transactionSetGoal[LEG_W]->completed() && 00455 transactionSetGoal[LEG_E]->completed() && 00456 transactionSetGoal[LEG_S]->completed()); 00457 } 00458 00459 00460 /** 00461 Check the completion status of the Set Leg Goal transaction. 00462 00463 @return true if the last leg goal set was completed successfully. 00464 */ 00465 00466 bool LegInterface::getLegGoalSuccess() 00467 { 00468 return(transactionSetGoal[LEG_W]->success() && 00469 transactionSetGoal[LEG_E]->success() && 00470 transactionSetGoal[LEG_S]->success()); 00471 } 00472 00473 void LegInterface::displayStatus() 00474 { 00475 pc->printf("Transaction status:\n\r"); 00476 transactionEstop[LEG_W]->displayStatus(pc, "Estop W:\t"); 00477 transactionEstop[LEG_E]->displayStatus(pc, "Estop E:\t"); 00478 transactionEstop[LEG_S]->displayStatus(pc, "Estop S:\t"); 00479 pc->printf("\n\r"); 00480 transactionQueryState[LEG_W]->displayStatus(pc, "Query State W:\t"); 00481 transactionQueryState[LEG_E]->displayStatus(pc, "Query State E:\t"); 00482 transactionQueryState[LEG_S]->displayStatus(pc, "Query State S:\t"); 00483 pc->printf("\n\r"); 00484 transactionQueryLiftParams[LEG_W]->displayStatus(pc, "Query Lift Params W"); 00485 transactionQueryLiftParams[LEG_E]->displayStatus(pc, "Query Lift Params E"); 00486 transactionQueryLiftParams[LEG_S]->displayStatus(pc, "Query Lift Params S"); 00487 pc->printf("\n\r"); 00488 transactionQueryWheelParams[LEG_W]->displayStatus(pc, "Query Wheel Params W"); 00489 transactionQueryWheelParams[LEG_E]->displayStatus(pc, "Query Wheel Params E"); 00490 transactionQueryWheelParams[LEG_S]->displayStatus(pc, "Query Wheel Params S"); 00491 pc->printf("\n\r"); 00492 transactionSetLiftParams[LEG_W]->displayStatus(pc, "Set Lift Params W"); 00493 transactionSetLiftParams[LEG_E]->displayStatus(pc, "Set Lift Params E"); 00494 transactionSetLiftParams[LEG_S]->displayStatus(pc, "Set Lift Params S"); 00495 pc->printf("\n\r"); 00496 transactionSetWheelParams[LEG_W]->displayStatus(pc, "Set Wheel Params W"); 00497 transactionSetWheelParams[LEG_E]->displayStatus(pc, "Set Wheel Params E"); 00498 transactionSetWheelParams[LEG_S]->displayStatus(pc, "Set Wheel Params S"); 00499 pc->printf("\n\r"); 00500 transactionSetGoal[LEG_W]->displayStatus(pc, "Set Goal W:\t"); 00501 transactionSetGoal[LEG_E]->displayStatus(pc, "Set Goal E:\t"); 00502 transactionSetGoal[LEG_S]->displayStatus(pc, "Set Goal S:\t"); 00503 pc->printf("\n\r"); 00504 00505 } 00506 00507 /** 00508 Reset the transaction status for each of the legs (if necessary). 00509 00510 This affects the internal status of the MODI2C transaction objects. Hence, 00511 this method should only be called if it is clear that the ISR has "forgotten" 00512 about one of the leg transactions. 00513 00514 @TODO 00515 It is unclear why we need this. There is probably a bug in the MODI2C code that 00516 causes this to happen. However, it is interesting that it is only this transaction type 00517 that seems to need this... 00518 00519 This is somewhat redundant with clearSetGoalTransactions(). Should resolve this at some point 00520 */ 00521 00522 void LegInterface::clearLegSetGoalStatus() 00523 { 00524 for(int i = 0; i < NUM_LEGS; ++i) { 00525 // Reset leg only if it has not completed 00526 if(!transactionSetGoal[i]->completed()) { 00527 // This causes the transaction to be seen as being completed 00528 transactionSetGoal[i]->clearStatus(); 00529 } 00530 } 00531 } 00532 00533 void LegInterface::reset() 00534 { 00535 I2CTransaction::reset(); 00536 } 00537 00538 void LegInterface::resetBus() 00539 { 00540 I2CTransaction::resetBus(); 00541 } 00542 00543 void LegInterface::cycleBus() 00544 { 00545 I2CTransaction::cycleBus(); 00546 } 00547 00548 void LegInterface::clearQueryTransactions() 00549 { 00550 transactionQueryState[LEG_W]->clearStatus(); 00551 transactionQueryState[LEG_E]->clearStatus(); 00552 transactionQueryState[LEG_S]->clearStatus(); 00553 } 00554 00555 void LegInterface::clearSetGoalTransactions() 00556 { 00557 transactionSetGoal[LEG_W]->clearStatus(); 00558 transactionSetGoal[LEG_E]->clearStatus(); 00559 transactionSetGoal[LEG_S]->clearStatus(); 00560 } 00561 00562 00563 /** 00564 Initialize the I2C pins and other hardware. If it has already been initialized, then 00565 we will re-initialize. 00566 00567 @param sda Name of the pin that is used for data 00568 @param scl Name of the pin that is used for the clock 00569 */ 00570 00571 void LegInterface::initI2C(PinName sda, PinName scl) 00572 { 00573 I2CTransaction::initI2C(sda, scl); 00574 }
Generated on Sun Jul 24 2022 16:55:01 by
1.7.2