TRR 2018 / Mbed 2 deprecated biniou-TRR2019-DLVV

Dependencies:   mbed MPU6050

Committer:
GaspardD
Date:
Fri Oct 04 09:46:00 2019 +0000
Revision:
10:e63fe4080760
Parent:
9:1b54bac6d9a7
Child:
11:2156cb77d0d6
ca marche

Who changed what in which revision?

UserRevisionLine numberNew contents of line
GaspardD 9:1b54bac6d9a7 1 #include "log.h"
GaspardD 9:1b54bac6d9a7 2
GaspardD 9:1b54bac6d9a7 3 Timer t_loggingTimer;
GaspardD 9:1b54bac6d9a7 4 int i_logging_duration;
GaspardD 9:1b54bac6d9a7 5 bool b_LOG_READY = false;
GaspardD 10:e63fe4080760 6 Serial rs_LOG_pc(USBTX, USBRX,9600);
GaspardD 10:e63fe4080760 7 //Serial rs_LOG_odroid(PC_10, PC_11,115200);
GaspardD 9:1b54bac6d9a7 8
GaspardD 9:1b54bac6d9a7 9
GaspardD 9:1b54bac6d9a7 10 s_Sample s_LOG_history[LOG_SIZE];
GaspardD 9:1b54bac6d9a7 11 int i_LOG_index_data = 0;
GaspardD 9:1b54bac6d9a7 12 bool b_LOG_flag = false;
GaspardD 9:1b54bac6d9a7 13
GaspardD 9:1b54bac6d9a7 14 void log_start(int duration_ms)
GaspardD 9:1b54bac6d9a7 15 {
GaspardD 9:1b54bac6d9a7 16 b_LOG_flag = true;
GaspardD 9:1b54bac6d9a7 17 b_LOG_READY = false;
GaspardD 9:1b54bac6d9a7 18 t_loggingTimer.start();
GaspardD 9:1b54bac6d9a7 19 i_logging_duration = duration_ms;
GaspardD 9:1b54bac6d9a7 20 t_loggingTimer.reset();
GaspardD 9:1b54bac6d9a7 21 }
GaspardD 9:1b54bac6d9a7 22
GaspardD 9:1b54bac6d9a7 23 void log_check()
GaspardD 9:1b54bac6d9a7 24 {
GaspardD 10:e63fe4080760 25 if(t_loggingTimer.read_ms() > i_logging_duration || i_LOG_index_data >= LOG_SIZE) {
GaspardD 9:1b54bac6d9a7 26 b_LOG_READY = true;
GaspardD 9:1b54bac6d9a7 27 b_LOG_flag = false;
GaspardD 9:1b54bac6d9a7 28 t_loggingTimer.stop();
GaspardD 9:1b54bac6d9a7 29 t_loggingTimer.reset();
GaspardD 9:1b54bac6d9a7 30 }
GaspardD 9:1b54bac6d9a7 31 if(b_LOG_flag && i_LOG_index_data < LOG_SIZE) {
GaspardD 10:e63fe4080760 32 i_LOG_index_data ++;
GaspardD 10:e63fe4080760 33 rs_LOG_pc.printf("i_LOG_index_data:%d\r\n",i_LOG_index_data);
GaspardD 9:1b54bac6d9a7 34 }
GaspardD 10:e63fe4080760 35
GaspardD 9:1b54bac6d9a7 36 }
GaspardD 9:1b54bac6d9a7 37 void log_pc()
GaspardD 9:1b54bac6d9a7 38 {
GaspardD 9:1b54bac6d9a7 39 rs_LOG_pc.printf("timestamp;left_90;right_90;left_45;right_45;pwm_dir;odom;speed;\r\n");
GaspardD 10:e63fe4080760 40 for(int i = 0; i<i_LOG_index_data; i++) {
GaspardD 10:e63fe4080760 41 rs_LOG_pc.printf("%d;%f;%f;%f;%f;%d;%f;%f;\r\n",s_LOG_history[i].timestamp,s_LOG_history[i].left_90,s_LOG_history[i].right_90,s_LOG_history[i].left_45,s_LOG_history[i].right_45,s_LOG_history[i].pwm_dir,s_LOG_history[i].odom,s_LOG_history[i].speed);
GaspardD 10:e63fe4080760 42
GaspardD 10:e63fe4080760 43 s_LOG_history[i].left_90 = 0.0;
GaspardD 10:e63fe4080760 44 s_LOG_history[i].right_90 = 0.0;
GaspardD 10:e63fe4080760 45 s_LOG_history[i].left_45 = 0.0;
GaspardD 10:e63fe4080760 46 s_LOG_history[i].right_45 = 0.0;
GaspardD 10:e63fe4080760 47 s_LOG_history[i].odom = 0.0;
GaspardD 10:e63fe4080760 48 s_LOG_history[i].speed = 0.0;
GaspardD 10:e63fe4080760 49 s_LOG_history[i].timestamp = 0;
GaspardD 10:e63fe4080760 50 s_LOG_history[i].pwm_dir = 0;
GaspardD 10:e63fe4080760 51
GaspardD 10:e63fe4080760 52
GaspardD 9:1b54bac6d9a7 53 }
GaspardD 10:e63fe4080760 54 i_LOG_index_data = 0;
GaspardD 10:e63fe4080760 55 b_LOG_READY = false;
GaspardD 9:1b54bac6d9a7 56 }