Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   separate classes (http://www.chiefdelphi.com/forums/showthread.php?t=95402)

Thad House 29-05-2011 01:39

separate classes
 
1 Attachment(s)
Our labview programmer uses seperate VI's for everything and i was trying to do the same thing in java. for some reason i cannot get it to work. it compiles correctly and uploads, but it never then works. can i get any help.

here is the code

thanks

EHaskins 29-05-2011 02:19

Re: separate classes
 
The only thing I see without knowing what you symptons are, is that you never instantiate DriveRobot.driver.

In the future when you post issues like this, you need to include more information. Are there any errors? Does the DS say "No Code", "Watchdog Not Fed", etc? Does the DS message change when you enable or disable it? These are all important pieces of information we can use to help find your issue.

I would also say that seperating functionallity is often a good thing, but you're sperating things in an unusual way. I suggest you spend some time reading Java code posted by other teams. It may give a better idea of how Java programs should be partitioned.

Ether 29-05-2011 09:00

Re: separate classes
 
Quote:

Originally Posted by sst.thad (Post 1064049)
for some reason i cannot get it to work. it compiles correctly and uploads, but it never then works. can i get any help.

You might get more help if you explain what you mean by "it never works". Does that mean it does something.. but not what you expect, or does it mean it's completely DOA. Also, give some detail about what are all the indicator LEDs doing.



Thad House 29-05-2011 13:12

Re: separate classes
 
When i run the code on the robot, it runs and enables, but the joysticks never control anything. the victors do enable. i put relay code into the main file in the operatercontrol section, and it does not run either. so i do not belive the code gets to operater control.

Ether 29-05-2011 13:20

Re: separate classes
 
Quote:

Originally Posted by sst.thad (Post 1064073)
When i run the code on the robot, it runs and enables, but the joysticks never control anything. the victors do enable. i put relay code into the main file in the operatercontrol section, and it does not run either. so i do not belive the code gets to operater control.

When you say "the joysticks never control anything" what do you mean by that? Do you mean you've checked the status lights on the motor controllers and they are not responding to the joysticks? Do you also mean that you've checked the PWM indicators in the Dashboard and they are not responding?



wmarshall 29-05-2011 17:22

Re: separate classes
 
First, check the manifest file in the resources/META-INF/ folder. It should look something like this (note that MIDlet-Name can be basically whatever you want):
Code:

MIDlet-Name: ASimpleJavaBot
MIDlet-Version: 1.0.0
MIDlet-Vendor: FIRST
MIDlet-1: spike, , com.hedgehog.spike.spike
MicroEdition-Profile: IMP-1.0
MicroEdition-Configuration: CLDC-1.1

If that looks ok, then you should note that you code will throw a NullPointerException on robotInit(). You never instantiate RobotDrive.driver, as Eric mentioned, so any method call involving it will nuke the JVM from orbit. You probably don't need to call your drive methods twice (in RobotDrive.run() and spike.operatorControl()). In addition, I'm a bit confused by how you're attempting to drive your robot; you seem to be using three joysticks, using driver and secondary in RobotDrive.run(), driver and driver2 in spike.operatorControl(). Lastly, you may actually want to start the RobotDrive thread.

Java is a very object-oriented language, so you may want to investigate using static fields so that you don't have to instantiate your Inputs and Joysticks classes. Over here you can see our code. We made big steps in properly using Object Orientation to make our code not be a complete mess, and kinda succeeded.


All times are GMT -5. The time now is 22:19.

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