Auton With 4 motor base?

So I have a comp tomorrow and I just want to make the robot lift arms, move back then move forward. I have looked at so example programs but they have a drivetrain. How do I setup and code this? Thank you

Just to clarify, you want the motors to move together but not in a drivetrain, or you want them to move together in a drivetrain?

The two left to move together and the 2 right to move together. I have not setup a drive train and don’t want to

You could use a motor group for the left and right wheel motors

What? I just need to know how to setup the velocity units or rotations.

Ohhhhhh gotcha

LW1.startrotateFor(500, rotationunist::deg);

That’s off the top of my head, but it should work.

Do I have o setup up anything before that or just put that in the auton and boom.

On that piece of code you would need to set up the velocity at the beginning of the autonomous code

void autonomous(void) {

}

/---------------------------------------------------------------------------/
/* /
/
User Control Task /
/
/
/
This task is used to control your robot during the user control phase of /
/
a VEX Competition. /
/
/
/
You must modify the code to add your own robot specific commands here. /
/
---------------------------------------------------------------------------*/

void usercontrol(void) {

int LISpeedPCT=100;
int RISpeedPCT=100;
int ArmSpeedPCT=100;
int RightaSpeedPCT=100;

while (true) {

 int RSpeed = Controller1.Axis2.position();

int LSpeed = Controller1.Axis3.position(); //you don’t need each individual motor to be a variable if you just reference the same variable for both wheels on one side of a drive train.
RF.spin(directionType::fwd, RSpeed, velocityUnits::pct);
RR.spin(directionType::fwd, RSpeed, velocityUnits::pct);
LF.spin(directionType::fwd, LSpeed, velocityUnits::pct);
LR.spin(directionType::fwd, LSpeed, velocityUnits::pct);

if(Controller1.ButtonR2.pressing()) {
  RI.spin(directionType::fwd, RISpeedPCT, velocityUnits::pct);
  LI.spin(directionType::fwd, LISpeedPCT, velocityUnits::pct);

}

else if(Controller1.ButtonR1.pressing()) {
  RI.spin(directionType::rev, RISpeedPCT, velocityUnits::pct);
  LI.spin(directionType::rev, LISpeedPCT, velocityUnits::pct);
}

else{
  LI.stop(brakeType::hold);
  RI.stop(brakeType::hold);
}

if(Controller1.ButtonL2.pressing()) {
  Arm.spin(directionType::fwd, ArmSpeedPCT, velocityUnits::pct);
  Righta.spin(directionType::fwd, RightaSpeedPCT, velocityUnits::pct);
}

else if(Controller1.ButtonL1.pressing()) {
  Arm.spin(directionType::rev, ArmSpeedPCT, velocityUnits::pct);
  Righta.spin(directionType::rev, RightaSpeedPCT, velocityUnits::pct);
}

else{
  Arm.stop(brakeType::hold);
  Righta.stop(brakeType::hold);
}

wait(20, msec); // Sleep the task for a short amount of time to
                // prevent wasted resources.

}
}

//
// Main will set up the competition functions and callbacks.
//
int main() {
// Set up callbacks for autonomous and driver control periods.
Competition.autonomous(autonomous);
Competition.drivercontrol(usercontrol);

// Run the pre-autonomous function.
pre_auton();

// Prevent main from exiting with an infinite loop.
while (true) {
wait(100, msec);
}
}
I have the PCT and stuff there I think

That’s in the user control, you would need to define it in the autonomous section.

1 Like

