Hello Vex World! We’ve been coding a simple catapult program and have encountered a problem. It has an Intake built into it and the motors running in the catapult’s direction has dominance. However even though I tell the two motors to run at 100 percent, they won’t pull through to trigger the slip gear, even if I tell it to run way more degrees than it needs to. Then if I run a simple joystick to move the catapult at full speed, it works just fine. I’ve attached the program below and hope someone can tell me why the motors won’t run at full speed for how long I need them to.
#include "robot-config.h"
int Catapult = 0;
bool Intake = 0;
////////////////
// Switch //
////////////////
void SwitchFunction()
{
Brain.Screen.clearScreen();
Brain.Screen.setCursor(1,1);
Brain.Screen.print(Catapult);
Brain.Screen.print(Intake);
Brain.Screen.render();
if(Catapult == 0)
{
Controller1.rumble(".");
Controller1.Screen.clearLine();
Controller1.Screen.print("Tap To Load Catapult");
if(Intake == 0)
{
LSwitch.stop();
RSwitch.stop();
}
else if(Intake == 1)
{
LSwitch.stop();
RSwitch.stop();
}
}
else if(Catapult == 1)
{
Controller1.rumble(".");
Controller1.Screen.clearLine();
Controller1.Screen.print("Tap To Use Intake");
LSwitch.setReversed(false);
RSwitch.setReversed(true);
if(Intake == 0)
{
LSwitch.rotateFor(500,vex::rotationUnits::deg,100,vex::velocityUnits::pct);
RSwitch.rotateFor(500,vex::rotationUnits::deg,100,vex::velocityUnits::pct);
}
else if(Intake == 1)
{
LSwitch.rotateFor(500,vex::rotationUnits::deg,100,vex::velocityUnits::pct);
RSwitch.rotateFor(500,vex::rotationUnits::deg,100,vex::velocityUnits::pct);
}
}
else if(Catapult == 2)
{
Controller1.rumble(".");
Controller1.Screen.clearLine();
Controller1.Screen.print("TAP TO FIRE!");
LSwitch.setReversed(true);
RSwitch.setReversed(false);
if(Intake == 0)
{
LSwitch.stop();
RSwitch.stop();
}
else if(Intake == 1)
{
LSwitch.spin(vex::directionType::fwd,200,vex::velocityUnits::rpm);
RSwitch.spin(vex::directionType::fwd,200,vex::velocityUnits::rpm);
}
}
else if(Catapult == 3)
{
Controller1.rumble(".");
Controller1.Screen.clearLine();
Controller1.Screen.print("Tap To Load Catapult");
LSwitch.setReversed(false);
RSwitch.setReversed(true);
if(Intake == 0)
{
LSwitch.rotateFor(90,vex::rotationUnits::deg,100,vex::velocityUnits::pct);
RSwitch.rotateFor(90,vex::rotationUnits::deg,100,vex::velocityUnits::pct);
}
else if(Intake == 1)
{
LSwitch.rotateFor(90,vex::rotationUnits::deg,100,vex::velocityUnits::pct);
RSwitch.rotateFor(90,vex::rotationUnits::deg,100,vex::velocityUnits::pct);
}
}
}
///////////////////
// DRIVE //
///////////////////
void DriveFunction()
{
while(true)
{
//left side drive
LMotor1.spin(vex::directionType::fwd, Controller1.Axis3.value(), vex::velocityUnits::pct);
LMotor2.spin(vex::directionType::fwd, Controller1.Axis3.value(), vex::velocityUnits::pct);
//right side drive
RMotor1.spin(vex::directionType::fwd, Controller1.Axis2.value(), vex::velocityUnits::pct);
RMotor2.spin(vex::directionType::fwd, Controller1.Axis2.value(), vex::velocityUnits::pct);
}
}
////////////////////
// Intake //
////////////////////
void ChangeIntake()
{
::Intake = !Intake;
SwitchFunction();
}
////////////////////
// Catapult //
////////////////////
void ChangeCatapult()
{
if(Catapult == 0)
{
Catapult = 1;
}
else if(Catapult == 1)
{
Catapult = 2;
}
else if(Catapult == 2)
{
Catapult = 3;
}
else if(Catapult == 3)
{
Catapult = 1;
}
SwitchFunction();
}
int main()
{
Catapult = 0;
Intake = 0;
LMotor1.setStopping(vex::brakeType::brake);
LMotor2.setStopping(vex::brakeType::brake);
RMotor1.setStopping(vex::brakeType::brake);
RMotor2.setStopping(vex::brakeType::brake);
RMotor1.setReversed(true);
RMotor2.setReversed(true);
LSwitch.setStopping(vex::brakeType::coast);
RSwitch.setStopping(vex::brakeType::coast);
Controller1.ButtonL1.pressed(ChangeIntake);
Controller1.ButtonR1.pressed(ChangeCatapult);
vex::thread drivethread (DriveFunction);
drivethread.detach();
}
Gucci Bot.vex (9 KB)