Go to Post The driver must have a relationship with the robot, the driver should talk to the robot, speak soft encouraging words to it. Pet names are also a good idea. If the driver does not love the robot, how can the driver learn to trust the robot. - Gboehm [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rating: Thread Rating: 6 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 18-03-2013, 14:19
slibert slibert is offline
Software Mentor
AKA: Scott Libert
FRC #2465 (Kauaibots)
Team Role: Mentor
 
Join Date: Oct 2011
Rookie Year: 2005
Location: Kauai, Hawaii
Posts: 351
slibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud of
Crio C++ Preferences -> How to See/Edit these values in the Smart Dashboard

We are currently using a Preferences object in our code, to store/retrieve various tuning parameters like PID coefficients.

Here's the snippet of code that instantiates/uses the Preferences:

**********

<RobotMap.cpp, in the static init() method>

Preferences *prefs = Preferences::GetInstance();
double tilter_p = prefs->GetDouble("Tilt_P", 1.0);
double tilter_i = prefs->GetDouble("Tilt_I", 0.0);
double tilter_d = prefs->GetDouble("Tilt_D", 0.0);
// BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS
LiveWindow* lw = LiveWindow::GetInstance();
....

***********

On the smart dashboard side, we transition to Teleop mode, enable it in the driver station, and then add the "RobotPreferences" widget, but the above preferences don't show up. (Actually, nothing shows up in the widget). Other controls are communicating Ok w/the robot code, just not the Preferences.

So we push the "Save" button on the smart dashboard side, reboot the robot, and still nothing shows up in the "RobotPreferences" widget.

We think our usage is correct (we've based it on the documentation in the 2013 screensteps live at http://wpilib.screenstepslive.com/s/...martdashboard).

Are we missing some sort of important initialization here in order to get this to work?
Reply With Quote
  #2   Spotlight this post!  
Unread 18-03-2013, 14:32
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,576
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Crio C++ Preferences -> How to See/Edit these values in the Smart Dashboard

Just getting the preference doesn't ensure that the preference exists in the file. You need to get it there somehow (either by putting a value in there in your program or by entering in with the smartdashboard widget and then saving it).

If you want to do it programatically, you can check if the preference exists, and if it doesn't exist, put a value and then save.
Reply With Quote
  #3   Spotlight this post!  
Unread 18-03-2013, 16:17
slibert slibert is offline
Software Mentor
AKA: Scott Libert
FRC #2465 (Kauaibots)
Team Role: Mentor
 
Join Date: Oct 2011
Rookie Year: 2005
Location: Kauai, Hawaii
Posts: 351
slibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud of
Re: Crio C++ Preferences -> How to See/Edit these values in the Smart Dashboard

Thanks, Joe.

So w/the code shown above, do you think this sequence should work?

A) Start robot (runs above code).
B) In SmartDashboard, in Preferences widget, add a variable w/same name as declared in the code above.
C) Then, press SAVE.
D) Then, reboot robot, restart smart dashboard, and the value should show up in the Preferences widget.

I ask this nit-picky question because when we tested it, we performed all of these steps - except B. Instead, we performed A, C and D. Our assumption was that the robot code's default values would get saved when "SAVE" was pressed in the widget, but that appears not to be the case.
Reply With Quote
  #4   Spotlight this post!  
Unread 18-03-2013, 18:03
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,576
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Crio C++ Preferences -> How to See/Edit these values in the Smart Dashboard

Quote:
Originally Posted by slibert View Post
So w/the code shown above, do you think this sequence should work?
Yes
Reply With Quote
  #5   Spotlight this post!  
Unread 20-03-2013, 15:33
slibert slibert is offline
Software Mentor
AKA: Scott Libert
FRC #2465 (Kauaibots)
Team Role: Mentor
 
Join Date: Oct 2011
Rookie Year: 2005
Location: Kauai, Hawaii
Posts: 351
slibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud of
Re: Crio C++ Preferences -> How to See/Edit these values in the Smart Dashboard

Hmmm - no joy. Performed steps A-D, and the robot still uses the "default" preference values. After restarting the robot, the Robot Preferences widget shows no values, and they didn't appear in the NetworkTables viewer either.

We noted that smart dashboard doesn't prompt for any data type when adding a preference. I assume the smart dashboard is adding a string. If so, is there a problem because the dashboard-added string is not the same datatype that the robot code is expecting?

Perhaps we have to modify the robot code to only use strings, converting them ourselves to doubles/ints/etc within the robot code?
Reply With Quote
  #6   Spotlight this post!  
Unread 20-03-2013, 16:14
Happy Birthday! Jefferson Jefferson is offline
Registered User
AKA: Jeff Clements
FRC #0016 (Bomb Squad)
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2010
Location: Mountain Home, AR
Posts: 258
Jefferson has a reputation beyond reputeJefferson has a reputation beyond reputeJefferson has a reputation beyond reputeJefferson has a reputation beyond reputeJefferson has a reputation beyond reputeJefferson has a reputation beyond reputeJefferson has a reputation beyond reputeJefferson has a reputation beyond reputeJefferson has a reputation beyond reputeJefferson has a reputation beyond reputeJefferson has a reputation beyond repute
Re: Crio C++ Preferences -> How to See/Edit these values in the Smart Dashboard

