Go to Post However I do wish to reassure people that the judges did not just fall off the back of a turnip truck... - dtengineering [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 06-02-2015, 20:39
VaneRaklan VaneRaklan is offline
Registered User
FRC #2557 (The SOTABots)
Team Role: Programmer
 
Join Date: Feb 2015
Rookie Year: 2014
Location: Tacoma, WA
Posts: 18
VaneRaklan is an unknown quantity at this point
Pulling Variables from Robot

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?
Reply With Quote
  #2   Spotlight this post!  
Unread 06-02-2015, 21:34
Fauge7 Fauge7 is offline
Head programmer
FRC #3019 (firebird robotics)
Team Role: Programmer
 
Join Date: Jan 2013
Rookie Year: 2012
Location: Scottsdale
Posts: 195
Fauge7 is a name known to allFauge7 is a name known to allFauge7 is a name known to allFauge7 is a name known to allFauge7 is a name known to allFauge7 is a name known to all
Re: Pulling Variables from Robot

In robot map you declare the constants for the robot.

For example:

Code:
public static final int MOTOR_SPOT_1 = 1;
Then in any class simply reference it by typing

Code:
RobotMap.MOTOR_SPOT_1
Reply With Quote
  #3   Spotlight this post!  
Unread 06-02-2015, 23:23
defied defied is offline
Registered User
FRC #2557
 
Join Date: Jan 2014
Location: Tacoma, WA
Posts: 23
defied is an unknown quantity at this point
Re: Pulling Variables from Robot

Quote:
Originally Posted by Fauge7 View Post
In robot map you declare the constants for the robot.

For example:

Code:
public static final int MOTOR_SPOT_1 = 1;
Then in any class simply reference it by typing

Code:
RobotMap.MOTOR_SPOT_1
Would there be a way to change the value during runtime from the command pulling it? Remove final?

Thanks,
D
Reply With Quote
  #4   Spotlight this post!  
Unread 06-02-2015, 23:35
TFleig78's Avatar
TFleig78 TFleig78 is offline
Registered User
AKA: Tyler
FRC #0078 (Air Strike)
Team Role: Programmer
 
Join Date: Jan 2013
Rookie Year: 2012
Location: Rhode Island
Posts: 58
TFleig78 will become famous soon enoughTFleig78 will become famous soon enough
Re: Pulling Variables from Robot

Quote:
Originally Posted by defied View Post
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.
Reply With Quote
  #5   Spotlight this post!  
Unread 06-02-2015, 23:37
defied defied is offline
Registered User
FRC #2557
 
Join Date: Jan 2014
Location: Tacoma, WA
Posts: 23
defied is an unknown quantity at this point
Re: Pulling Variables from Robot

Perfect! Thanks!

D
Reply With Quote
  #6   Spotlight this post!  
Unread 07-02-2015, 23:28
Fauge7 Fauge7 is offline
Head programmer
FRC #3019 (firebird robotics)
Team Role: Programmer
 
Join Date: Jan 2013
Rookie Year: 2012
Location: Scottsdale
Posts: 195
Fauge7 is a name known to allFauge7 is a name known to allFauge7 is a name known to allFauge7 is a name known to allFauge7 is a name known to allFauge7 is a name known to all
Re: Pulling Variables from Robot

The final keyword in java is used when a variable value is known at runtime.
Reply With Quote
Reply


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 18:03.

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