So first off I am using the command based robot template from WPI, and I need to create a command group that will be run during our autonomous period. We are just going to shoot the balls that are in our robot and that’s it for autonomous, nothing complicated.
Basically what I need the robot to do is:
Begin running shooter motor (this will be running throughout autonomous)
Wait 3 seconds or so (for motor to spin up)
run our ball delivery motor for ~1.5 sec
stop ball delivery motor
Run conveyor motor to put 2nd ball in place
run ball delivery motor again
stop motors
I have commands written to do all of these functions, I just need a way to put them together into a command group with a delay in-between. Can anyone offer any guidance that has worked with the command based template?
There is WaitCommand() for the delay part. And you already have the other commands written as you note above. The next step is to create a new class that extends CommandGroup and add all the commands to it.
Alright so I got a chance to test the autonomous today and it doesn’t work. What happens is that when I run the shooter motor runs but then the delivery wheel runs right away as well. The wait command doesn’t seem to be doing anything and the other commands don’t timeout when they are supposed to. (I have the others using setTimeout()).
Can anyone offer any insight into what might be going wrong?
As far as timeOuts for commands, although you are setting the timeout, did you change the isFinished() method to read “return isTimedOut();” I had an issue with this before i buckled down and decided to actually read the documentation more thoroughly.
if you want to know what our code looks like, it’s a simple three line command sequence.
The first command simply sets the shooter to a speed to 1.0 and then returns. The second command is a 3 second delay while the shooter actually gets up to speed (notice that the first command says Parallel, while the second says Sequential). And the last command turns on the motors that feed into the shooter at a slow enough speed to allow time for the shooter to regain it’s momentum. (The parameter is 5 seconds, speed is set within the class). In your case, you are breaking up the two motors that I’m controlling in one command. It seems like you are doing most of this, another thing to check is to make sure the in the end() and interrupted() methods of each command that you are stopping the motors. Not sure if this will solve you problem but I hope it helps.
I hope you read this before competition, but it’s also good to have initialization code that simply turns everything off when you start each state (teleop, auto and disabled). In each of our subsystems we have an init() method that simply turns off the motors associated with the subsystems and is called in each of the main init methods (teleopInit, autonomousInit and disabledInit). That could explain why your motors are starting up right away, they could be reading leftovers from the last time you were in teleop. But on second thought, this is unlikely after a power cycle, so I’m not sure. Regardless it’s a good practice.
That’s interesting, I didn’t expect to see many ramp bots this year, but I guess that’s what 1501 did? Also, if you ever have any other questions, feel free to PM me and I’ll try to help as best I can. And if you’re having trouble at nationals stop by our pit and we’ll see if we can help. Best of luck!!