Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Controller.h
00001 #ifndef CONTROLLER_H_ 00002 #define CONTROLLER_H_ 00003 #include <cstdlib> 00004 #include <mbed.h> 00005 #include "EncoderCounter.h" 00006 #include "LowpassFilter.h" 00007 00008 class Controller 00009 { 00010 00011 public: 00012 00013 Controller(PwmOut& pwmLeft, PwmOut& pwmRight, 00014 EncoderCounter& counterLeft, EncoderCounter& counterRight); 00015 00016 virtual ~Controller(); 00017 void setDesiredSpeedLeft(float desiredSpeedLeft); 00018 void setDesiredSpeedRight(float desiredSpeedRight); 00019 void AttachTicker(void); 00020 void DetachTicker(void); 00021 float getSpeedLeft(); 00022 float getSpeedRight(); 00023 float getIntegralLeft(); 00024 float getIntegralRight(); 00025 float getProportionalLeft(); 00026 float getProportionalRight(); 00027 00028 private: 00029 00030 static const float PERIOD; 00031 static const float COUNTS_PER_TURN; 00032 static const float LOWPASS_FILTER_FREQUENCY; 00033 static const float KN; 00034 static const float KP; 00035 static const float KI; 00036 static const float I_MAX; 00037 static const float MAX_VOLTAGE; 00038 static const float MIN_DUTY_CYCLE; 00039 static const float MAX_DUTY_CYCLE; 00040 00041 PwmOut& pwmLeft; 00042 PwmOut& pwmRight; 00043 EncoderCounter& counterLeft; 00044 EncoderCounter& counterRight; 00045 short previousValueCounterLeft; 00046 short previousValueCounterRight; 00047 LowpassFilter speedLeftFilter; 00048 LowpassFilter speedRightFilter; 00049 float desiredSpeedLeft; 00050 float desiredSpeedRight; 00051 float actualSpeedLeft; 00052 float actualSpeedRight; 00053 float iSumLeft; 00054 float iSumRight; 00055 Ticker ticker; 00056 00057 void run(); 00058 00059 }; 00060 00061 #endif /* CONTROLLER_H_ */ 00062 00063 00064 00065 00066 00067 00068
Generated on Fri Jul 15 2022 22:53:33 by
 1.7.2
 1.7.2