Log in

View Full Version : Pulling Variables from Robot


VaneRaklan
06-02-2015, 20:39
So we are having some problems with variables in Command base programming. What we want to do is to create a variable in either Robot.Java or Robot.Map (or just any one class) that we can call from (i.e Robot.(variable name)) to be used in a command or subsystem. We just cant seem to be able to do just that. Anyone have any ideas as to why or for how we can do this?

Fauge7
06-02-2015, 21:34
In robot map you declare the constants for the robot.

For example:

public static final int MOTOR_SPOT_1 = 1;

Then in any class simply reference it by typing

RobotMap.MOTOR_SPOT_1

defied
06-02-2015, 23:23
In robot map you declare the constants for the robot.

For example:

public static final int MOTOR_SPOT_1 = 1;

Then in any class simply reference it by typing

RobotMap.MOTOR_SPOT_1

Would there be a way to change the value during runtime from the command pulling it? Remove final?

Thanks,
D

TFleig78
06-02-2015, 23:35
Would there be a way to change the value during runtime from the command pulling it? Remove final?
D

Yes, removing final will allow you to change the value during runtime.

defied
06-02-2015, 23:37
Perfect! Thanks!

D

Fauge7
07-02-2015, 23:28
The final keyword in java is used when a variable value is known at runtime.