Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Can anyone please tell me what is wrong with coding here (http://www.chiefdelphi.com/forums/showthread.php?t=143925)

Heber Hooper 02-15-2016 06:57 PM

Can anyone please tell me what is wrong with coding here
 
RobotDrive myRobot; // class that handles basic drive operations
Joystick leftStick; // set to ID 1 in DriverStation
Joystick rightStick; // set to ID 2 in DriverStation
public Robot() {
myRobot = new RobotDrive(0, 1);
myRobot.setExpiration(0.1);
leftStick = new Joystick(0);
rightStick = new Joystick(1); }


/**
* Runs the motors with tank steering.
*/
public void operatorControl() {
myRobot.setSafetyEnabled(true);
while (isOperatorControl() && isEnabled()) {
myRobot.tankDrive(leftStick, rightStick);
System.out.println(leftStick.getY());
System.out.println(rightStick.getY());
leftStick.getRawAxis(0);
Timer.delay(0.005) ; }
// wait for a motor update time}
because it is getting annoyed at the curly braces i bolded and i cannot run anything until it is fixed

thatprogrammer 02-15-2016 07:00 PM

Re: Can anyone please tell me what is wrong with coding here
 
Can you post the error message you get?
Thanks.

Heber Hooper 02-15-2016 07:12 PM

Re: Can anyone please tell me what is wrong with coding here
 
It is a syntax error with it saying that more { need to be entered to complete ClassBody

CyberTeam5713 02-15-2016 07:13 PM

Re: Can anyone please tell me what is wrong with coding here
 
these {

euhlmann 02-15-2016 09:27 PM

Re: Can anyone please tell me what is wrong with coding here
 
Code:

public class Robot {
    RobotDrive myRobot;  // class that handles basic drive operations
    Joystick leftStick;  // set to ID 1 in DriverStation
    Joystick rightStick; // set to ID 2 in DriverStation

    public Robot() {
        myRobot = new RobotDrive(0, 1);
        myRobot.setExpiration(0.1);
        leftStick = new Joystick(0);
        rightStick = new Joystick(1);
    }
   
    /**
    * Runs the motors with tank steering.
    */
    public void operatorControl() {
        myRobot.setSafetyEnabled(true);
        while (isOperatorControl() && isEnabled()) {
            myRobot.tankDrive(leftStick, rightStick);
            System.out.println(leftStick.getY());
            System.out.println(rightStick.getY());
            leftStick.getRawAxis(0);
            // wait for a motor update time
            Timer.delay(0.005);
        }
    }
}

Formatted your code. Hope this helps.

Heber Hooper 02-16-2016 01:28 PM

Re: Can anyone please tell me what is wrong with coding here
 
Quote:

Originally Posted by euhlmann (Post 1540887)
Code:

public class Robot {
    RobotDrive myRobot;  // class that handles basic drive operations
    Joystick leftStick;  // set to ID 1 in DriverStation
    Joystick rightStick; // set to ID 2 in DriverStation

    public Robot() {
        myRobot = new RobotDrive(0, 1);
        myRobot.setExpiration(0.1);
        leftStick = new Joystick(0);
        rightStick = new Joystick(1);
    }
   
    /**
    * Runs the motors with tank steering.
    */
    public void operatorControl() {
        myRobot.setSafetyEnabled(true);
        while (isOperatorControl() && isEnabled()) {
            myRobot.tankDrive(leftStick, rightStick);
            System.out.println(leftStick.getY());
            System.out.println(rightStick.getY());
            leftStick.getRawAxis(0);
            // wait for a motor update time
            Timer.delay(0.005);
        }
    }
}

Formatted your code. Hope this helps.

Thanks man this helps a lot!


All times are GMT -5. The time now is 08:06 AM.

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