This is what I have. I want to make the arms go up a little, then drop cube.
void autonomous(void) {

Arm.rotateFor(1000,rotationUnits::deg,20,velocityUnits::pct,true);

Righta.rotateFor(1000,rotationUnits::deg,20,velocityUnits::pct,true);

//LF.rotateFor(-1000,rotationUnits::deg,55,velocityUnits::pct,true);

//RR.rotateFor(-1000,rotationUnits::deg,55,velocityUnits::pct,true);

//LR.rotateFor(-1000,rotationUnits::deg,55,velocityUnits::pct,true);

//LF.rotateFor(-1000,rotationUnits::deg,55,velocityUnits::pct,true);

//RR.rotateFor(-1000,rotationUnits::deg,55,velocityUnits::pct,true);

//LR.rotateFor(-1000,rotationUnits::deg,55,velocityUnits::pct,true);

//RF.rotateFor(-1000,rotationUnits::deg,55,velocityUnits::pct,true);

//LF.rotateFor(-1000,rotationUnits::deg,55,velocityUnits::pct,true);

//RR.rotateFor(-1000,rotationUnits::deg,55,velocityUnits::pct,true);

//LR.rotateFor(-1000,rotationUnits::deg,55,velocityUnits::pct,true);

vex::task::sleep(1000);

//RF.stop(hold);

//LR.stop(hold);

//RR.stop(hold);

//LF.stop(hold);

Righta.stop(hold);

Arm.stop(hold);

vex::task::sleep(0500);

//RF.rotateFor(1000,rotationUnits::deg,55,velocityUnits::pct,true);

//LF.rotateFor(1000,rotationUnits::deg,55,velocityUnits::pct,true);

//RR.rotateFor(1000,rotationUnits::deg,55,velocityUnits::pct,true);

//LR.rotateFor(1000,rotationUnits::deg,55,velocityUnits::pct,true);

LI.rotateFor(-1000,rotationUnits::deg,100,velocityUnits::pct,true);

RI.rotateFor(-1000,rotationUnits::deg,100,velocityUnits::pct,true);

vex::task::sleep(1000);

//RF.stop(hold);

//LR.stop(hold);

//RR.stop(hold);

//LF.stop(hold);

RI.stop(hold);

LI.stop(hold);

}

Sorry for all the comments. So will this make it go up at a speed of 20 for 1 second, stop, then drop the cube

@ButterNubs, first of all, you have to wrap your code into [code]...[/code] tags. If code is easily readable you increase the chance that somebody is going to understand it and help you.

The last argument for rotateTo() function is waitForCompletion boolean. You pass true which means that rotateTo() function will not return control back to the autonomous() function until arm reaches position +1000.

Essentially you are asking left arm motor to lift it 1000 units alone, then you will ask the second motor Righta to do similar task on its own. My guess is that left arm motor will start lifting the arm, then overheat, and that will be the end of your autonomous, because it will never reach +1000.

vex::motor::rotateTo() reference
vex::motor::setStopping() reference

Here is what I would do:

void autonomous(void)
{
    // set brake mode for arm motors to hold
    Arm.setStopping(hold);
    Righta.setStopping(hold);

    // set brake mode for drivetrain motors to brake
    RF.setStopping(brake);
    RR.setStopping(brake);
    LF.setStopping(brake);
    LR.setStopping(brake);

    // command arm motors to start moving up
    Arm.rotateFor(   1000,rotationUnits::deg,false);
    Righta.rotateFor(1000,rotationUnits::deg,false);

    // then without wait command drive motors to move back
    RF.rotateFor(-1000,rotationUnits::deg,55,velocityUnits::pct,false);
    RR.rotateFor(-1000,rotationUnits::deg,55,velocityUnits::pct,false);
    LF.rotateFor(-1000,rotationUnits::deg,55,velocityUnits::pct,false);
    LR.rotateFor(-1000,rotationUnits::deg,55,velocityUnits::pct,false);

    // wait enough time for all motors to finish
    vex::task::sleep(5000);

    // command drive motors to move forward
    RF.rotateFor(1000,rotationUnits::deg,55,velocityUnits::pct,false);
    RR.rotateFor(1000,rotationUnits::deg,55,velocityUnits::pct,false);
    LF.rotateFor(1000,rotationUnits::deg,55,velocityUnits::pct,false);
    LR.rotateFor(1000,rotationUnits::deg,55,velocityUnits::pct,false);

    // wait enough time for all motors to finish
    vex::task::sleep(5000);

    // exiting autonomous when everything is done
 }

After tomorrow’s competition, the next learning step might be to study motor_groups: VEXcode, motor groups and drivetrain example

1 Like