I would suggest using the Prefs.PutNumber function in the RobotInit to get the keys in the table.

Then in TeleopPeriodic use:
PIDNAME->SetPID(Prefs->GetNumber("TiltP". 1.0), Prefs->GetNumber("TiltI", 0.0), Prefs->GetNumber("TiltD". 0.0));
Replacing PIDNAME with your PID.

Also, why don't you use LiveWindow to tune the PID and then hard code those parameters once they are set?

Last edited by Jefferson : 20-03-2013 at 16:15. Reason: Add LW question
Reply With Quote
  #7   Spotlight this post!  
Unread 20-03-2013, 16:30
slibert slibert is offline
Software Mentor
AKA: Scott Libert
FRC #2465 (Kauaibots)
Team Role: Mentor
 
Join Date: Oct 2011
Rookie Year: 2005
Location: Kauai, Hawaii
Posts: 351
slibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud of
Re: Crio C++ Preferences -> How to See/Edit these values in the Smart Dashboard

Great idea, PutNumber (but not "Save") in the Robot. Thanks....

We are using LiveWindow to tune PIDs, but have multiple robots (competition, practice) and want to use the same code for each - and differences in robot weight mean PID coefficients may be different. Plus have some other calibration constants (angle sensor offsets, etc.) that differ on each robot.
Reply With Quote
  #8   Spotlight this post!  
Unread 20-03-2013, 16:50
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,576
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Crio C++ Preferences -> How to See/Edit these values in the Smart Dashboard

Quote:
Originally Posted by slibert View Post
Hmmm - no joy. Performed steps A-D, and the robot still uses the "default" preference values. After restarting the robot, the Robot Preferences widget shows no values, and they didn't appear in the NetworkTables viewer either.

Was there anything in the TableViewer before restarting? Is there anything in the wpilib-preferences.ini file on the robot (you can FTP to the robot to retrieve it).

Quote:
We noted that smart dashboard doesn't prompt for any data type when adding a preference. I assume the smart dashboard is adding a string. If so, is there a problem because the dashboard-added string is not the same datatype that the robot code is expecting?

Perhaps we have to modify the robot code to only use strings, converting them ourselves to doubles/ints/etc within the robot code?
I've only looked at the java implementation, but C++ should be similar. Internally, everything is transmitted and stored as strings, and then the string is parsed and converted to the right format based on the type you specify in the get (eg int, float, boolean, string, etc). You shouldn't need to do that in your own code.

Are you using the latest C++ update from March 4th? There have been at least two bugs in the preferences class that have been fixed this year.
Reply With Quote
  #9   Spotlight this post!  
Unread 02-04-2013, 15:13
slibert slibert is offline
Software Mentor
AKA: Scott Libert
FRC #2465 (Kauaibots)
Team Role: Mentor
 
Join Date: Oct 2011
Rookie Year: 2005
Location: Kauai, Hawaii
Posts: 351
slibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud of
Re: Crio C++ Preferences -> How to See/Edit these values in the Smart Dashboard

We're still struggling to get the C++ Preferences class to actually save values to a file on the CRio. We've verified we're using the latest (3/4/2013) WPILibrary update and v47 of the Crio firmware.

Here's the robot startup code that populates the preferences:

*****

double steer_L_F_offset_angle = prefs->GetDouble("L_F_Steer_Offset_Angle", -126.0);
double steer_L_B_offset_angle = prefs->GetDouble("L_B_Steer_Offset_Angle", -70.0);
double steer_R_F_offset_angle = prefs->GetDouble("R_F_Steer_Offset_Angle", 170.0);
double steer_R_B_offset_angle = prefs->GetDouble("R_B_Steer_Offset_Angle", -140.0);

prefs->PutDouble("L_F_Steer_Offset_Angle", steer_L_F_offset_angle);
prefs->PutDouble("L_B_Steer_Offset_Angle", steer_L_B_offset_angle);
prefs->PutDouble("R_F_Steer_Offset_Angle", steer_R_F_offset_angle);
prefs->PutDouble("R_B_Steer_Offset_Angle", steer_R_B_offset_angle);

prefs->Save();

*****

- The Preference values, which are added by the robot at startup and are showing upon the Dashboard, show up in and can successfully be edited in the "Robot Preferences" control.
- We deleted the preferences file (wpilib-preferences.ini) on the robot and restarted the robot, and the file gets re-created by the robot startup code. However it still only has the [Preferences] header and no key/value entries in it.

The "PutDouble" code invoked by the robot startup code definitely populates the values into the NetworkTables (since they show up on the dashboard).

So in summary, since the Preferences class is actually re-creating a preferences file after we had previously deleted it, and is populating the NetworkTables, but no key/value pairs are written to the preferences file, it appears that the "PutDouble" code in the robot is *not* putting the values into the internal m_values table. We've also verified the string names of the variables being added to the Preferences are unique.
Reply With Quote
  #10   Spotlight this post!  
Unread 02-04-2013, 17:39
RufflesRidge RufflesRidge is offline
Registered User
no team
 
Join Date: Jan 2012
Location: USA
Posts: 989
RufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant future
Re: Crio C++ Preferences -> How to See/Edit these values in the Smart Dashboard

This is probably why:
http://firstforge.wpi.edu/sf/go/artf...3649387177 14
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 03:21.

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