Quote:
Originally Posted by Robby Unruh
What do you mean "leaving the scope"?
|
An object only exists when in scope. For instance if you declare a variable in a method it is created and destroyed when the method is entered and exited.
I usually declare a motor in a class and call that classes constructor from my top level class (I use SimpleRobot usually) that way the motor exists from when the class is first instantiated and never goes away until exit.
The scenario I mentioned in the previous post only occurs when you do something like
public void motorStuff(){
motor = new Jaguar(1);
Jaguar.set(0.5);
}
The motor controller object will go away before it has time to do anything. Even if you call it repeatedly it won't last long enough to run for more than microseconds.
It doesn't seem to be the problem from the code you posted, but it doesn't hurt to ask.