|
|
|
![]() |
|
|||||||
|
||||||||
|
|
Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Read/Write Preferences in C++
The 2015 SmartDashboard description gives a code example to set Preferences, then display them by adding a Robot Preferences widget.
Last year we made program changes for some timing and positioning variables that we would have preferred to set via the SmartDashboard and have them preserved. I added the code to a Sample Robot project and can not get it to work. The lines we added have // %rod comments in the following snippet. //////////////////////////////////////////////////////////////////// class Robot: public SampleRobot { RobotDrive myRobot; // robot drive system Joystick stick; // only joystick Preferences *prefs; // %rod public: Robot() : myRobot(0, 1), // these must be initialized in the same order stick(0) // as they are declared above. { myRobot.SetExpiration(0.1); prefs = Preferences::GetInstance(); // %rod } void RobotInit(){ // all new %rod double x; double y; SmartDashboard: utString("Version","1.1");x = prefs->GetDouble("x Pref",33); y = prefs->GetDouble("y Pref",66); } ////////////////////////////////////////////////////// The SmartDashboard will display the version 1.1 data, but when we add the Robot Preferences widget, it is blank. I then spent several hours trying prefs->PutDouble, prefs->Save..., etc. and have now given up. Is there a working example of C++ using Preferences? |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|