Go to Post Wishes and dreams can hold a robot together just as well as nuts and bolts. - Kyle [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

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Spotlight this post!  
Unread 20-02-2012, 01:02
bob.wolff68's Avatar
bob.wolff68 bob.wolff68 is offline
Da' Mentor Man
FRC #1967
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2007
Location: United States
Posts: 157
bob.wolff68 is just really nicebob.wolff68 is just really nicebob.wolff68 is just really nicebob.wolff68 is just really nicebob.wolff68 is just really nice
Re: Changing parameters on the fly?

Alright folks,

I've got answers....

Indeed - we agree that SmartDashboard::GetInstance()->GetDouble("name") does not work...however, we did find that GetString() **DOES** work. So, here's an iterative solution...

1) You **MUST** use the smartdashboard app on a separate computer due to the fact that hitting ENTER will disable the robot.

2) You must retrieve your "double values" as strings and then convert them to double/float values... see below...

3) When in operation, you simply tune your PID values by entering a new value into one of the boxes and hitting ENTER (on the 2nd laptop....see #1) and the new value will be put into the PIDController immediately so you can see the difference. When you're happy with the results, record your P,I, and D and put those into your real code. Tada.

Bob...

Code:
PIDController pid(0.00, 0.00, 0.00, &encoder, &motor);
SmartDashboard* smarty=SmartDashboard::GetInstance();
// Initially gotta put some value in order to get SmartDashboard 
// to create a textbox for the value...
// Simply calling GetString() will not produce a box...
smarty->PutString("P-value", "0.0");
smarty->PutString("D-value", "0.0");
smarty->PutString("D-value", "0.0");

std::string tempstring;
float p, i, d;

// Initialize the pid...these values I cannot tell you .... 
// They depend on your situation
pid.SetInputRange(.....);
pid.SetOutputRange(.....);
pid.SetSetpoint(.....);
pid.Enable();

while (IsOperatorControl())
{
  tempstring = smarty->GetString("P-value");
  sscanf(tempstring.c_str(), "%f", &p);

  tempstring = smarty->GetString("I-value");
  sscanf(tempstring.c_str(), "%f", &i);

  tempstring = smarty->GetString("D-value");
  sscanf(tempstring.c_str(), "%f", &d);

  pid.SetPID(p, i, d);
}
__________________
~~~~~~~~~~~~~~~~~~~
Bob Wolff - Software from the old-school
Mentor / C / C++ guy
Team 1967 - The Janksters - San Jose, CA
Reply With Quote
 


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 12:38.

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