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.
Fork of PES1 by
Roboter.h
00001 #ifndef ROBOTER_H 00002 #define ROBOTER_H 00003 00004 #include <mbed.h> 00005 #include "IRSensor.h" 00006 #include "Servo.h" 00007 #include "readCamera.h" 00008 #include "EncoderCounter.h" 00009 #include "LowpassFilter.h" 00010 00011 00012 class Roboter 00013 { 00014 00015 public: 00016 00017 Roboter(AnalogIn* distance, DigitalOut* bit0, DigitalOut* bit1, DigitalOut* bit2, PwmOut* pwmL, PwmOut* pwmR, Servo* servo1, Servo* servo2, EncoderCounter* counterLeft, EncoderCounter* counterRight, DigitalOut* enableMotorDriver); 00018 00019 void ausweichen1(); 00020 int ausweichen2(); 00021 int readSensors(); 00022 int pickup(); 00023 void anfahren(float cam); 00024 int geradeFahren(); 00025 int kreisFahren(); 00026 int stateAuswahl(float cam, int tempState, int temp); 00027 void initSpeedcontrol(); 00028 void speedCtrl(); 00029 int back(); 00030 00031 00032 00033 static const float PERIOD = 0.001f; // period of control task, given in [s] 00034 static const float COUNTS_PER_TURN = 1200.0f; // resolution of encoder counter 00035 static const float LOWPASS_FILTER_FREQUENCY = 300.0f; // frequency of lowpass filter for actual speed values, given in [rad/s] 00036 static const float KN = 40.0f; // speed constant of motor, given in [rpm/V] 00037 static const float KP = 0.2f; // speed controller gain, given in [V/rpm] 00038 static const float MAX_VOLTAGE = 12.0f; // supply voltage for power stage in [V] 00039 static const float MIN_DUTY_CYCLE = 0.02f; // minimum allowed value for duty cycle (2%) 00040 static const float MAX_DUTY_CYCLE = 0.98f; // maximum allowed value for duty cycle (98%) 00041 static const float correction = 0.97f; // Korrekturfaktor für speedControl 00042 static const float v = 30.0f; // Min. Geschw. 00043 00044 00045 private: 00046 00047 IRSensor sensors[6]; 00048 00049 PwmOut* pwmL; 00050 PwmOut* pwmR; 00051 Servo* servo1; 00052 Servo* servo2; 00053 00054 //speed control------------------ 00055 00056 EncoderCounter* counterRight; 00057 EncoderCounter* counterLeft; 00058 DigitalOut* enableMotorDriver; 00059 00060 short previousValueCounterRight; 00061 short previousValueCounterLeft; 00062 00063 float desiredSpeedLeft; 00064 float desiredSpeedRight; 00065 00066 float actualSpeedLeft; 00067 float actualSpeedRight; 00068 00069 LowpassFilter speedLeftFilter; 00070 LowpassFilter speedRightFilter; 00071 00072 Ticker t1; 00073 00074 //speed control------------------ 00075 00076 }; 00077 00078 #endif
Generated on Wed Jul 20 2022 10:49:35 by
1.7.2
