![]() |
Timer.Delay stops motor movement?
I'm currently trying to program autonomous and it's working, I've isolated this issue to be with the Timer.Delay(seconds) command. When hovering over the command, it states that it allows: "Motors [to] continue to run at their last assigned values," but it simply stops them for the time allotted. Are there any alternative timing methods that allow motors to continue to run and change the command after an allotted time?
code: Code:
case leftAuto: |
Re: Timer.Delay stops motor movement?
Is "arcadeDrive" an instance of a RobotDrive? If so, did you disable the motor safety feature? If not, the speed controllers will think that they are no longer being controlled when your Timer.delay() pauses. This will cause the watchdog to time out and disable all of the drive motors.
Here is an example of turning off the motor safety feature while driving autonomously: Code:
|
Re: Timer.Delay stops motor movement?
I'm not sure exactly what you're trying to do, but this many Timer.delay() calls in a single routine is definitely not the code you're looking for. Which robot model are you using (SampleRobot, IterativeRobot, CommandBasedRobot, etc)?
|
Re: Timer.Delay stops motor movement?
Quote:
Quote:
|
Re: Timer.Delay stops motor movement?
Quote:
|
Re: Timer.Delay stops motor movement?
Quote:
Code:
import edu.wpi.first.wpilibj.Timer;Code:
public void autonomousPeriodic() { |
Re: Timer.Delay stops motor movement?
Quote:
|
Re: Timer.Delay stops motor movement?
That sounds like you have something very wrong that is entirely unrelated to the issues being discussed in this thread.
|
Re: Timer.Delay stops motor movement?
Fair, but I can't imagine it's anything mechanical. Our teleop drive works, as does everything else.
|
Re: Timer.Delay stops motor movement?
Quote:
|
Re: Timer.Delay stops motor movement?
Here it is:
Code:
package org.usfirst.frc.team2221.robot; |
Re: Timer.Delay stops motor movement?
I'm not sure that I can answer your autonomous behavior question, but I do have some suggestions that might help clean up some issues.
If you want to turn the motor safety feature on in teleop and off in autonomous, I would recommend that you move the invocation into the teleopInit() and autonomousInit() methods (and then remove the calls from your periodic methods). Code:
@OverrideCode:
Finally, you really want to avoid any use of Timer.delay() in the teleop portion of your robot. If the driver happens to be moving the robot at 10 ft/sec and presses a button that fires off one of your Timer.delay(0.5) calls, the robot will move 5 feet before the operator will have a chance to control it again (hopefully the motor safety will kick in and stop the robot if this condition occurs). You want to avoid features like gamepad rumble if they will disable the ability to drive the robot. For an iterative base robot, you will need to keep track of the state of your different events. One way to do this is with small helper classes. For example, the following Rumbler class keeps track of the rumbling state of a gamepad and turns it off after the appropriate delay (provided you use the start() method to start it and periodically call its periodic() method): Code:
package org.usfirst.frc.team868.robot;Code:
Then in your teleopPeriodic() you could make use of this and get rid of some of your timer delays: Code:
These kind of situations are why the command based robot framework was designed. Good luck. |
Re: Timer.Delay stops motor movement?
pblankenbaker brings up many good points. As to why autonomous is doing nothing (actually, what do you mean by beyblades...I'm not familiar with that expression), I'm not sure. I am curious what you have done to figure it out yourself...have you tried putting a println statement in autonomousPeriodic that shows the value of the timeElapsed variable, which is the variable controlling the timed actions? I would also take a look at the value you got in autonomousInit for autoStartTime. I am not in front of a robot right now, but I'm wondering if your construction of a Timer object and the call to the start() method (in autonomousInit) has any effect on the values returned by Timer.getFPGATimestamp() [the documentation is unclear but makes me think that I'd definitely investigate that]. If that resets or modifies the values returned by the getFPGATimestamp method, then placing the call to start() after you get the autoStartTime might be what is ailing you. Perhaps that (calling the start() method) needs to be removed or placed before you get the autoStartTime value. Bottom line, do you know the values of autoStartTime and timeElapsed (which is based on autoStartTime)?
Another thing that looks odd to me (but is ok if it is working...I'm just curious) is your motor inversions on your drive train. You invert one motor only (the rear, right motor). Again, if everything drives ok then it works...but I'd love to understand how that makes sense. I'm guessing that my tired, addled brain is missing something there. Quote:
|
Re: Timer.Delay stops motor movement?
Quote:
|
Re: Timer.Delay stops motor movement?
Quote:
|
| All times are GMT -5. The time now is 04:11. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi