I’m currently trying to use the button pressed command to make my elevator move to a certain height on its own. I made some code, it did absolutely nothing, and I’m not sure why. If anyone would be able to take a look at what I’ve done and let me know if they see anything wrong with it that would be very much appreciated. Here’s what I’ve tried, not including where I defined the motors or the rest of my code for other things:
Yes, I forgot to include it here but I did have while true in my code. I also believe toward the bottom of user control the sleep task is automatically in there as well.
Does the elevator work if you controlled it manually? The code looks fine to me. Would need to see the entire code to be able to find whether it’s code or something else causing the problem.
Try putting
elevatorMotor.rotateTo(-500, rotationUnits::deg, 80, velocityUnits::rpm);
elevatorMotor2.rotateTo(-500, rotationUnits::deg, 80, velocityUnits::rpm);
in place of the manual code and when you click the button, check the device manager on the brain, find the elevator motor and see what number is under command
What do you mean by manually by hand? Trying running the default driver program and moving the motor for the elevator to see if it lifts there may not be enough torque.
I added a startRotateTo because I assume you want both motors to lift simultaneously, so the command starts the rotation but doesn’t wait for it to end, then since the second function is a regular rotateTo the program waits for the command to complete. This works because both motors should take the same time to rotateTo that position.
Adding start rotate to didn’t work. Still nothing. I’ve tried taking it out of the while true loop, nothing. I have no idea at this point, no idea why it’s not working for me.