Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   C/C++ (http://www.chiefdelphi.com/forums/forumdisplay.php?f=183)
-   -   SmartDashboard - PID Editor Crashes C++ CRio Code (http://www.chiefdelphi.com/forums/showthread.php?t=115138)

slibert 18-03-2013 14:12

SmartDashboard - PID Editor Crashes C++ CRio Code
 
Via LiveWindow and the SmartDashboard, we are able to successfully edit the P value of our swerve drive subsystem code. We are currently tuning the PIDs linking our angle sensors to our steeringmotors.

However, whenever we edit the I or D values in the Smart Dashboard (the instant we change focus away from these controls), the robot crashes.

Source Code which demonstrates the problem is at:

Swerve Drive Code

http://code.google.com/p/kauaibotsfi...riveSystem.cpp

Angle Sensor Code

http://code.google.com/p/kauaibotsfi...ngleSensor.cpp

If anyone has any ideas as to how to resolve this, we would greatly appreciate it. The promise of LiveWindow to accelerate our PID tuning progress is tantalizing, but seemingly unreachable, to us....

slibert 20-03-2013 16:58

Re: SmartDashboard - PID Editor Crashes C++ CRio Code
 
In case this is helpful to others, we've found a workaround:

1) Copy WPILibrary PIDController.cpp/.h into our project.
2) Add new "internal" SetP, SetI, SetD, SetF methods to PIDController.h/.cpp
3) Modify the PIDController::ValueChanged method as follows (commented out code is the WPILib implementation that seems to be causing problems, although we're not sure why):

void PIDController::ValueChanged(ITable* source, const std::string& key, EntryValue value, bool isNew){
/*if (key==kP || key==kI || key==kD || key==kF) {
if (m_P != m_table->GetNumber(kP) || m_I != m_table->GetNumber(kI) || m_D != m_table->GetNumber(kD) || m_F != m_table->GetNumber(kF) ) {
SetPID(m_table->GetNumber(kP, 0.0), m_table->GetNumber(kI, 0.0), m_table->GetNumber(kD, 0.0), m_table->GetNumber(kF, 0.0));
}*/
if (key==kP && m_P != value.f) {
SetP(value.f);
} else if (key==kI && m_I != value.f) {
SetI(value.f);
} else if (key==kD && m_D != value.f) {
SetD(value.f);
} else if (key==kF && m_F != value.f) {
SetF(value.f);
} else if (key==kSetpoint && m_setpoint != value.f) {
SetSetpoint(value.f);
} else if (key==kEnabled && m_enabled != value.b) {
if (value.b) {
Enable();
} else {
Disable();
}
}
}


All times are GMT -5. The time now is 12:50.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi