Our team is attempting to code our mecanum wheels but we are finding that our code does not seem to be function properly.
The left joystick when turned up makes the robot turn left.
The left joystick when turned down makes the robot turn right.
The right joystick when turned right moves the robot backwards.
The right joystick when turned left moves the robot forward.
The side to side commands should be the right joystick, but the robot isn’t reading this code.
Here is our current code:
#include "vex.h"
using namespace vex;
void vexcodeInit( void ) {
task rc_auto_loop_task_Controller1(rc_auto_loop_callback_Controller1);
}
int main() {
// Initializing Robot Configuration. DO NOT REMOVE!
vexcodeInit();
vex::motor LeftFrontMotor = vex::motor( vex::PORT1, true);
vex::motor LeftBackMotor = vex::motor( vex::PORT2, true);
vex::motor RightFrontMotor = vex::motor( vex::PORT3);
vex::motor RightBackMotor = vex::motor( vex::PORT4);
vex::motor LeftIntakeMotor = vex::motor( vex::PORT5, true);
vex::motor RightIntakeMotor = vex::motor( vex::PORT6);
vex::controller Controller1 = vex::controller();
Controller1.Screen.print("ZOOMER ATTACK!!");
//Forward Movement
RightFrontMotor.spin(vex::directionType::fwd, Controller1.Axis3.position(), vex::velocityUnits::pct );
LeftFrontMotor.spin(vex::directionType::fwd, Controller1.Axis3.position(), vex::velocityUnits::pct );
RightBackMotor.spin(vex::directionType::fwd, Controller1.Axis3.position(), vex::velocityUnits::pct );
LeftBackMotor.spin(vex::directionType::fwd, Controller1.Axis3.position(), vex::velocityUnits::pct );
//Backward Movement
RightFrontMotor.spin(vex::directionType::rev, Controller1.Axis3.position(), vex::velocityUnits::pct );
LeftFrontMotor.spin(vex::directionType::rev, Controller1.Axis3.position(), vex::velocityUnits::pct );
RightBackMotor.spin(vex::directionType::rev, Controller1.Axis3.position(), vex::velocityUnits::pct );
LeftBackMotor.spin(vex::directionType::rev, Controller1.Axis3.position(), vex::velocityUnits::pct );
//Left Movement
LeftFrontMotor.spin(vex::directionType::rev, Controller1.Axis1.position(), vex::velocityUnits::pct );
LeftBackMotor.spin(vex::directionType::rev, Controller1.Axis1.position(), vex::velocityUnits::pct );
RightFrontMotor.spin(vex::directionType::rev, Controller1.Axis1.position(), vex::velocityUnits::pct );
RightBackMotor.spin(vex::directionType::rev, Controller1.Axis1.position(), vex::velocityUnits::pct );
//Right Movement
LeftFrontMotor.spin(vex::directionType::fwd, Controller1.Axis1.position(), vex::velocityUnits::pct );
LeftBackMotor.spin(vex::directionType::rev, Controller1.Axis1.position(), vex::velocityUnits::pct );
RightFrontMotor.spin(vex::directionType::rev, Controller1.Axis1.position(), vex::velocityUnits::pct );
RightBackMotor.spin(vex::directionType::fwd, Controller1.Axis1.position(), vex::velocityUnits::pct );
//Turn Left
if(Controller1.ButtonL1.pressing()) {
LeftFrontMotor.spin(vex::directionType::rev, 50, vex::velocityUnits::pct);
LeftBackMotor.spin(vex::directionType::rev, 50, vex::velocityUnits::pct);
RightFrontMotor.spin(vex::directionType::fwd, 50, vex::velocityUnits::pct);
RightBackMotor.spin(vex::directionType::fwd, 50, vex::velocityUnits::pct);
} else {
Drivetrain.stop();
}
//}
//Turn Right
if(Controller1.ButtonR1.pressing()) {
LeftFrontMotor.spin(vex::directionType::fwd, 50, vex::velocityUnits::pct);
LeftBackMotor.spin(vex::directionType::fwd, 50, vex::velocityUnits::pct);
RightFrontMotor.spin(vex::directionType::rev, 50, vex::velocityUnits::pct);
RightBackMotor.spin(vex::directionType::rev, 50, vex::velocityUnits::pct);
} else {
Drivetrain.stop();
}
//
}