I am using X Drive currently, I have it so the controller axis 3 is going front and back and that works, and controller axis 1 spins the bot and that works, but axis 4 also spins the bot for some reason instead of driving sideways. Here is my code
#include "vex.h"
using namespace vex;
using signature = vision::signature;
using code = vision::code;
// A global instance of brain used for printing to the V5 Brain screen
brain Brain;
// VEXcode device constructors
controller Controller1 = controller(primary);
motor leftFront = motor(PORT1, ratio18_1, false);
motor leftBack = motor(PORT2, ratio18_1, false);
motor rightBack = motor(PORT9, ratio18_1, true);
motor rightFront = motor(PORT10, ratio18_1, true);
// VEXcode generated functions
// define variable for remote controller enable/disable
bool RemoteControlCodeEnabled = true;
// define variables used for controlling motors based on controller inputs
bool DrivetrainNeedsToBeStopped_Controller1 = true;
// define a task that will handle monitoring inputs from Controller1
int rc_auto_loop_function_Controller1() {
// process the controller input every 20 milliseconds
// update the motors based on the input values
while(true) {
if(RemoteControlCodeEnabled) {
// calculate the drivetrain motor velocities from the controller joystick axies
// left = Axis3 + Axis4
// right = Axis3 - Axis4
int leftFrontSpeed = Controller1.Axis3.position() + Controller1.Axis4.position() + Controller1.Axis1.position();
int leftBackSpeed = Controller1.Axis3.position() + Controller1.Axis4.position() + Controller1.Axis1.position();
int rightFrontSpeed = Controller1.Axis3.position() - Controller1.Axis4.position() - Controller1.Axis1.position();
int rightBackSpeed = Controller1.Axis3.position() - Controller1.Axis4.position() - Controller1.Axis1.position();
// check if the values are inside of the deadband range
if (abs(leftFrontSpeed) < 5 && abs(rightFrontSpeed) < 5 && abs(leftBackSpeed) < 5 && abs(rightBackSpeed) < 5) {
// check if the motors have already been stopped
if (DrivetrainNeedsToBeStopped_Controller1) {
// stop the drive motors
leftFront.stop();
leftBack.stop();
rightFront.stop();
rightBack.stop();
// tell the code that the motors have been stopped
DrivetrainNeedsToBeStopped_Controller1 = false;
}
} else {
// reset the toggle so that the deadband code knows to stop the motors next time the input is in the deadband range
DrivetrainNeedsToBeStopped_Controller1 = true;
}
// only tell the right drive motor to spin if the values are not in the deadband range
if (DrivetrainNeedsToBeStopped_Controller1) {
leftFront.setVelocity(leftFrontSpeed, percent);
leftFront.spin(forward);
rightFront.setVelocity(rightFrontSpeed, percent);
rightFront.spin(forward);
leftBack.setVelocity(leftBackSpeed, percent);
leftBack.spin(forward);
rightBack.setVelocity(rightBackSpeed, percent);
rightBack.spin(forward);
}
}
// wait before repeating the process
wait(20, msec);
}
return 0;
}
/**
* Used to initialize code/tasks/devices added using tools in VEXcode Pro.
*
* This should be called at the start of your int main function.
*/
void vexcodeInit( void ) {
task rc_auto_loop_task_Controller1(rc_auto_loop_function_Controller1);
}