Autonomous with button

We are trying to figure out a way to start an “autonomous” period using a button.

Theoretically we hope to push the button and have our robot go through a series of events. It would move the drive motors along with a few other motors.

Thanks!

Something like this maybe:
http://www.team358.org/files/programming/ControlSystem2015-2019/labview/index.php#ButtonStartofTimedAction

Okay! The motors are now working but we are struggling to get our drive motors working. They go for less than half a second and then stop. This is confusing because our arm motor goes for its designated time.

Drive motors need a little extra step because of the motor safety.
Here’s an example for Drive motors.

Okay thanks! Would this work best in teleop, autonomous, or periodic tasks?

Periodic Tasks would be best for a timed sequence of actions.

We put this code in periodic tasks but for whatever reason it still is not driving. We aren’t quite sure what is going wrong. Here is our code for periodic tasks:

Maybe your conditional statement is evaluating to false? (I don’t know what “greater than” does when applied to boolean values.)

Also, I suspect you should put the safety disable inside the first frame of the sequence structure, otherwise your Safety Config will be set to Disable every 20ms.

We just moved the safety disable into the first frame and it didn’t change the outcome.

Yes, moving the safety disable is more of a best practice, so that your robot isn’t always disabling its safety configuration - it shouldn’t be expected to solve the core logic problem.

Try removing elements to see what’s causing the failure. For example, if you replace the entire sequence frame with just a call to ArcadeDrive (0.5, 0.5) with no time delay, do the motors engage at all?

They engage for a split second. However after that, it will not move until we press the button again

Well, that’s sort of a good sign - the way your conditional is set up, it only evaluates to TRUE (and thus runs the code inside) on the first loop where the button is TRUE. After that, both the current and feedforward node are TRUE, and when evaluating TRUE > TRUE, the result will be FALSE.

I would have thought the sequence frame would prevent the loop from finishing, but maybe there’s something there I don’t understand. @Mark_McLeod, any insight here?

I don’t see anything unusual.
John mentioned the misplacement of the Disable.
The “Left and Right Motors” aren’t being set anywhere else I assume.

The behavior still sounds like a Motor Safety issue.
Just for testing purposes I’d try switching all use of the Motor Safety to Disable, including in Begin.vi

Wouldn’t placing this code in periodic tasks cause a race condition? In teleop, they aren’t using their joystick so I’d wager they’re sending the value 0 to the motors there. In periodic tasks, they’re sending the value once to the motors (safety disabled, if we had used a loop here we’d instead see a motor stutter)

If the actions are driving motors that are simultaneously being controlled in teleop, we should expect a quick spurt followed by nothing. Though, I’d also say I don’t like the idea of moving a 2 second loop into telop (this stops your robot from responding to any input for 2 seconds)

1 Like

Good catch.

There are a couple of solutions that might do the job.

  • Just handle the set drive motors in Periodic Tasks and not at all in Teleop. Integrate it into that loop to be called while the sequence isn’t active. i.e., Use the joystick to set the motors as normal in the false case, then there is no conflict while the sequence is active.

  • Make a Global variable lockout. Set it at the beginning of the sequence, and unset at the end. In Teleop feed the variable into a case statement that sets the motors normally while the sequence is inactive or doesn’t set them at all if the sequence is active.

  • Do the same in Teleop except used an elapsed time check if the sequence remains that simple.

Thanks everyone for your help! We got it working by moving all the drive motor functions to period tasks and removing them from teleop. Then we set the motors to normal in the false case and it worked!

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.