ROBOTC.net forums
http://www.robotc.net/forums/

Passing variables between programs?
http://www.robotc.net/forums/viewtopic.php?f=32&t=9136
Page 1 of 1

Author:  DarkVortex [ Wed Jul 23, 2014 7:11 pm ]
Post subject:  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

Author:  BurningLights [ Thu Jul 24, 2014 4:55 pm ]
Post subject:  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.

Author:  DarkVortex [ Thu Jul 24, 2014 5:16 pm ]
Post subject:  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!

Author:  BurningLights [ Fri Jul 25, 2014 8:22 am ]
Post subject:  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.

Author:  DarkVortex [ Fri Jul 25, 2014 10:10 am ]
Post subject:  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.

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/