![]() |
Autonomous java problems
Hi guys,
We are first year programmers that are not sure on how to program autonomous on our robot. Every time we try we keep getting an output from the console on netbeans saying, "Robot Drive...output not updated enough" :confused: Please respond as soon as possible and with some example code if possible. Thanks |
Re: Autonomous java problems
That error is part of a safety feature in the RobotDrive class. It states that if the RobotDrive isn't update every so often, then the robot will stop driving. For Autonomous you want to set the speed once and then stop it later. To do this you need to disable the safety.
Code:
RobotDrive.setSafetyEnabled(false); |
Re: Autonomous java problems
Thanks!! It now works!!!
|
Re: Autonomous java problems
Although this works and doesn't (normally) cause problems, the safety is there for a reason. Once you guys get it figured out the simple way (and if you still have spare time, a rare commodity) I would recommend figuring out a way to update the motors regularly.
AutonomousPeriodic, like the name suggests, runs periodically, just like teleop periodic. The programming "structure" (it's something you have to create on your own, not a built in java thing) that allows you to do this is called a state machine. But once again, this is just for if you have time, and if you want something to try during offseason to help you next year. I doubt that it will cause problems for you now.:) |
Re: Autonomous java problems
A good mental model for programming the robot is that, each time your code executes, you should be answering the question "what should the robot be doing right now."
Consider the situation where you want to drive forward for a certain time. Each time the loop would execute, you'd ask the question "what should the robot be doing now.". In this case, you'd be examining your timer and saying something like this: float elapsedtime = ...; float timeToDriveForward = ...; if (elapsedtime < timeToDriveForward) { // set motors to drive forward } else { // turn motors off } Note that each time this executes, you are either setting the motors to drive forward, or turning them off. |
| All times are GMT -5. The time now is 02:36. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi