This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
writeDebugStream("FL Motor: %d\n", motor[MecMotor_FL]); | |
writeDebugStream("BL Motor: %d\n", motor[MecMotor_BL]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Recall that Robotc stores the list of motors as the following: | |
typedef enum tMotor { | |
leftMotor = 0, | |
rightMotor = 7, | |
centerMotor = 1, | |
} tMotor; | |
//We can keep track of the number of motors using a constant that is updated by hand | |
#define NUM_MOTORS 3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void driveSetMecMotorPolarDegrees(DesiredMotorVals *desiredMotorVals, int angle, float powerRatio, | |
float rotationRatio) { | |
//Holds max motor powers | |
float maxPowFLBR = cosDegrees(45.0 - (float)angle); | |
float maxPowFRBL = cosDegrees(45.0 + (float)angle); | |
float powFL = (powerRatio * maxPowFLBR) + (rotationRatio * abs(maxPowFLBR)); | |
float powBL = (powerRatio * maxPowFRBL) + (rotationRatio * abs(maxPowFRBL)); | |
float powFR = (powerRatio * maxPowFRBL) - (rotationRatio * abs(maxPowFRBL)); | |
float powBR = (powerRatio * maxPowFLBR) - (rotationRatio * abs(maxPowFLBR)); | |
//Cap motor values |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//RobotC variable that keeps track of # of total motors | |
int kNumbOfTotalMotors = 5; | |
int maxMotorPowers[kNumbOfTotalMotors]; | |
maxMotorPowers[(int) leftMotor] = 100; //(int) leftMotor translates to 1, a valid array index | |
maxMotorPowers[(int) rightMotor] = 50; | |
... | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//An example of how RobotC stores motors | |
typedef enum tMotor { | |
leftMotor = 0, | |
rightMotor = 7, | |
centerMotor = 1, | |
} tMotor; | |
//RobotC variable that keeps track of # of maximum motors | |
int kNumbOfTotalMotors = 10; |
NewerOlder