|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
Re: COmmand based software Interrupts
In the Elevator subsystem:
How are the upperLimit() and lowerLimit() switches wired up? If they are just limit switches that pull the channel low when the switch is closed (ground on the NC pin, signal on the C pin), then I would expect your GetLowerLimit() and GetUpperLimit() to return true when the switches are not pressed, and false when they are pressed. This is because there are pull-ups on the discrete input channels. This would cause your MoveElevatorXXX commands to immediately end. If you haven't already tested in your subsystem do what you think they should... add some print statements that call elevator.GetLowerLimit() and elevator.GetUpperLimit() from within Robot.TeleopPeriodic(). Without running any commands, press your switches and verify that the functions are retuning True/False when you think they should. If that's not the problem, can you provide a real log of the output that you're seeing in the console when you run. I suspect that what was provided earlier wasn't real output from the robot. There's a lot more print statements in your code that I would expect to see that aren't in the log you provided. Having a real copy of the log will help us see how the commands are executing and potentially help narrow down where to look. Last edited by otherguy : 03-12-2015 at 04:22 PM. Reason: fix typo that got flagged as profanity? |
|
#2
|
|||
|
|||
|
Re: COmmand based software Interrupts
Quote:
I'll get a proper log later, but yeah that was pretty much it :/ the only thing I changed was adding a printf to the isFinished command. When the new button was pressed it ran the: old command interrupt new command init new command execute new command isFinished old command execute old command isfinished new command execute new command isFinished old command execute old command isfinished and et cetera. Last edited by Sparkyshires : 03-12-2015 at 03:24 PM. |
|
#3
|
||||
|
||||
|
Re: COmmand based software Interrupts
Your switches may be wired correctly... but that doesn't mean that your code is reading their states correctly. Hence my suggestion to check that it's doing what you expect. If you're confident that's not the problem, good. I can't make you check it. You're the one that's saying it's not working correctly, so It may be prudent to verify your assumptions.
Other things that could be wrong: Which commands in particular are you referring to as "new" command and "old" command? The reason I ask is in OI all the MoveElevatorXXX commands are started when you press a button. These are the command I thought you were talking about previously wrt your logs. They will only execute once unless you're repeatedly pressing the button in question. This is not consistent with the logs you've provided. On the other hand, if the one of the commands that's running happens to be the DropElevator() or LiftElevator() commands, then there's a different explanation for what may be going on. I have yet to come up with a case where WhileHeld() actually does what you want it to (if someone has a use case, please let me know). If I understand your code correctly, the way you're attempting to use this command is to have your Lift/DropElevator() commands run until you let go of the button. But what's actually going to happen is each loop iteration, you're going to start a new copy of the Lift/DropElevator() command. Since you have a call to stop the elevator as part of the command, you're going to be in this endless loop of driving the elevator, stopping it, driving it, stopping it, until you let go of the button. Here's why using the joy1button4->WhileHeld(new DropElevator()); as an example:
What you probably want to do is instead execute the command WhenPressed, then call a command that stops the elevator (ElevatorIdle) When the same button is released. Code:
joy1button3->WhileHeld(new LiftElevator()); joy1button4->WhileHeld(new DropElevator()); joy2button3->WhileHeld(new LiftElevator()); Code:
joy1button3->WhenPressed(new LiftElevator()); joy1button3->WhenReleased(new ElevatorIdle()); joy1button4->WhenPressed(new DropElevator()); joy1button4->WhenReleased(new ElevatorIdle()); joy2button3->WhenPressed(new LiftElevator()); joy2button3->WhenReleased(new ElevatorIdle()); |
|
#4
|
|||
|
|||
|
Re: COmmand based software Interrupts
Quote:
The fact there is only one object created at Robot init (vs. one created every time the button is held) is only important if your command has member variables that might make a difference to you how many objects there are. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|