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 /* 00002 * Controller.h 00003 * Copyright (c) 2020, ZHAW 00004 * All rights reserved. 00005 */ 00006 00007 #ifndef CONTROLLER_H_ 00008 #define CONTROLLER_H_ 00009 00010 #include <cstdlib> 00011 #include <mbed.h> 00012 #include "EncoderCounter.h" 00013 #include "Motion.h" 00014 #include "LowpassFilter.h" 00015 00016 /** 00017 * This class implements a controller that regulates the 00018 * speed of the two motors of the ROME2 mobile robot. 00019 */ 00020 class Controller { 00021 00022 public: 00023 00024 Controller(PwmOut& pwmLeft, PwmOut& pwmRight, EncoderCounter& counterLeft, EncoderCounter& counterRight); 00025 virtual ~Controller(); 00026 void setTranslationalVelocity(float velocity); 00027 void setRotationalVelocity(float velocity); 00028 float getActualTranslationalVelocity(); 00029 float getActualRotationalVelocity(); 00030 void setDesiredSpeedLeft(float desiredSpeedLeft); 00031 void setDesiredSpeedRight(float desiredSpeedRight); 00032 float getActualSpeedLeft(); 00033 float getActualSpeedRight(); 00034 void setX(float x); 00035 float getX(); 00036 void setY(float y); 00037 float getY(); 00038 void setAlpha(float alpha); 00039 float getAlpha(); 00040 00041 private: 00042 00043 static const float PERIOD; 00044 static const float PI; 00045 static const float WHEEL_DISTANCE; 00046 static const float WHEEL_RADIUS; 00047 static const float COUNTS_PER_TURN; 00048 static const float LOWPASS_FILTER_FREQUENCY; 00049 static const float KN; 00050 static const float KP; 00051 static const float MAX_VOLTAGE; 00052 static const float MIN_DUTY_CYCLE; 00053 static const float MAX_DUTY_CYCLE; 00054 00055 PwmOut& pwmLeft; 00056 PwmOut& pwmRight; 00057 EncoderCounter& counterLeft; 00058 EncoderCounter& counterRight; 00059 Motion translationalMotion; 00060 Motion rotationalMotion; 00061 float translationalVelocity; 00062 float rotationalVelocity; 00063 float actualTranslationalVelocity; 00064 float actualRotationalVelocity; 00065 short previousValueCounterLeft; 00066 short previousValueCounterRight; 00067 LowpassFilter speedLeftFilter; 00068 LowpassFilter speedRightFilter; 00069 float desiredSpeedLeft; 00070 float desiredSpeedRight; 00071 float actualSpeedLeft; 00072 float actualSpeedRight; 00073 float x; 00074 float y; 00075 float alpha; 00076 Ticker ticker; 00077 00078 void run(); 00079 }; 00080 00081 #endif /* CONTROLLER_H_ */ 00082
Generated on Wed Jul 20 2022 03:42:12 by
