The code was working earlier, we are not sure what changed to break things. But I am getting this error:
The error we are getting is ERROR 1 DifferentialDrive... Output not updated often enough. edu.wpi.first.wpilibj.MotorSafety.check(MotorSafety.java:96) Error at edu.wpi.first.wpilibj.MotorSafety.check(MotorSafety.java:96): DifferentialDrive... Output not updated often enough.
DifferentialDrive wants you to call one of the drive methods in each period. In teleop, we call diffdrive.arcadeDrive(joystick.get...) to satisfy that need, but in autonomous we sometimes see that message for two reasons. One is that we might drive, then stop to shoot etc. While shooting, you need to continue calling diffdrive.arcadeDrive(0, 0) to stay put and satisfy the motor safety timer. The other reason is that we might directly call the motor.set(.. commands from a Ramsete-based trajectory follower in autonomous, circumventing the diffdrive. In that case, you need to call diffdrive.feed() to tell it that everything is fine and there is no need to invoke motor safety to stop motors because we are controlling the motors without calling arcadeDrive but by directly going to the motor.set(...)
I’ll start including those things, thanks for that advice.
We would would start the robot in teleop. Press button 2 and then 1. Which activates the tshirtcannon.shoot method. And then the error code spits out and my pneumatics stop working.
I pretty sure there isn’t a problem with the buttons because I have print statements that run when the method calls, and they get called every time I press them, even after the pneumatics stop working.
We keep our code open source so anyone can benefit from what we’re doing, there are teams with much stronger software practices than ours, but our robots are typically command-based and operate relatively bug free from year to year. Hopefully some of it can help you guys as well, feel free and ask any questions about what you’re seeing.
To break down this particular command, we needed our shooter flywheel to get to shooting speed before we pushed balls through the indexer to score so we use the Timer class from WPILib to countdown from command scheduling to the time to actually shoot.
I think you want to do the same thing. Instead of waiting, and blocking the way you have with a wait command, seeing the logic in the scheduler link above will hopefully help you understand that you can achieve the same thing without messing up the scheduler just by using a timer and some conditional logic in your execute method.
You can also use a SequentialCommandGroup with 3 commands to fire then wait then release. Or chanhe the shoottshirt command to fire in intialize, release in end and use the withTimeout decorator to add the delay.
I made those changes and the robot seems to be working as intended. The only thing is that when I start the robot in TeleOp or Auto it spits out watchdog not fed again and then ERROR 1. The watchdog not fed does go away and then I can use the robot exactly as intended… so I think the problem is fixed. But I am not sure what is going on with the ERROR, or if it is even a problem.
The updated code has been pushed to github, and thank you for all the help so far.
Re-arranging your command assignments to triggers might prevent you from overrunning the watchdog.
The scheduler documentation actually has some example code that shows how you can alter the logging and visualize what action the scheduler is taking. You could then go and figure out which of the command constructors or initialize methods are taking too long.