Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Vision code in separate class? (http://www.chiefdelphi.com/forums/showthread.php?t=126268)

CarrotBlasphemy 11-02-2014 18:22

Vision code in separate class?
 
I downloaded the sample vision code project and copied the main file into my preexisting project. Whenever I attempt to create a new `VisionCode vision=new VisionCode();` and try to run it, it says "network tables has already been initialized" and the program halts. Is there a way to cleanly keep the vision code in a separate file and call it from my main one? This is my first year as programmer and our team's first year trying vision code

Thanks!

irvingc 11-02-2014 18:32

Re: Vision code in separate class?
 
The issue is probably that your VisionCode class still extends the SimpleRobot class. This is a problem because the default RobotBase constructor (from which SimpleRobot extends) is where NetworkTable initialization is conducted. You need to change your VisionCode class not to extend SimpleRobot. Depending on how familiar you are with Java, this might not be so straightforward. Is there a reason you can't just modify the VisionSampleProject robot code to fit your needs?

mwtidd 11-02-2014 20:39

Re: Vision code in separate class?
 
Are you using robot builder? We wound up creating a subsystem called "HotCamera" in which we added an initialize method and an isHot method. I personally like this design, because any commands requiring the camera can then reserve it.

CarrotBlasphemy 11-02-2014 21:23

Thanks so much! Removing the `extends SimpleRobot` did the trick! I'll have to hack at the code to try to get it down to something as simple as an init and isHot but I'm a step closer than this afternoon!


All times are GMT -5. The time now is 09:30.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi