From 8a57f4b8767b0534bf406137cfe636c954a974e2 Mon Sep 17 00:00:00 2001 From: Fisch Date: Fri, 6 Aug 2021 16:25:43 +0200 Subject: [PATCH] faster reverse driving --- controller_teensy/src/main.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/controller_teensy/src/main.cpp b/controller_teensy/src/main.cpp index 1a4647e..203057e 100644 --- a/controller_teensy/src/main.cpp +++ b/controller_teensy/src/main.cpp @@ -58,6 +58,9 @@ unsigned long brake_ok_time=0; bool error_throttle_outofrange=false; bool error_brake_outofrange=false; +#define REVERSE_ENABLE_TIME 1000 //ms. how long standstill to be able to drive backward +#define REVERSE_SPEED 0.15 //reverse driving speed //0 to 1 + #define NORMAL_MAX_ACCELERATION_RATE 10000 #define SLOW_MAX_ACCELERATION_RATE 500 int16_t max_acceleration_rate=NORMAL_MAX_ACCELERATION_RATE; //maximum cmd send increase per second @@ -433,7 +436,7 @@ void readADC() { last_notidle=loopmillis; reverse_enabled=false; } - #define REVERSE_ENABLE_TIME 1000 + if (loopmillis-last_notidle > REVERSE_ENABLE_TIME) { reverse_enabled=true; } @@ -566,8 +569,9 @@ void sendCMD() { int16_t cmd_send_toMotor=constrain(cmd_send* (1.0-(brake_pos*0.5/1000.0) ) ,0,1000); //brake "ducking" + if (reverse_enabled) { - cmd_send_toMotor-=brake_pos*0.1; + cmd_send_toMotor-=brake_pos*REVERSE_SPEED; } if (!controllers_connected || !armed) { //controllers not connected or not armed @@ -588,12 +592,11 @@ void sendCMD() { log_update=true; //Serial.print(cmd_send); Serial.print(", "); Serial.print(throttle_pos); Serial.print(", "); Serial.print(filtered_curFL*1000); Serial.print(", "); Serial.print(filtered_curFR*1000); Serial.print(", "); Serial.print(filtered_currentAll*1000); Serial.println() - }else if(loopmillis>last_log_send+LOGMININTERVAL){ + }/*else if(loopmillis>last_log_send+LOGMININTERVAL){ //Serial.print(throttle_raw); Serial.println(); - Serial.print(linearizeThrottle(throttle_raw)); Serial.println(); last_log_send=loopmillis; - } + }*/ }