|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
Changing parameters on the fly?
Does anyone know a slick way of changing some parameters on the fly. My wife is going to attempt to tune our PID routines we have setup with crumby default values; and I want to avoid modifying a #define in code and redeploying 80 times in a day.
I've thought about attempting fopen or something like that, but that still requires me to filezilla something down there ( or SSH/terminal somehow into the robot) If the fopen is on the right track, I'm not quite sure how I go about cracking into the robot, so a link to a guide or some instructions for that would be awesome. Are there any sneaky methods that we could use from the driver station maybe? Thanks in advance! ![]() |
|
#2
|
||||
|
||||
|
Re: Changing parameters on the fly?
Quote:
Crude, but simple and effective. Each time you bump a button, display the actual value on your driver station so you know where you're at. |
|
#3
|
|||
|
|||
|
Re: Changing parameters on the fly?
Thanks, for the idea; however over dinner I realized what I think I should do is simply debug the robot, and set watches on P,I,D temp values that get loaded each time the PID starts, and set a breakpoint, so I can modify the values from the debugger and resume.
answered my own question. |
|
#4
|
|||
|
|||
|
Re: Changing parameters on the fly?
Yeah I've been in the same situation, and idealy I'd like to use the smart dashboard to set the values like:
Code:
examplemotor->Set(SmartDashboard::GetInstance()->GetDouble("examplekeyname");
|
|
#5
|
||||
|
||||
|
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);
}
|
|
#6
|
||||
|
||||
|
Re: Changing parameters on the fly?
The shell provided for the operating system is really a C interpreter. So you can define a global in your code then simply change its value from the command line.
in your C++ code: extern "C" { float iMyPidGain; } then from the VxWorks shell: % iMyPidGain = 0.001 Last edited by wireties : 02-20-2012 at 01:44 AM. |
|
#7
|
||||
|
||||
|
Re: Changing parameters on the fly?
Keith,
Are you talking about the terminal console via the VxWorks menu (ie. Netconsole output) ?? I've never heard of this...can you point to some documentation on it? bob |
|
#8
|
||||
|
||||
|
Re: Changing parameters on the fly?
Quote:
Help->Help Contents->Wind River Documentation->Guides->Host Tools->Wind River Workbench Host Shell Users Guide->Part 1->Using C Interpreter with VxWorks 6.X |
|
#9
|
||||
|
||||
|
Re: Changing parameters on the fly?
This is really big news that I believe VERY few people know of...if I have 'external' access (on the fly) to my program's variables in an interpretive way, well...the possibilities are HUGE.
I'll be trying this with my programmers tomorrow for sure! bob - Team 1967 Mentor - The Janksters |
|
#10
|
||||
|
||||
|
Re: Changing parameters on the fly?
Quote:
We use this all the time: to turn on/off the collection of data, play with operating params (like PID constants), enable/disable features while debugging etc. It definitely works! Good luck! |
|
#11
|
|||
|
|||
|
Re: Changing parameters on the fly?
I personally use LV, so this problem is trivial for us, but would it be possible to have a CSV file stored on the robot that it reads from? So that if you modify the values, it's behavior will change?
|
|
#12
|
||||
|
||||
|
Re: Changing parameters on the fly?
Quote:
Code:
in your C++ code:
extern "C" {
typedef struct _PIDConst
{
float Kp;
float Ki;
float Kd;
} PIDConst;
PIDConst iMyPidGain;
}
then from the VxWorks shell:
% iMyPidGain.Kp = 0.001
|
|
#13
|
|||
|
|||
|
Re: Changing parameters on the fly?
Is there any other way to do this without having to have a second computer? It would not be ideal to have to laptops running at the operator's console...
|
|
#14
|
||||
|
||||
|
Re: Changing parameters on the fly?
It is possible to save data to a text file on the cRIO,
and to read it back. Team 1425 has done this in the past. Having a robot ability to update tunable parameters without firing up WindRiver workbench is a great time saver. This works wonders when you need to calibrate some component that is likely to get adjusted during normal maintenance and repair during competition. I'm currently trying to get the team I'm working with in MN (3765) to recreate this. The neat thing about creating ascii based files is that you can use external tools to view them. Last night I was showing the team how you can use the robot's built in FTP server to look at the file system on the cRIO. We looked at the system install files and noted the changes and deletions that happen when code is deployed and undeployed from workbench. We also used the ftp server to create a team data directory on the robot as a location to create our persistent data files. On a PC that is connected to your team's robot, you can use ftp to browse the robot's file system by opening a web browser and using the URL: ftp://10.XX.YY.2/ 10.XX.YY.2 being the standard FIRST defined IP address for your robot. Note that the protocol part of the URL is ftp - not http like you see during regular web browsing. This will give you a file listing of the root of the robot file system, and you can browse down into the various sub-directories. The web browser is a good place to start since it gives a read-only view of the file system. You want to be sure that you don't modify any of the existing files there, without fully understanding the consequences. |
|
#15
|
||||
|
||||
|
Re: Changing parameters on the fly?
We ftp text files to the robot and read them all the time. Our autonomous behavior is implemented with a special script language.
HTH |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|