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.
Controller.h
00001 /* 00002 * Controller.h 00003 * Copyright (c) 2018, 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 #include "Signal.h" 00016 00017 /** 00018 * This class implements the coordinate transformation, speed control and 00019 * the position estimation of a mobile robot with differential drive. 00020 */ 00021 class Controller { 00022 00023 public: 00024 00025 Controller(PwmOut& pwmLeft, PwmOut& pwmRight, EncoderCounter& counterLeft, EncoderCounter& counterRight); 00026 virtual ~Controller(); 00027 void setTranslationalVelocity(float velocity); 00028 void setRotationalVelocity(float velocity); 00029 float getActualTranslationalVelocity(); 00030 float getActualRotationalVelocity(); 00031 void setX(float x); 00032 float getX(); 00033 void setY(float y); 00034 float getY(); 00035 void setAlpha(float alpha); 00036 float getAlpha(); 00037 float getangleRight(); 00038 float getangleLeft(); 00039 void startMeasure(); 00040 00041 private: 00042 00043 static const uint32_t STACK_SIZE = 4096; // stack size of thread, given in [bytes] 00044 static const float PERIOD; 00045 static const float PI; 00046 static const float WHEEL_DISTANCE; 00047 static const float WHEEL_RADIUS; 00048 static const float COUNTS_PER_TURN; 00049 static const float LOWPASS_FILTER_FREQUENCY; 00050 static const float KN; 00051 static const float KP; 00052 static const float MAX_VOLTAGE; 00053 static const float MIN_DUTY_CYCLE; 00054 static const float MAX_DUTY_CYCLE; 00055 00056 PwmOut& pwmLeft; 00057 PwmOut& pwmRight; 00058 EncoderCounter& counterLeft; 00059 EncoderCounter& counterRight; 00060 Motion translationalMotion; 00061 Motion rotationalMotion; 00062 float translationalVelocity; 00063 float rotationalVelocity; 00064 float actualTranslationalVelocity; 00065 float actualRotationalVelocity; 00066 short previousValueCounterLeft; 00067 short previousValueCounterRight; 00068 LowpassFilter speedLeftFilter; 00069 LowpassFilter speedRightFilter; 00070 float desiredSpeedLeft; 00071 float desiredSpeedRight; 00072 float actualSpeedLeft; 00073 float actualSpeedRight; 00074 float actualAngleRight; 00075 float actualAngleLeft; 00076 float x; 00077 float y; 00078 float alpha; 00079 Signal signal; 00080 Thread thread; 00081 Ticker ticker; 00082 bool startMeasurement; 00083 00084 void sendSignal(); 00085 void run(); 00086 }; 00087 00088 #endif /* CONTROLLER_H_ */ 00089 00090
Generated on Tue Jul 26 2022 07:27:32 by
