Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Autonomous timeout (http://www.chiefdelphi.com/forums/showthread.php?t=108754)

Bennett 27-09-2012 19:20

Autonomous timeout
 
We are trying to program autonomous code for our robot and in our commands we have
Code:

    public turnLeft() {
        m_timeout = timeout;
        requires(chassis);

but the m_timeout = timeout; says that m_timeout has private access in edu.wpi.first.wpilibj.command.Command
cannot find symbol
symbol: variable timeout
location:class edu.wpi.first.wpilibj.templates.commands.turnLeft

any ideas as to why?
thanks.

F22Rapture 27-09-2012 22:22

Re: Autonomous timeout
 
Our (error-free) code looks like this --

Code:

public class TurnLeft extends CommandBase {
   
    private double m_timeout;
    private double m_speed;
   
    public TurnLeft(double speed, double timeout) {
        m_timeout = timeout;
        m_speed = speed;
        // Use requires() here to declare subsystem dependencies
        // eg. requires(chassis);
        requires(drivetrain);
    }

Do you have any other code? Because I'm assuming you want to do the same thing that our code does, that is, turn left for the period of time put inside the parentheses when you call the command. To do that you need to make "timeout" a parameter in the TurnLeft method by using putting "double timeout" inside the parentheses. You also want to make m_timeout a variable inside the class, so make sure to put "private double m_timeout;" somewhere.

If you want you can just copy/paste my code in (remove the "speed" stuff) and see if it works.

Ginto8 30-09-2012 23:16

Re: Autonomous timeout
 
Quote:

Originally Posted by Bennett (Post 1187697)
cannot find symbol
symbol: variable timeout
location:class edu.wpi.first.wpilibj.templates.commands.turnLeft

This error means that the compiler is looking for a variable named "timeout" and can't find it. I'm guessing you meant for timeout to be a parameter of the constructor, but forgot to actually put it in. The change is easy:

Code:

    public turnLeft(double timeout) {


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

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