Stumped by a teams auton failing

One of my teams has a simple auton that looks correct to me, but the spinTo commands hang up. Motors do not spin at all. Commenting those lines has the bot drive all the Drivetrain steps no problem. I have confirmed with them the motor ports. We have checked the motors in the devices page on the brain and confirmed the degrees they are using are correct and in the right direcrtion. I have had them try spinToPosition and rotateTo. I have had them setPosition for those motors in PreAuton and Auton and both.

void pre_auton(void) {
  // All activities that occur before the competition starts
  // Example: clearing encoders, setting servo positions, ...

  Drivetrain.setDriveVelocity(80,percent);
  Lift.setPosition(0, degrees);
  Fork.setPosition(0, degrees);
  Claw.setPosition(0, degrees);
  Lift.setVelocity(100, percent);
  Fork.setVelocity(100, percent);
  Claw.setVelocity(100, percent);
  Claw.setStopping(hold);
  Fork.setStopping(hold);
  Lift.setStopping(hold);

  // Initializing Robot Configuration. DO NOT REMOVE!
  vexcodeInit();
}

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

void autonomous(void) {
  // ..........................................................................
  // Insert autonomous user code here.
  // ..........................................................................


  // neutral goal rush
  // set motor variables
  Drivetrain.setDriveVelocity(80,percent);
  Lift.setPosition(0, degrees);
  Fork.setPosition(0, degrees);
  Claw.setPosition(0, degrees);
  Lift.setVelocity(100, percent);
  Fork.setVelocity(100, percent);
  Claw.setVelocity(100, percent);
  Claw.setStopping(hold);
  Fork.setStopping(hold);
  Lift.setStopping(hold);
  // raise lift
  Lift.spinTo(50, degrees, true);
  // drive to goal
  Drivetrain.driveFor(forward, 45, inches);
  Drivetrain.setDriveVelocity(40, percent);
  Drivetrain.driveFor(forward, 2, inches);
  // close claw
  Claw.spinTo(900, degrees, true);
  // drive back to starting position
  Drivetrain.setDriveVelocity(80, percent);
  Drivetrain.driveFor(reverse, 46, inches);

Any thoughts on what I am missing?

The motors were originally initiated with the device manager, so have correct configuration there and have the externs in robot-config.h. They switched to expert mode to set a software limit on the claw and lift that works in driver contol:

     // check the ButtonL1/ButtonL2 status to control Lift
      if (Controller1.ButtonL1.pressing()) {
        Lift.spinTo(1550, degrees, false);
        Controller1RightShoulderControlMotorsStopped = false;
      } else if (Controller1.ButtonL2.pressing()) {
        Lift.spinTo(50, degrees, false);
        Controller1RightShoulderControlMotorsStopped = false;
      } else {
        Lift.stop();
        // set the toggle so that we don't constantly tell the motor to stop
        // when the buttons are released
        Controller1LeftShoulderControlMotorsStopped = true;
      }
      // check the ButtonR1/ButtonR2 status to control Claw
      if (Controller1.ButtonR1.pressing()) {
        Claw.spinTo(0, degrees, false);
        Controller1RightShoulderControlMotorsStopped = false;
      } else if (Controller1.ButtonR2.pressing()) {
        Claw.spinTo(900, degrees, false);
        Controller1RightShoulderControlMotorsStopped = false;
      } else {
        Claw.stop();
        // set the toggle so that we don't constantly tell the motor to stop
        // when the buttons are released
        Controller1RightShoulderControlMotorsStopped = true;
      }

So, yeah, I cannot see the issue.

How far into the program does it get before it stops?

The first action is a spinTo, If that is uncommented, it stops there. If both spinTo actions are commented, it completes the auton

1 Like

I would recommend adding a timeout to the spinTo.

1 Like

That is a good recommendation – I will edit the first post to indicate that the lift and claw motors don’t spin at all. Timeout would make sense if they were spinning though.

2 Likes

I don’t have a lot of experience with spinTo. Does the code work if you write it in a while loop?

while(Lift.position(degrees) < 50)
Lift.spin(forward, 100, percent);

worth a shot I guess.

you removed this from the controller task.

      } else if (!Controller1LeftShoulderControlMotorsStopped) {

so the code will keep sending Lift.stop()
same with the claw.

5 Likes

My general advise for teams using V5 Pro is don’t assign motors to the controller in graphical configuration, it just seems to cause confusion, write the code directly and there’s no second guesing what the auto generated code may be doing. Also, the auto generated code is verbose and not particularly good, it can be written much more cleanly inside usercontrol().

4 Likes

Ah, good catch. So the first if statement in that task

if (RemoteControlCodeEnabled) {

would not preclude the Lift.stop(); in autonomous?

you could manually set it to false at the beginning of auton. It does not change automatically.

RemoteControlCodeEnabled = false;
4 Likes

Yeah, it is clearly better to write you own. So fast though for new teams to get started.