Example use of I2CTransaction class. In this example, the master mbed is talking to 3 legs of the SIPPC3B robot.

Committer:
symbiotic
Date:
Thu May 22 21:17:58 2014 +0000
Revision:
1:d3abc0577ebc
Parent:
0:346370254254
Child:
2:17c7a02f8401
added continuous control handle

Who changed what in which revision?

UserRevisionLine numberNew contents of line
symbiotic 0:346370254254 1 #ifndef LEGINTERFACE_H
symbiotic 0:346370254254 2 #define LEGINTERFACE_H
symbiotic 0:346370254254 3 #include "I2CTransaction.h"
symbiotic 0:346370254254 4 #include "leg_packets.h"
symbiotic 0:346370254254 5
symbiotic 0:346370254254 6 class LegInterface
symbiotic 0:346370254254 7 {
symbiotic 0:346370254254 8 public:
symbiotic 0:346370254254 9 // Indices for the different legs
symbiotic 0:346370254254 10 enum Leg {LEG_W=0, LEG_E, LEG_S, NUM_LEGS};
symbiotic 0:346370254254 11
symbiotic 0:346370254254 12 // An array of I2C addresses indexable by enum Leg
symbiotic 0:346370254254 13 static const int LegAddress[];
symbiotic 0:346370254254 14
symbiotic 0:346370254254 15
symbiotic 0:346370254254 16 LegInterface(Serial *pc = NULL);
symbiotic 0:346370254254 17
symbiotic 0:346370254254 18 bool sendEstop(bool estop);
symbiotic 0:346370254254 19 bool queryStateInitiate();
symbiotic 0:346370254254 20 bool queryStateCompleted(int timeout = 1000);
symbiotic 0:346370254254 21 bool queryStateCopy(LegState_t legState[NUM_LEGS]);
symbiotic 0:346370254254 22 void displayLegState(LegState_t *legState);
symbiotic 0:346370254254 23 bool queryLegParams(Leg leg, LegControlParams_t *liftParams, LegControlParams_t *wheelParams);
symbiotic 0:346370254254 24 void displayParams(LegControlParams_t *params);
symbiotic 0:346370254254 25 bool setLegParams(Leg leg, LegControlParams_t *liftParams, LegControlParams_t *wheelParams);
symbiotic 0:346370254254 26 bool setLegGoal(int32_t liftPos[NUM_LEGS], int32_t wheelVel[NUM_LEGS]);
symbiotic 1:d3abc0577ebc 27 bool setLegGoal(float liftPos[NUM_LEGS], float wheelVel[NUM_LEGS]);
symbiotic 0:346370254254 28 void displayStatus();
symbiotic 0:346370254254 29
symbiotic 0:346370254254 30 private:
symbiotic 0:346370254254 31 I2CTransaction *transactionEstop[NUM_LEGS];
symbiotic 0:346370254254 32 LegPacket_t legPacketEstop;
symbiotic 0:346370254254 33
symbiotic 0:346370254254 34 I2CTransaction *transactionQueryState[NUM_LEGS];
symbiotic 0:346370254254 35 LegPacket_t legPacketQuery;
symbiotic 0:346370254254 36 LegState_t legState[NUM_LEGS];
symbiotic 0:346370254254 37
symbiotic 0:346370254254 38 I2CTransaction *transactionQueryLiftParams[NUM_LEGS];
symbiotic 0:346370254254 39 I2CTransaction *transactionQueryWheelParams[NUM_LEGS];
symbiotic 0:346370254254 40 LegPacket_t legPacketQueryLiftParams;
symbiotic 0:346370254254 41 LegPacket_t legPacketQueryWheelParams;
symbiotic 0:346370254254 42 LegControlParams_t legLiftParams;
symbiotic 0:346370254254 43 LegControlParams_t legWheelParams;
symbiotic 0:346370254254 44
symbiotic 0:346370254254 45 I2CTransaction *transactionSetLiftParams[NUM_LEGS];
symbiotic 0:346370254254 46 I2CTransaction *transactionSetWheelParams[NUM_LEGS];
symbiotic 0:346370254254 47 LegPacket_t legPacketSetLiftParams;
symbiotic 0:346370254254 48 LegPacket_t legPacketSetWheelParams;
symbiotic 0:346370254254 49
symbiotic 0:346370254254 50 I2CTransaction *transactionSetGoal[NUM_LEGS];
symbiotic 0:346370254254 51 LegPacket_t legPacketSetGoal[NUM_LEGS];
symbiotic 0:346370254254 52 Serial *pc;
symbiotic 0:346370254254 53
symbiotic 0:346370254254 54 };
symbiotic 0:346370254254 55
symbiotic 0:346370254254 56 #endif