TRR 2018 / Mbed 2 deprecated biniou-TRR2019-DLVV

Dependencies:   mbed MPU6050

Revision:
12:58ad06f9847d
Parent:
9:1b54bac6d9a7
--- a/sm_esc.cpp	Fri Oct 04 09:58:51 2019 +0000
+++ b/sm_esc.cpp	Fri Oct 04 22:20:23 2019 +0000
@@ -1,5 +1,6 @@
 #include "sm_esc.h"
 #include "sm_sections.h"
+#include "sm_servo.h"
 
 PwmOut pwm_ESC(PD_12);
 DigitalOut relay_ESC(PG_0);
@@ -42,7 +43,7 @@
     switch(e_ESC_state) {
         case ESC_DISABLED:
             if(b_UTILS_flag_emergency_stop) {
-                rs_LOG_pc.printf("EMERGENCY STOP\r\n");
+                rs_LOG.printf("EMERGENCY STOP\r\n");
                 b_UTILS_flag_emergency_stop = false;
                 if(b_CHASSIS_with_pushbutton) {
                     relay_ESC = 1;
@@ -53,7 +54,7 @@
             break;
 
         case ESC_INIT:
-            rs_LOG_pc.printf("Init esc\r\n");
+            rs_LOG.printf("Init esc\r\n");
             b_UTILS_flag_button_ESC = false;
             pwm_ESC.period_ms(ESC_PERIOD_DURATION_MS);          //20 ms is default
             pwm_ESC.pulsewidth_us(0);
@@ -71,13 +72,13 @@
             wait(1);
             pwm_ESC.pulsewidth_us(ESC_PULSE_IDLE_US);
             wait(1);
-            log_start(10000);
+            log_start(120000);
             break;
 
         case ESC_COMMAND:
             switch(e_SECTIONS_state) {
                 case RUNNING_SECTION:
-                    pwm_ESC.pulsewidth_us(s_UTILS_currentSection->targetSpeed_mps);
+                    pwm_ESC.pulsewidth_us(s_UTILS_currentSection->targetSpeed_mps - (d_SERVO_coefFreinage*s_UTILS_currentSection->plagePulseFreinage));
                     break;
                 case STOPPED:
                     break;