Made PIDController use pthreads in C++

Change-Id: I3d4d1aa912bf56faa1d5e150732da5e7b551077d
This commit is contained in:
thomasclark
2014-06-05 11:32:49 -04:00
parent 36470d3b7c
commit c937c409ae
2 changed files with 209 additions and 210 deletions

View File

@@ -6,9 +6,9 @@
#pragma once
#include "Base.h"
#include "HAL/Semaphore.hpp"
#include "Controller.h"
#include "LiveWindow/LiveWindow.h"
#include <pthread.h>
class PIDOutput;
class PIDSource;
@@ -69,6 +69,7 @@ private:
float m_minimumInput; // minimum input - limit setpoint to this
bool m_continuous; // do the endpoints wrap around? eg. Absolute encoder
bool m_enabled; //is the pid controller enabled
bool m_destruct; // should the calculate thread stop running
float m_prevError; // the prior sensor input (used to compute velocity)
double m_totalError; //the sum of the errors for use in the integral calc
enum
@@ -83,15 +84,15 @@ private:
float m_result;
float m_period;
MUTEX_ID m_semaphore;
PIDSource *m_pidInput;
PIDOutput *m_pidOutput;
Notifier *m_controlLoop;
pthread_t m_controlLoop;
pthread_mutex_t m_mutex;
void Initialize(float p, float i, float d, float f, PIDSource *source, PIDOutput *output,
float period = 0.05);
static void CallCalculate(void *controller);
static void *CallCalculate(void *controller);
virtual ITable* GetTable();
virtual std::string GetSmartDashboardType();