Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Help With Programing (http://www.chiefdelphi.com/forums/showthread.php?t=100328)

Stagger007 15-01-2012 23:23

Help With Programing
 
Hello my team is a rookie team and its the first time we do FRC and we finally got the java image on the cRIO now were running ode that is directly copied from the java guide and its not running. Our code is as follows:
package edu.wpi.first.wpilibj.templates;


import edu.wpi.first.wpilibj.SimpleRobot;
import edu.wpi.first.wpilibj.Servo;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.Joystick;

public class RobotTemplate extends SimpleRobot {
RobotDrive drive = new RobotDrive(1, 2);
Joystick leftStick = new Joystick(1);
Joystick rightStick = new Joystick(2);
/**
* This function is called once each time the robot enters autonomous mode.
*/
public void autonomous() {
for(int i =0; i < 4; i++){
drive.drive(0.5, 0.0);
Timer.delay(2.0);
drive.drive(0.0, 0.75);
Timer.delay(0.75);
}
drive.drive(0.0,0.0);
}

public void operatorControl() {
while (isOperatorControl() && isEnabled()){
drive.tankDrive(leftStick, rightStick);
Timer.delay(.005);

}

}
}

davidthefat 15-01-2012 23:25

Re: Help With Programing
 
Is it not connecting to the computer or what?
BTW, I would not use the for loops. Remember the "action" is not done almost instantly, it takes time for a physical object to be actuated. I would also take out the delays.

youxinche95 15-01-2012 23:34

Re: Help With Programing
 
It's great to see rookie teams dive into text based programming languages!

getWatchdog().feed()?

I think that's missing,

or did you not enable watchdog?

either way, the code looks fine other than that.

gixxy 16-01-2012 00:17

Re: Help With Programing
 
Did you fix the db37 cable (the ribbon cable connecting the digital sidecar to the cRio) if not then the jaguars/victors will not work in ports 1 and 2. they will in ports 3 and 4 (we figured that out after a lot of testing)

here is the document on fixing the cable if it applies: http://www.usfirst.org/sites/default...structions.pdf

Stagger007 16-01-2012 09:49

Re: Help With Programing
 
i did not enable the watch do I'm not really sure what that does

gixxy 16-01-2012 10:48

Re: Help With Programing
 
Basically the watchdog is a guardian. When enabled you need to "feed()" it and keep it happy. However if your code goes into an infinite loop or something the code will not be able to "feed()" the watchdog and it will die, and dis-activate the motors and other components with it, so that the robot doesn't go wild and break itself or something else.

However if you did not enable the watchdog, you should be fine not putting the code in for it.

BradAMiller 16-01-2012 11:33

Re: Help With Programing
 
I just copied your program and pasted it into a new project and ran it. Other than the motor ports not matching mine, it seemed to run some motors, at least in autonomous. I didn't have joysticks on the test platform.

Were you seeing no movement at all? If so, I'd look for other problems, like (as has been said) the cable to the digital breakout board, or something else.

You should verify that the driver station software is set up properly and that you see green "Communications" and "Robot Code" indicators and that your team number is set correctly.

Let us know after trying those things.

Brad

BradAMiller 16-01-2012 11:59

Re: Help With Programing
 
Quote:

Originally Posted by BradAMiller (Post 1106812)
I just copied your program and pasted it into a new project and ran it. Other than the motor ports not matching mine, it seemed to run some motors, at least in autonomous. I didn't have joysticks on the test platform.
Brad

That was stupid... you know the test system had some servos that happened to be on those channels and naturally they moved before the motor safety stuff caught it. Change your autonomous code to look like this:
Code:

    public void autonomous() {
        drive.setSafetyEnabled(false);  // this turns off motor safety
        for (int i = 0; i < 4; i++) {
            drive.drive(0.5, 0.0);
            Timer.delay(2.0);
            drive.arcadeDrive(0.0, 0.75);  // this was a typo in the book
            Timer.delay(0.75);
        }
        drive.drive(0.0, 0.0);
    }

Brad


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

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