![]() |
ASAP Code giving outOfMemory error
1 Attachment(s)
Hello everyone and thanks for reading,
I am a programming mentor on rookie team 4998. We are working on finishing our code for competition Thursday but are running into issues. I am getting a outOfMemory error which is then followed by "Robot Drive... Output not updated often enough." continuously outputting once the robot is enabled. It sounds like this is a result of a motor getting declared but not set. I can not seem to solve this no matter how I change the code around. If someone could take a look, it would help me a lot. I will be recreating it completely tomorrow if I do not get a response because it wasn't coded the best way and I need it to work. I will try and check back a few more times tonight to respond. Thanks for help everyone! Andrew |
Re: ASAP Code giving outOfMemory error
I took a look through your code and have the following comments/suggestions:
You need to refactor the execute() methods in several of your commands. For example, the execute method in Shoot.java looks like: Code:
This is fundamental rule that needs to be followed when using the CommandBased framework (the execute() method of one active command must complete before the execute() of the next active command is invoked). For example, if the code fragment above takes 2 seconds to run. Then none of the execute methods of the other commands on your robot will run for 2 seconds. The driver won't be able to drive the robot and the robot will continue on "cruise control" until the motor safety kicks in and kills your program with the dreaded "Robot Drive... Output not updated often enough." message. This is most likely the reason you are seeing the "Robot Drive... Output not updated often enough." message. Once you see this message, you are probably done for the match. To refactor this type of code, you will either need to break the Shoot command into separate simple commands that you can join into a sequential command group: WaitForCatapultReady, WaitAfterShooting, RaiseElevator, LowerElevator. For example, if the following code fragment raises the elevator: Code:
while(!catapult.CatapultMSEnd()) {Code:
public class RaiseElevator extends CommandBase {If you don't want to break your Shoot command into a group of separate command, it is possible to refactor it by keeping track of states (define a set of states to transition through, have the initialize() method put it in the initial state, have the execute() method do an action based on the state (but no loops/delays), have the isFinished method determine when to move to the next state or when it is done. Wrapping your head around the CommandBase framework takes some time, but it does have a lot of nice advantages over the SimpleRobot framework (especially on robots with numerous subsystems). Keep at it and I'm sure you work your way through the issues. Good Luck. |
Re: ASAP Code giving outOfMemory error
Thank you very much for the detailed reply! It helped a lot to understand how the command/subsystem framework works. I should have realized that the commands were suppose to be recursion based (that's what it looks like is happening) based on some sample code I was using.
Either way thanks for the reply again. This should definitely be enough info to finish the code up. Andrew |
Re: ASAP Code giving outOfMemory error
Quote:
Commands should be seen as instructions to control the hardware tied to a subsystem. A command can do one thing and finish such as set a solenoid in a subsystem and complete, or a command can run forever, and only close when interrupted, such as driving with Joysticks, which will run forever, and if you hit a button to run another command on that subsystem it will stop. Take a look at the screensteps live wpi site for an overview of commandbase if its still unclear or post questions here. If you are getting an outOfMemory message, you have a memory leak somewhere. I haven't looked at your code, but look for anywhere you use the new operator in a loop. That is probably not something you want to do. Hope this helps, Kevin |
| All times are GMT -5. The time now is 11:30. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi