Go to Post Adversity should be seen as a challenge and not as an obstacle. :D - waialua359 [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
 
Thread Tools Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 17-02-2015, 15:24
GeeTwo's Avatar
GeeTwo GeeTwo is online now
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,614
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.
  #2   Spotlight this post!  
Unread 17-02-2015, 15:57
AnnaliseDonavan AnnaliseDonavan is offline
Registered User
FRC #4284
 
Join Date: Jan 2015
Location: Cincinnati,Ohio
Posts: 20
AnnaliseDonavan is an unknown quantity at this point
Re: Robot Code Problem ** Again**

Quote:
Originally Posted by GeeTwo View Post
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.
The robot drive works, that is not the problem that I am running into I cannot get the buttons to work.
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


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

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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