SPQR-Team1-2020/include/drivecontroller.h

39 lines
830 B
C
Raw Normal View History

#pragma once
#include <Arduino.h>
#include "motor.h"
//PID Constants
#define KP 1.2
#define KI 0
#define KD 0.7
class DriveController{
public:
DriveController(Motor* m1_, Motor* m2_, Motor* m3_, Motor* m4_);
2019-11-13 16:26:03 +01:00
void drive(int dir, int speed, int tilt);
void prepareDrive(int dir, int speed, int tilt);
void drivePrepared();
float updatePid();
2019-11-18 14:37:55 +01:00
float torad(float f);
int vxp, vyp, vxn, vyn;
bool canUnlock;
elapsedMillis unlockTime;
private:
Motor* m1;
Motor* m2;
Motor* m3;
Motor* m4;
int pDir, pSpeed, pTilt;
float speed1, speed2, speed3, speed4, errorePre, integral, pidfactor, errorP, errorD, errorI, delta;
int vx, vy;
float sins[360], cosins[360];
};