Emergency coding help?

We have a tournament tomorrow, and we uploaded our code to the brain, and for whatever reason, none of the motors are working. The pneumatics are working, but none of the motors are moving. I am open to any help or suggestions. Here is the code:

// ---- START VEXCODE CONFIGURED DEVICES ----
// Robot Configuration:
// [Name] [Type] [Port(s)]
// Controller1 controller
// LeftDrive motor_group 13, 14
// RightDrive motor_group 11, 12
// LeftArm digital_out A
// RightArm digital_out B
// flywheel motor 15
// ---- END VEXCODE CONFIGURED DEVICES ----
#include “vex.h”
using namespace vex;
// A global instance of competition
competition Competition;
void pre_auton(void) {
// Initializing Robot Configuration. DO NOT REMOVE!
vexcodeInit();
// All activities that occur before the competition starts
// Example: clearing encoders, setting servo positions, …
}

void autonomous(void) {
}

void usercontrol(void) {

while (1) {

//LeftDrive.setVelocity(150,rpm);
//RightDrive.setVelocity(150,rpm);

LeftDrive.setVelocity( Controller1.Axis3.position(),pct);
RightDrive.setVelocity( Controller1.Axis2.position(), pct);

if(Controller1.Axis3.position() <10){
LeftDrive.setVelocity(0, pct);
}
if(Controller1.Axis2.position() < 10){
RightDrive.setVelocity(0, pct);
}
if(Controller1.ButtonR1.pressing()){
LeftArm.set(true);
RightArm.set(true);
}else{
LeftArm.set(false);
RightArm.set(false);
}
if(Controller1.ButtonL1.pressing()){
flywheel.setVelocity(600, rpm);
flywheel.setMaxTorque(100, pct);
}
else{
flywheel.setVelocity(0,pct);
}
if(Controller1.ButtonX.pressing()){
LeftDrive.setMaxTorque(100,pct);
RightDrive.setMaxTorque(100,pct);
}
else{
LeftDrive.setMaxTorque(50,pct);
RightDrive.setMaxTorque(50, pct);
}

wait(20, msec);
}
}

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 think the issue is with using set velocity without telling the motors to spin. Set velocity sets what speed the motor should spin at when spin is called so if spin isn’t called it won’t work. Either call spin for each motor at the end or do the better thing of using spin in all places. This can be done by using spin(fwd, velocity, velocityUnits).

4 Likes

Your issue appears to be that you set the velocity for the motors but you never called the spin function on them to actually make them move with the velocity you set.

2 Likes

Not sure why it isn’t working but try switching everything to percentages

// ---- START VEXCODE CONFIGURED DEVICES ----
// Robot Configuration:
// [Name] [Type] [Port(s)]
// Controller1 controller
// LeftDrive motor_group 13, 14
// RightDrive motor_group 11, 12
// LeftArm digital_out A
// RightArm digital_out B
// flywheel motor 15
// ---- END VEXCODE CONFIGURED DEVICES ----
#include “vex.h”
using namespace vex;
// A global instance of competition
competition Competition;
void pre_auton(void) {
// Initializing Robot Configuration. DO NOT REMOVE!
vexcodeInit();
// All activities that occur before the competition starts
// Example: clearing encoders, setting servo positions, …
}

void autonomous(void) {
}

void usercontrol(void) {
  while(1){

    // Controls left drive
    if(Controller1.Axis3.position() > 10)
      LeftDrive.spin(forward, Controller1.Axis3.position(),pct);
    else
      LeftDrive.spin(forward, 0, pct);

    // Controls right drive
    if(Controller1.Axis2.position() > 10)
      RightDrive.spin(forward, Controller1.Axis2.position(),pct);
    else
      RightDrive.spin(forward, 0, pct);

    // Simplified arm controls
    LeftArm.set(Controller1.ButtonR1.pressing());
    RightArm.set(Controller1.ButtonR1.pressing());

    // Controls flywheel
    if(Controller1.ButtonL1.pressing())
      flywheel.spin(forward, 100, pct);
    else
      flywheel.spin(forward, 0, pct);

    // Keeping this as is cause IDK what it's for
    if(Controller1.ButtonX.pressing()){
    LeftDrive.setMaxTorque(100,pct);
    RightDrive.setMaxTorque(100,pct);
    }
    else{
    LeftDrive.setMaxTorque(50,pct);
    RightDrive.setMaxTorque(50, pct);
    }

    wait(20, msec);
  }
}

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);
}
}
1 Like