View unanswered posts | View active topics It is currently Tue Aug 14, 2018 3:04 am






Reply to topic  [ 5 posts ] 
Passing variables between programs? 
Author Message
Rookie

Joined: Wed Jul 23, 2014 7:05 pm
Posts: 3
Post Passing variables between programs?
I was wondering if it would be possible to pass information between Autonomous and TeleOp mode (FTC). Say, for example, the user selects some preferences in autonomous, such as base drive speed and inverted controls. These are saved as variables in the autonomous code. Of course, they are only needed in the TeleOp code, but you can't re-select these preferences before TeleOp starts (as the robot would be in the middle of the field... and you can't touch it anyway). Is there a way to save those variables to maybe a text file on the NXT, and then read from them in the initialization of TeleOp? Something like this:

User selects preferences -> autonomous starts -> preferences are saved to a text file -> autonomous goes on -> autonomous ends -> teleop initializes and preferences are loaded -> teleop starts with new drive speed and other saved settings

If that's not possible, is there another way to do it?

Thanks for the help

--
Vortex


Wed Jul 23, 2014 7:11 pm
Profile
Professor
User avatar

Joined: Sat Aug 31, 2013 9:15 am
Posts: 256
Post Re: Passing variables between programs?
Yes, that is absolutely possible! Take a look at http://www.robotc.net/wiki/NXT_Functions_File_Access to see complete descriptions of all the file functions.

_________________
FTC Team 6100 Chariots of Fire - Programmer (2012-2013)
FTC Team 7468 Blue Chariots of Fire - Programmer (2013-2014)
FTC Team 7468 Blue Chariots of Fire - Mentor (2014-2015)
Check out our team website at http://bluechariotsoffire.com/.


Thu Jul 24, 2014 4:55 pm
Profile
Rookie

Joined: Wed Jul 23, 2014 7:05 pm
Posts: 3
Post Re: Passing variables between programs?
Awesome, sounds great. Thanks for the help. I'll look into that. Text files do seem to be the easiest way of getting information between programs for now, though maybe someone will come up with a better way of doing so. If possible, of course. We'll just have to wait and see!

Also, I'm assuming that all I'd have to do is write to the text file in a specific order, and then assign the variables in TeleOp their data that way as well.. Unless there's a way to read a certain line from the text file? I suppose I could also put each line into a string array, and then pull them out and parse as needed.

Thanks for the help!

_________________
FTC Team 365 MOE
Programmer (2013-2014)
Head Programmer (2014- )

Check out our team website:
http://www.moeftc.org


Thu Jul 24, 2014 5:16 pm
Profile
Professor
User avatar

Joined: Sat Aug 31, 2013 9:15 am
Posts: 256
Post Re: Passing variables between programs?
DarkVortex wrote:
Awesome, sounds great. Thanks for the help. I'll look into that. Text files do seem to be the easiest way of getting information between programs for now, though maybe someone will come up with a better way of doing so. If possible, of course. We'll just have to wait and see!

Also, I'm assuming that all I'd have to do is write to the text file in a specific order, and then assign the variables in TeleOp their data that way as well.. Unless there's a way to read a certain line from the text file? I suppose I could also put each line into a string array, and then pull them out and parse as needed.

Thanks for the help!


Yes, you are correct about having to use a specific order when writing to and reading from the file. ROBOTC only provides sequential access to files. Hopefully that's sufficient for your purposes.

_________________
FTC Team 6100 Chariots of Fire - Programmer (2012-2013)
FTC Team 7468 Blue Chariots of Fire - Programmer (2013-2014)
FTC Team 7468 Blue Chariots of Fire - Mentor (2014-2015)
Check out our team website at http://bluechariotsoffire.com/.


Fri Jul 25, 2014 8:22 am
Profile
Rookie

Joined: Wed Jul 23, 2014 7:05 pm
Posts: 3
Post Re: Passing variables between programs?
BurningLights wrote:
Yes, you are correct about having to use a specific order when writing to and reading from the file. ROBOTC only provides sequential access to files. Hopefully that's sufficient for your purposes.


Should be perfect. Thanks again for the help.

_________________
FTC Team 365 MOE
Programmer (2013-2014)
Head Programmer (2014- )

Check out our team website:
http://www.moeftc.org


Fri Jul 25, 2014 10:10 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 5 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.