Ok, not a rookie, but for sure no expert. Is there any way to access limit switches that are set for arms in Teleop during Autonomous? We have limit switches that work during Teleop perfectly and would like to move the same arms to a position and have them stop. I thought…limit switch in auto…hmmm. I tried and the switches didn’t stop the motor. Can this be done? Maybe I just made a mistake in creating the Auto program. Any help would be great.
This definitely can be done. In fact, your robot can and should work functionally the same in auto and teleop, and it’s merely what is causing the inputs (controllers verses prepared instructions) that is different.
I highly suggest uploading your code to github so we can view it and help you based on your current code structure. The way you are describing your problem leaves many different avenues based on what your code currently looks like. I describe the process to creating a github repo in this thread.
AfterTen, I personally wouldn’t recommend that architecture. Not that it wouldn’t work, but I don’t see the added benefit; and I see more complexity. I’m curious if there’s a reason you would do it that way though. (Maybe @mention me in another thread or PM, not that I’ll be able to respond quickly).
I’m not sure why you see more complexity. We do the same. We have a single loop that polls our sensors and saves the results to globals. This allows you to use them in both teleop or auto, and doesn’t require you to put gets in both to use the sensors. It’s quite clean and simple. It also has the benefit that your sensors are polling in disabled so you can feed them to your dashboard and probe them for troubleshooting, all without enabling the robot.
Pretty much this.
We also do this for many of our mechanisms that operate by state machine.
(I haven’t bothered to seriously look into Command And Control - I should)
For instance our intake, not surprisingly, goes up and down.
There is a global variable that we set to the desired state of the intake.
Then the VI that actually controls the intake runs in periodic tasks and just monitors the global variable.
Set the variable to “UP” and the intake goes up. “Down” goes down.
Now in auto we just set it when we need to and same for TeleOp. Hitting buttons on control panel just sets a global variable.
As usual with programming there multiple ways to go about it and the best way, barring an objective argument against it like introducing too much lag, is just the way it makes more sense to you.