Skip to content

Commit

Permalink
feat: Implemented drivetrain control, translated
Browse files Browse the repository at this point in the history
- Code to control the intakes, catapult, drivetrain, and the elevation
  have been translated in this commit.
- The drivetrain code is not working properly at this point.
  • Loading branch information
absozero committed Sep 11, 2023
1 parent 3b582f2 commit d68e091
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 13 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# PROS Version

==
This is the PROS version of the robot, rewritten from the VexCode version. This was done so that we could support a greater feature set and support external libraries.

The PROS version will be first rewritten from the VEXCode version and then it will have features added onto it. It is not expected to become production ready as soon as it is complete.

To see the vexcode version, go [here](https://github.com/calhighrobotics/Over-Under-2023-24-teamB)
To see the vexcode version, go [here](https://github.com/calhighrobotics/Over-Under-2023-24-teamB)


Empty file added TASKS.md
Empty file.
48 changes: 37 additions & 11 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,44 +75,70 @@ void autonomous() {}
*/
void opcontrol() {
pros::Controller controller (pros::E_CONTROLLER_MASTER);
pros::Motor RightFront (1, pros::E_MOTOR_GEARSET_18, false, pros::E_MOTOR_ENCODER_DEGREES);
pros::Motor LeftFront (2, pros::E_MOTOR_GEARSET_18, false, pros::E_MOTOR_ENCODER_DEGREES);
pros::Motor RightFront (2, pros::E_MOTOR_GEARSET_18, false, pros::E_MOTOR_ENCODER_DEGREES);
pros::Motor LeftFront (1, pros::E_MOTOR_GEARSET_18, false, pros::E_MOTOR_ENCODER_DEGREES);
pros::Motor LeftBack (3, pros::E_MOTOR_GEARSET_18, false, pros::E_MOTOR_ENCODER_DEGREES);
pros::Motor RightBack (4, pros::E_MOTOR_GEARSET_18, false, pros::E_MOTOR_ENCODER_DEGREES);
pros::Motor LeftMid (10, pros::E_MOTOR_GEARSET_18, false, pros::E_MOTOR_ENCODER_DEGREES);
pros::Motor Elevation (20, pros::E_MOTOR_GEARSET_18, false, pros::E_MOTOR_ENCODER_DEGREES);
pros::Motor RightMid (6, pros::E_MOTOR_GEARSET_18, false, pros::E_MOTOR_ENCODER_DEGREES);
pros::Motor RightMid (9, pros::E_MOTOR_GEARSET_18, false, pros::E_MOTOR_ENCODER_DEGREES);
pros::Motor Catapult (7, pros::E_MOTOR_GEARSET_18, false, pros::E_MOTOR_ENCODER_DEGREES);
pros::Motor IntakeLeft (8, pros::E_MOTOR_GEARSET_18, false, pros::E_MOTOR_ENCODER_DEGREES);
pros::Motor IntakeRight (9, pros::E_MOTOR_GEARSET_18, false, pros::E_MOTOR_ENCODER_DEGREES);


while (true) {
// Read joystick values
int power = controller.get_analog(ANALOG_LEFT_Y);
int turn = controller.get_analog(ANALOG_RIGHT_X);
int power = controller.get_analog(pros::E_CONTROLLER_ANALOG_LEFT_Y);
int turn = controller.get_analog(pros::E_CONTROLLER_ANALOG_LEFT_X);

int left = power + turn;
int right = power - turn;

while (true)
{
controller.print(0, 0, power);
controller.print(1, 0, turn);
}


// EXPERIMENTAL DRIVETRAIN CODE - Not Working currently.
RightFront.move(right);
RightMid.move(right);
RightBack.move(right);

LeftFront.move(left);
LeftMid.move(left);
LeftBack.move(left);

// Controls Catapult movement - uses A button to cock the catapult back, the Y button to release tension.
if (controller.get_digital(DIGITAL_A)) {
Catapult.move(127);
}
else if (controller.get_digital(pros::E_CONTROLLER_DIGITAL_Y)) {
Catapult.move(-127);
}
else {
Catapult.brake();
}

// Catapult controller, uses the X button holded down to push the elevation up.
if (controller.get_digital(DIGITAL_X)) {
Elevation.move(127);
}
else {
Elevation.brake();
}

// Intake controller, moves the left and right intakes and stops them if nothing is pressed.
if (controller.get_digital(pros::E_CONTROLLER_DIGITAL_B)) {
IntakeRight.move(127);
IntakeLeft.move(127);
}
else {
IntakeRight.brake();
IntakeLeft.brake();
}




pros::delay(2); // Small delay to reduce CPU usage
}


}

0 comments on commit d68e091

Please sign in to comment.