diff --git a/include/moveControl.h b/include/moveControl.h index deffcad..14333cc 100644 --- a/include/moveControl.h +++ b/include/moveControl.h @@ -5,7 +5,7 @@ #include #include "motorControl.h" -#include "speedometer" +#include "speedometer.h" #include "config.h" #include "debugMqtt.h" #include "debugTimes.h" diff --git a/include/route.h b/include/route.h index f208657..95481e3 100644 --- a/include/route.h +++ b/include/route.h @@ -6,8 +6,8 @@ #include #include -#include "hardware/motorControl.h" -#include "hardware/speedometer.h" +#include "motorControl.h" +#include "speedometer.h" #include "debugMqtt.h" #include "config.h" diff --git a/lib/Hardware/Illumination/underfloorLighting.cpp b/lib/Illumination/underfloorLighting.cpp similarity index 100% rename from lib/Hardware/Illumination/underfloorLighting.cpp rename to lib/Illumination/underfloorLighting.cpp diff --git a/lib/Hardware/Illumination/underfloorLighting.h b/lib/Illumination/underfloorLighting.h similarity index 100% rename from lib/Hardware/Illumination/underfloorLighting.h rename to lib/Illumination/underfloorLighting.h diff --git a/lib/Debug/MQTT/debugMqtt.cpp b/lib/MQTT/debugMqtt.cpp similarity index 100% rename from lib/Debug/MQTT/debugMqtt.cpp rename to lib/MQTT/debugMqtt.cpp diff --git a/lib/Debug/MQTT/debugMqtt.h b/lib/MQTT/debugMqtt.h similarity index 100% rename from lib/Debug/MQTT/debugMqtt.h rename to lib/MQTT/debugMqtt.h diff --git a/lib/Hardware/MotorControl/motorControl.cpp b/lib/MotorControl/motorControl.cpp similarity index 97% rename from lib/Hardware/MotorControl/motorControl.cpp rename to lib/MotorControl/motorControl.cpp index 399455f..86fefb2 100644 --- a/lib/Hardware/MotorControl/motorControl.cpp +++ b/lib/MotorControl/motorControl.cpp @@ -94,14 +94,14 @@ void MotorControl::runMotorControl() { void MotorControl::setMinPwm(uint8_t min) { if (min > 80) min = 80; //transform percentage to real pwm value - min = (uint8_t) ((1 >> pwm_res - 1) * (min / 100)); + min = (uint8_t) (((1 >> pwm_res) - 1) * (min / 100)); this->dutycycle_min = min; } void MotorControl::setMaxPwm(uint8_t max) { if (max > 100) max = 100; //transform percentage to real pwm value - max = (uint8_t) ((1 >> pwm_res - 1) * (max / 100)); + max = (uint8_t) (((1 >> pwm_res) - 1) * (max / 100)); this->dutycycle_max = max; } diff --git a/lib/Hardware/MotorControl/motorControl.h b/lib/MotorControl/motorControl.h similarity index 100% rename from lib/Hardware/MotorControl/motorControl.h rename to lib/MotorControl/motorControl.h diff --git a/lib/Hardware/Speedometer/speedometer.cpp b/lib/Speedometer/speedometer.cpp similarity index 100% rename from lib/Hardware/Speedometer/speedometer.cpp rename to lib/Speedometer/speedometer.cpp diff --git a/lib/Hardware/Speedometer/speedometer.h b/lib/Speedometer/speedometer.h similarity index 96% rename from lib/Hardware/Speedometer/speedometer.h rename to lib/Speedometer/speedometer.h index 901651f..859bf90 100644 --- a/lib/Hardware/Speedometer/speedometer.h +++ b/lib/Speedometer/speedometer.h @@ -25,7 +25,7 @@ * @brief Default value for min Millisseconds between each loop * @see setDelay(uint8_t val) */ -#define DELAY 30 +#define DELAY_SPEEDOMETER 30 #define PI 3.1415926535897932384626433832795 /** @@ -57,7 +57,7 @@ class Speedometer { * This function should be called every mainloop. If the delay is not reached, than the * functions returns immediately. * @see runSpeedometer() - * @see DELAY + * @see DELAY_SPEEDOMETER */ void loop(); @@ -112,7 +112,7 @@ class Speedometer { uint8_t bufSize = BUFSIZE; uint16_t steps; - uint8_t delay = DELAY; + uint8_t delay = DELAY_SPEEDOMETER; int16_t *buf; }; diff --git a/lib/Debug/Times/debugTimes.cpp b/lib/Times/debugTimes.cpp similarity index 100% rename from lib/Debug/Times/debugTimes.cpp rename to lib/Times/debugTimes.cpp diff --git a/lib/Debug/Times/debugTimes.h b/lib/Times/debugTimes.h similarity index 100% rename from lib/Debug/Times/debugTimes.h rename to lib/Times/debugTimes.h diff --git a/src/driveModi/consolControl.cpp b/src/driveModi/consolControl.cpp index bf0e149..6faad56 100644 --- a/src/driveModi/consolControl.cpp +++ b/src/driveModi/consolControl.cpp @@ -1,5 +1,4 @@ #include "consolControl.h" -#include ConsolControl::ConsolControl() { this->debug = new DebugMqtt("ConsolControl"); diff --git a/src/driveModi/consolControl.h b/src/driveModi/consolControl.h index af37926..2f673a9 100644 --- a/src/driveModi/consolControl.h +++ b/src/driveModi/consolControl.h @@ -1,6 +1,8 @@ #ifndef CONSOL_CONTROL_H #define CONSOL_CONTROL_H +#include + #include "moveControl.h" #include "debugMqtt.h" diff --git a/src/driveModi/manualControl.cpp b/src/driveModi/manualControl.cpp index ec6debc..ebc2f1e 100644 --- a/src/driveModi/manualControl.cpp +++ b/src/driveModi/manualControl.cpp @@ -15,8 +15,6 @@ void ManualControl::init(MoveControl *moveControl, MotorControl *motorControlLef } void ManualControl::runManualControl() { - DebugTimes runManualDebuginFunction; - //Cancel if delay is not reached if (millis() - this->last_millis < RUN_MANUALCONTROL_DELAY) { return; @@ -29,8 +27,6 @@ void ManualControl::runManualControl() { } this->last_millis = millis(); - runManualDebuginFunction.stop("Ober teil von runManualControl", 100); - //Change controlMode if (this->controlMode == ControMode::halt && Ps3.data.button.l3) { this->reset(); diff --git a/src/driveModi/manualControl.h b/src/driveModi/manualControl.h index 89feff8..9cdc4ea 100644 --- a/src/driveModi/manualControl.h +++ b/src/driveModi/manualControl.h @@ -4,7 +4,7 @@ #include #include "moveControl.h" -#include "hardware/motorControl.h" +#include "motorControl.h" #include "debugMqtt.h" #include "debugTimes.h" diff --git a/src/main.cpp b/src/main.cpp index c7792a9..df220ff 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -6,8 +6,8 @@ #include "config.h" -#include "hardware/motorControl.h" -#include "hardware/speedometer.h" +#include "motorControl.h" +#include "speedometer.h" #include "driveModi/autopilot.h" #include "driveModi/captureRoute.h" #include "driveModi/manualControl.h" @@ -82,7 +82,6 @@ void setup() { configTime(3600, 3600, "2.de.pool.ntp.org"); DebugMqtt::init(&mqtt_client, Loglevel::debug); - DebugMqtt::initRealMillis(); Ps3.attach(callbackControllerAction); Ps3.attachOnConnect(callbackControllerConnect); @@ -91,11 +90,11 @@ void setup() { Ps3.begin(); // Init hardware - left_motor.init(M_PWM_1, PWM_CHANNEL_M1, M_DIR_11, M_DIR_12, "left"); - right_motor.init(M_PWM_2, PWM_CHANNEL_M2, M_DIR_21, M_DIR_22, "right"); + left_motor.init(M_PWM_1, PWM_CHANNEL_M1, M_DIR_11, M_DIR_12); + right_motor.init(M_PWM_2, PWM_CHANNEL_M2, M_DIR_21, M_DIR_22); - speedometer_left.init(M_ENCODE_1A, M_ENCODE_1B, "left"); - speedometer_right.init(M_ENCODE_2A, M_ENCODE_2B, "right"); + speedometer_left.init(M_ENCODE_1A, M_ENCODE_1B, WHEEL_DIAMETER, ENC_STEPS); + speedometer_right.init(M_ENCODE_2A, M_ENCODE_2B, WHEEL_DIAMETER, ENC_STEPS); moveController.init(&left_motor, &right_motor, &speedometer_left, &speedometer_right); @@ -104,11 +103,6 @@ void setup() { captureRoute.init(&route, &moveController, &left_motor, &right_motor); autopilot.init(&route, &moveController); consolControl.init(&moveController); - - //Test checkTimes function - DebugTimes testDebugTimes; - delay(2); - testDebugTimes.stop("Test checkTimes"); } void loop() { @@ -125,18 +119,11 @@ void loop() { } } else { // Client connected - DebugTimes mqttClientLoop; mqtt_client.loop(); - mqttClientLoop.stop("mqttloop", 100); } - - DebugTimes runMotorLeft; + left_motor.runMotorControl(); - runMotorLeft.stop("left_motor", 100); - - DebugTimes runMotorRight; right_motor.runMotorControl(); - runMotorRight.stop("right_motor", 100); speedometer_left.runSpeedometer(); speedometer_right.runSpeedometer(); @@ -144,11 +131,8 @@ void loop() { // route.runRoute(); switch (driveMode) { - case manualControl_e: { - DebugTimes manControlDebug; + case manualControl_e: manualControl.runManualControl(); - manControlDebug.stop("manualControl run", 100); - } break; case captureRoute_e: diff --git a/src/moveControl.cpp b/src/moveControl.cpp index aa58239..8ec4bc7 100644 --- a/src/moveControl.cpp +++ b/src/moveControl.cpp @@ -47,11 +47,11 @@ void MoveControl::runMoveControl() { DebugTimes pidTimes; this->right_pid->Compute(); this->left_pid->Compute(); - pidTimes.stop("PID Calulate", 100); + pidTimes.stopConsol("PID Calulate", 100); DebugTimes regMotorTime; this->regulateMotors(); - regMotorTime.stop("regulateMotors", 100); + regMotorTime.stopConsol("regulateMotors", 100); static uint32_t functioncalls = 0; functioncalls++; @@ -62,7 +62,7 @@ void MoveControl::runMoveControl() { this->wheelspeed_right); DebugTimes debugMsgTime; debug->sendMsg(Loglevel::debug, str); - debugMsgTime.stop("debug Msg", 100); + debugMsgTime.stopConsol("debug Msg", 100); } }