From 049b0c18305b800734c01f03cb8c63f302a7ca8a Mon Sep 17 00:00:00 2001 From: EmaMaker Date: Thu, 5 Dec 2019 12:51:23 +0100 Subject: [PATCH] lines now working: angle of each motor was est to 0 in constructor --- src/drivecontroller.cpp | 4 ++++ src/ds_ctrl_lines.cpp | 10 +++++----- src/main.cpp | 2 +- src/motor.cpp | 2 -- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/drivecontroller.cpp b/src/drivecontroller.cpp index 6d1d526..af2653d 100644 --- a/src/drivecontroller.cpp +++ b/src/drivecontroller.cpp @@ -28,6 +28,10 @@ DriveController::DriveController(Motor* m1_, Motor* m2_, Motor* m3_, Motor* m4_) errorP = 0; errorI = 0; errorD = 0; + + errorePre = 0; + pidfactor = 0; + integral = 0; } void DriveController::prepareDrive(int dir, int speed, int tilt){ diff --git a/src/ds_ctrl_lines.cpp b/src/ds_ctrl_lines.cpp index c3672c4..f973b5c 100644 --- a/src/ds_ctrl_lines.cpp +++ b/src/ds_ctrl_lines.cpp @@ -50,7 +50,7 @@ void DataSourceCtrlLines::read(){ } void DataSourceCtrlLines::postProcess(){ - if ((inV > 0) || (outV > 0)) { + if ((inV > 0) || (outV > 0)) { fboundsOX = true; fboundsOY = true; if(exitTimer > EXTIME) { @@ -64,7 +64,7 @@ void DataSourceCtrlLines::postProcess(){ } void DataSourceCtrlLines::outOfBounds(){ - //handleExtern(); + handleExtern(); handleIntern(); } @@ -144,8 +144,8 @@ void DataSourceCtrlLines::handleIntern(){ break; } - if(exitTimer < 45) outVel = 200; - else outVel = 150; + if(exitTimer < 45) outVel = 350; + else outVel = 330; drive->prepareDrive(outDir, outVel, 0); // keeper_backToGoalPost = true; // keeper_tookTimer = true; @@ -154,7 +154,7 @@ void DataSourceCtrlLines::handleIntern(){ inVOldX = 0; inVOldY = 0; // lineSensByteBak = 30; - //drive->canUnlock = true; + drive->canUnlock = true; } // lineSensByteBak = linesensbyteI; diff --git a/src/main.cpp b/src/main.cpp index 77614af..4c8fd4f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -11,12 +11,12 @@ void setup() { delay(2000); } + void loop() { updateSensors(); drive->prepareDrive(0,0,0); linesCtrl->update(); - drive->drivePrepared(); } diff --git a/src/motor.cpp b/src/motor.cpp index 0bf5f13..ccdf0ec 100644 --- a/src/motor.cpp +++ b/src/motor.cpp @@ -11,8 +11,6 @@ Motor::Motor(int a, int b, int pwm, int angle_){ pinMode(pinA, OUTPUT); pinMode(pinB, OUTPUT); pinMode(pinPwm, OUTPUT); - - angle = 0; } Motor::Motor(){ }