Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   help for code to run motor (http://www.chiefdelphi.com/forums/showthread.php?t=102110)

nuru 06-02-2012 17:11

help for code to run motor
 
We are a rookie team and we wrote the following code to operate the motor.
We are not sure if it will work. Please help.

public class ParkwayRobot extends SimpleRobot
{
private final int PORT_ONE = 1;
private final int PORT_TWO = 2;
private final int MY_SLOT = 1; // or 2, 3, 4
private final double DESIRED_SPEED = 0.7;

RobotDrive drive = new RobotDrive(1, 2); // motors in ports 1 and 2
Joystick leftJoy = new Joystick(PORT_ONE);
Joystick rightJoy = new Joystick(PORT_TWO);

public void autonomous()
{

Jaguar firstJaguar = new Jaguar(MY_SLOT, PORT_ONE);
firstJaguar.set(DESIRED_SPEED); // between -1.0 and 1.0
}

public void operatorControl()
{

while (isOperatorControl() && isEnabled())
{
Drive.tankDrive(leftJoy, rightJoy);
Timer.delay(0.005);
}
}

}

We are not sure how to compile and run this code using Netbeans. Please help.

Thanks a lot!

severhale 06-02-2012 22:02

Re: help for code to run motor
 
Well to start, you may want to be more specific with your names. Saying LEFTJOYSTICKPORT instead of PORT_1 is much more helpful because you won't be accidentally mixing them up.

For running it, you have to go to setting, miscellaneous and put in your team number in the box where it says "team number." Then you can build it and if you're connected to the robot and on its subnet it will automatically upload it to the cRIO.

msulaimain 06-02-2012 22:10

Re: help for code to run motor
 
Any of the platforms that US FIRST provides teams with have examples that one can refer to and which can help you really understand the basic structure of programming in that language. I program in C++ and I know that they definitely have a SimpleRobot example. Maybe your platform has example programs as well.


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

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