Quote:
Originally Posted by sjspry
Also, note that when you call "getInstance" of the AxisCamera, it initializes and returns a class the first time you do this. If you don't capture this class in a variable and keep it "alive" during the whole of your robot's run, it will get garbage collected and the thread it creates to relay information will be killed.
|
This is not true.
AxisCamera.getInstance() will create a new instance of the
AxisCamera class and return it the first time it is called. Any time after that, it returns the one instance that it already created. There is no destructor that kills the camera thread, and a reference to the singleton
AxisCamera instance is always stored within the
AxisCamera class in
AxisCamera.m_instance. A call to
AxisCamera.getInstance() will always return this instance.
Code:
public class AxisCamera implements ISensor{
private static AxisCamera m_instance = null;
...
public static synchronized AxisCamera getInstance() {
if (m_instance == null) {
m_instance = new AxisCamera();
}
return m_instance;
}
The constructor calls the
AxisCameraStart function that is part of the C++ library. That function starts up the
PCVideoServer. Even if there was destruction of the
AxisCamera object, it would not signal this thread to stop.
To get back to the original question:
Make sure the camera is configured per the instructions located here:
http://www.usfirst.org/uploadedFiles...our_Camera.pdf
If there is any console output that you see before the program stops, posting that may be helpful.