View Single Post
  #1   Spotlight this post!  
Unread 17-02-2015, 15:24
GeeTwo's Avatar
GeeTwo GeeTwo is offline
Technical Director
AKA: Gus Michel II
FRC #3946 (Tiger Robotics)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Slidell, LA
Posts: 3,679
GeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond repute
Re: Robot Code Problem ** Again**

Quote:
Originally Posted by AnnaliseDonavan View Post
Code:
public class Robot extends IterativeRobot {
RobotDrive Drive;
Joystick drivestick;
Joystick joystick;
int autoLoopCounter;

/**
* This function is run when the robot is first started up and should be
* used for any initialization code.
*/
public void robotInit() {

    Jaguar FL = new Jaguar (5);
    Jaguar BL = new Jaguar (2);
    Jaguar FR = new Jaguar (3);
    Jaguar BR = new Jaguar (4);
    Drive = new RobotDrive(FL,BL,FR,BR);
    drivestick = new Joystick(0);
    joystick = new Joystick(1);


}
Declaring objects inside a method makes them local objects that (unless copied elsewhere) disappear when the method returns. I'm presuming you want these to be instance variables. In this case, declare them earlier and just assign them in robotInit():
Code:
public class Robot extends IterativeRobot {
RobotDrive Drive;
Joystick drivestick;
Joystick joystick;
Jaguar FL, BL, FR, BR;

int autoLoopCounter;

/**
* This function is run when the robot is first started up and should be
* used for any initialization code.
*/
public void robotInit() {

    FL = new Jaguar (5);
    BL = new Jaguar (2);
    FR = new Jaguar (3);
    BR = new Jaguar (4);
    Drive = new RobotDrive(FL,BL,FR,BR);
    drivestick = new Joystick(0);
    joystick = new Joystick(1);
}
P.S.: Also, enclosing your code with the tags makes it easier to read!

P.P.S.: After seeing this, I did not review the rest of the code.
__________________

If you can't find time to do it right, how are you going to find time to do it over?
If you don't pass it on, it never happened.
Robots are great, but inspiration is the reason we're here.
Friends don't let friends use master links.