TRR 2018 / Mbed 2 deprecated biniou-TRR2019-DLVV

Dependencies:   mbed MPU6050

Committer:
ohlimi2
Date:
Fri Oct 04 23:31:08 2019 +0000
Revision:
14:914467165f34
Parent:
13:3868cbdfa5ce
Child:
15:0f89d1ff860d
2 epingle mieux diminuer vitesse dans la dernierre ligne droite

Who changed what in which revision?

UserRevisionLine numberNew contents of line
GaspardD 3:1b7eb426247e 1 #include "sm_sections.h"
GaspardD 8:f23601373e8b 2 #include "sm_mpu.h"
GaspardD 3:1b7eb426247e 3
GaspardD 3:1b7eb426247e 4
GaspardD 4:efa207509f63 5 s_Section s_section1;
GaspardD 4:efa207509f63 6 s_Section s_section2;
GaspardD 12:58ad06f9847d 7 s_Section s_section2_1;
GaspardD 11:2156cb77d0d6 8 s_Section s_section3;
GaspardD 12:58ad06f9847d 9 s_Section s_section3_1;
GaspardD 12:58ad06f9847d 10 s_Section s_section4;
GaspardD 12:58ad06f9847d 11 s_Section s_section5;
GaspardD 12:58ad06f9847d 12 s_Section s_section5_1;
GaspardD 12:58ad06f9847d 13 s_Section s_section6_0;
GaspardD 12:58ad06f9847d 14 s_Section s_section6;
GaspardD 13:3868cbdfa5ce 15 s_Section s_section6_1;
GaspardD 12:58ad06f9847d 16 s_Section s_section7;
GaspardD 12:58ad06f9847d 17 s_Section s_section8;
GaspardD 12:58ad06f9847d 18 s_Section s_section9;
GaspardD 12:58ad06f9847d 19 s_Section s_section9_1;
GaspardD 12:58ad06f9847d 20 s_Section s_section10;
GaspardD 12:58ad06f9847d 21 s_Section s_section11;
GaspardD 13:3868cbdfa5ce 22 s_Section s_section11_1;
GaspardD 12:58ad06f9847d 23 s_Section s_section12;
GaspardD 3:1b7eb426247e 24
GaspardD 8:f23601373e8b 25 E_STATE_SECTIONS e_SECTIONS_state;
GaspardD 8:f23601373e8b 26
GaspardD 3:1b7eb426247e 27
GaspardD 8:f23601373e8b 28 void init_sm_sections()
GaspardD 8:f23601373e8b 29 {
GaspardD 3:1b7eb426247e 30
GaspardD 4:efa207509f63 31 d_ODOM_distFromSectionStart_m = 0.0;
GaspardD 8:f23601373e8b 32 e_SECTIONS_state = STOPPED;
GaspardD 8:f23601373e8b 33 s_section1.nextSection = NULL;
GaspardD 4:efa207509f63 34
GaspardD 4:efa207509f63 35
GaspardD 8:f23601373e8b 36 //section de départ
GaspardD 4:efa207509f63 37 s_section1.nextSection = &s_section2;
GaspardD 9:1b54bac6d9a7 38 s_section1.consigne_position = 0.5;
GaspardD 12:58ad06f9847d 39 s_section1.targetSpeed_mps = 1750;
GaspardD 12:58ad06f9847d 40 s_section1.lng_section_m = 0.8;
GaspardD 12:58ad06f9847d 41 s_section1.coef_pos = 40;
GaspardD 12:58ad06f9847d 42 s_section1.coef_bord = 0.6;
GaspardD 12:58ad06f9847d 43 s_section1.plagePulseFreinage = 20;
GaspardD 3:1b7eb426247e 44
GaspardD 12:58ad06f9847d 45 //ligne droite debut
GaspardD 12:58ad06f9847d 46 s_section2.nextSection = &s_section2_1;
GaspardD 9:1b54bac6d9a7 47 s_section2.consigne_position = 0.5;
GaspardD 12:58ad06f9847d 48 s_section2.targetSpeed_mps = 1770;
GaspardD 12:58ad06f9847d 49 s_section2.lng_section_m = 10.0;
GaspardD 12:58ad06f9847d 50 s_section2.coef_pos = 30;
GaspardD 12:58ad06f9847d 51 s_section2.coef_bord = 0.5;
GaspardD 12:58ad06f9847d 52 s_section2.plagePulseFreinage = 50;
GaspardD 12:58ad06f9847d 53
GaspardD 12:58ad06f9847d 54
GaspardD 12:58ad06f9847d 55 //ligne droite debut
GaspardD 12:58ad06f9847d 56 s_section2_1.nextSection = &s_section3;
GaspardD 12:58ad06f9847d 57 s_section2_1.consigne_position = 0.4;
GaspardD 12:58ad06f9847d 58 s_section2_1.targetSpeed_mps = 1600;
GaspardD 12:58ad06f9847d 59 s_section2_1.lng_section_m = 3.0;
GaspardD 12:58ad06f9847d 60 s_section2_1.coef_pos = 30;
GaspardD 12:58ad06f9847d 61 s_section2_1.coef_bord = 0.4;
GaspardD 12:58ad06f9847d 62 s_section2_1.plagePulseFreinage = 50;
GaspardD 12:58ad06f9847d 63
GaspardD 12:58ad06f9847d 64 //epingle 1 debut
GaspardD 12:58ad06f9847d 65 s_section3.nextSection = &s_section3_1;
GaspardD 12:58ad06f9847d 66 s_section3.consigne_position = 0.7;
GaspardD 12:58ad06f9847d 67 s_section3.targetSpeed_mps = 1620;
GaspardD 12:58ad06f9847d 68 s_section3.lng_section_m = 2.0;
GaspardD 12:58ad06f9847d 69 s_section3.coef_pos = 30;
GaspardD 12:58ad06f9847d 70 s_section3.coef_bord = 2.0;
GaspardD 12:58ad06f9847d 71 s_section3.plagePulseFreinage = 20;
GaspardD 12:58ad06f9847d 72
GaspardD 12:58ad06f9847d 73 //epingle 1 milieu
GaspardD 12:58ad06f9847d 74 s_section3_1.nextSection = &s_section4;
GaspardD 12:58ad06f9847d 75 s_section3_1.consigne_position = 0.7;
GaspardD 12:58ad06f9847d 76 s_section3_1.targetSpeed_mps = 1690;
GaspardD 12:58ad06f9847d 77 s_section3_1.lng_section_m = 4.0;
GaspardD 12:58ad06f9847d 78 s_section3_1.coef_pos = 30;
GaspardD 12:58ad06f9847d 79 s_section3_1.coef_bord = 2.0;
GaspardD 12:58ad06f9847d 80 s_section3_1.plagePulseFreinage = 20;
GaspardD 12:58ad06f9847d 81
GaspardD 12:58ad06f9847d 82 //post epingle 1
GaspardD 12:58ad06f9847d 83 s_section4.nextSection = &s_section5;
GaspardD 12:58ad06f9847d 84 s_section4.consigne_position = 0.8;
GaspardD 12:58ad06f9847d 85 s_section4.targetSpeed_mps = 1720;
GaspardD 12:58ad06f9847d 86 s_section4.lng_section_m = 5.0;
GaspardD 12:58ad06f9847d 87 s_section4.coef_pos = 30;
GaspardD 12:58ad06f9847d 88 s_section4.coef_bord = 1.3;
GaspardD 12:58ad06f9847d 89 s_section4.plagePulseFreinage = 30;
GaspardD 12:58ad06f9847d 90
GaspardD 12:58ad06f9847d 91 //droite epingle chicane
GaspardD 12:58ad06f9847d 92 s_section5.nextSection = &s_section5_1;
GaspardD 12:58ad06f9847d 93 s_section5.consigne_position = 0.6;
GaspardD 12:58ad06f9847d 94 s_section5.targetSpeed_mps = 1780;
GaspardD 12:58ad06f9847d 95 s_section5.lng_section_m = 7.0;
GaspardD 12:58ad06f9847d 96 s_section5.coef_pos = 30;
GaspardD 12:58ad06f9847d 97 s_section5.coef_bord = 0.7;
GaspardD 12:58ad06f9847d 98 s_section5.plagePulseFreinage = 40;
GaspardD 11:2156cb77d0d6 99
GaspardD 11:2156cb77d0d6 100
GaspardD 12:58ad06f9847d 101 //avant chicane
GaspardD 12:58ad06f9847d 102 s_section5_1.nextSection = &s_section6_0;
GaspardD 12:58ad06f9847d 103 s_section5_1.consigne_position = 0.8;
GaspardD 12:58ad06f9847d 104 s_section5_1.targetSpeed_mps = 1650;
GaspardD 12:58ad06f9847d 105 s_section5_1.lng_section_m = 4.0;
GaspardD 12:58ad06f9847d 106 s_section5_1.coef_pos = 30;
GaspardD 12:58ad06f9847d 107 s_section5_1.coef_bord = 2.0;
GaspardD 12:58ad06f9847d 108 s_section5_1.plagePulseFreinage = 40;
GaspardD 12:58ad06f9847d 109
GaspardD 12:58ad06f9847d 110 //pre chicane
GaspardD 12:58ad06f9847d 111 s_section6_0.nextSection = &s_section6;
GaspardD 12:58ad06f9847d 112 s_section6_0.consigne_position = 0.5;
GaspardD 12:58ad06f9847d 113 s_section6_0.targetSpeed_mps = 1650;
GaspardD 12:58ad06f9847d 114 s_section6_0.lng_section_m = 3.0;
GaspardD 12:58ad06f9847d 115 s_section6_0.coef_pos = 30;//50
GaspardD 12:58ad06f9847d 116 s_section6_0.coef_bord = 1.0;//2.0
GaspardD 12:58ad06f9847d 117 s_section6_0.plagePulseFreinage = 45;
GaspardD 12:58ad06f9847d 118
GaspardD 12:58ad06f9847d 119
GaspardD 12:58ad06f9847d 120 //chicane
GaspardD 12:58ad06f9847d 121 s_section6.nextSection = &s_section7;
GaspardD 12:58ad06f9847d 122 s_section6.consigne_position = 0.58;
GaspardD 12:58ad06f9847d 123 s_section6.targetSpeed_mps = 1675;
GaspardD 13:3868cbdfa5ce 124 s_section6.lng_section_m = 17.0;
GaspardD 12:58ad06f9847d 125 s_section6.coef_pos = 30;//50
GaspardD 12:58ad06f9847d 126 s_section6.coef_bord = 2.0;//2.0
GaspardD 12:58ad06f9847d 127 s_section6.plagePulseFreinage = 50;
GaspardD 12:58ad06f9847d 128
GaspardD 13:3868cbdfa5ce 129 //fin chicane SKIPPED
GaspardD 13:3868cbdfa5ce 130 s_section6_1.nextSection = &s_section7;
GaspardD 13:3868cbdfa5ce 131 s_section6_1.consigne_position = 0.58;
GaspardD 13:3868cbdfa5ce 132 s_section6_1.targetSpeed_mps = 1675;
GaspardD 13:3868cbdfa5ce 133 s_section6_1.lng_section_m = 0.0;
GaspardD 13:3868cbdfa5ce 134 s_section6_1.coef_pos = 30;//50
GaspardD 13:3868cbdfa5ce 135 s_section6_1.coef_bord = 2.0;//2.0
GaspardD 13:3868cbdfa5ce 136 s_section6_1.plagePulseFreinage = 50;
GaspardD 13:3868cbdfa5ce 137
GaspardD 12:58ad06f9847d 138 //ligne droite postchicane
GaspardD 12:58ad06f9847d 139 s_section7.nextSection = &s_section8;
GaspardD 13:3868cbdfa5ce 140 s_section7.consigne_position = 0.4;
GaspardD 12:58ad06f9847d 141 s_section7.targetSpeed_mps = 1770;
ohlimi2 14:914467165f34 142 s_section7.lng_section_m = 8.0;
GaspardD 12:58ad06f9847d 143 s_section7.coef_pos = 30;
GaspardD 12:58ad06f9847d 144 s_section7.coef_bord = 0.5;
GaspardD 12:58ad06f9847d 145 s_section7.plagePulseFreinage = 50;
GaspardD 12:58ad06f9847d 146
GaspardD 12:58ad06f9847d 147
GaspardD 13:3868cbdfa5ce 148 //freinage avant epingle
GaspardD 12:58ad06f9847d 149 s_section8.nextSection = &s_section9;
GaspardD 12:58ad06f9847d 150 s_section8.consigne_position = 0.4;
ohlimi2 14:914467165f34 151 s_section8.targetSpeed_mps = 1620;
ohlimi2 14:914467165f34 152 s_section8.lng_section_m = 4.0;
GaspardD 12:58ad06f9847d 153 s_section8.coef_pos = 30;
GaspardD 12:58ad06f9847d 154 s_section8.coef_bord = 0.4;
GaspardD 12:58ad06f9847d 155 s_section8.plagePulseFreinage = 50;
GaspardD 12:58ad06f9847d 156
GaspardD 12:58ad06f9847d 157 //epingle 2 debut
GaspardD 12:58ad06f9847d 158 s_section9.nextSection = &s_section9_1;
GaspardD 12:58ad06f9847d 159 s_section9.consigne_position = 0.7;
GaspardD 12:58ad06f9847d 160 s_section9.targetSpeed_mps = 1620;
GaspardD 12:58ad06f9847d 161 s_section9.lng_section_m = 2.0;
GaspardD 12:58ad06f9847d 162 s_section9.coef_pos = 30;
GaspardD 12:58ad06f9847d 163 s_section9.coef_bord = 2.0;
GaspardD 12:58ad06f9847d 164 s_section9.plagePulseFreinage = 20;
GaspardD 12:58ad06f9847d 165
GaspardD 12:58ad06f9847d 166 //epingle 2 milieu
GaspardD 12:58ad06f9847d 167 s_section9_1.nextSection = &s_section10;
GaspardD 12:58ad06f9847d 168 s_section9_1.consigne_position = 0.7;
GaspardD 13:3868cbdfa5ce 169 s_section9_1.targetSpeed_mps = 1670;
GaspardD 12:58ad06f9847d 170 s_section9_1.lng_section_m = 4.0;
GaspardD 12:58ad06f9847d 171 s_section9_1.coef_pos = 30;
GaspardD 12:58ad06f9847d 172 s_section9_1.coef_bord = 2.0;
GaspardD 12:58ad06f9847d 173 s_section9_1.plagePulseFreinage = 20;
GaspardD 12:58ad06f9847d 174
GaspardD 12:58ad06f9847d 175 //post epingle 2
GaspardD 12:58ad06f9847d 176 s_section10.nextSection = &s_section11;
GaspardD 12:58ad06f9847d 177 s_section10.consigne_position = 0.8;
GaspardD 12:58ad06f9847d 178 s_section10.targetSpeed_mps = 1720;
GaspardD 12:58ad06f9847d 179 s_section10.lng_section_m = 5.0;
GaspardD 12:58ad06f9847d 180 s_section10.coef_pos = 30;
GaspardD 12:58ad06f9847d 181 s_section10.coef_bord = 1.3;
GaspardD 12:58ad06f9847d 182 s_section10.plagePulseFreinage = 30;
GaspardD 12:58ad06f9847d 183
GaspardD 12:58ad06f9847d 184 //dernière ligne droite
GaspardD 13:3868cbdfa5ce 185 s_section11.nextSection = &s_section11_1;
ohlimi2 14:914467165f34 186 s_section11.consigne_position = 0.65;
GaspardD 13:3868cbdfa5ce 187 s_section11.targetSpeed_mps = 1750;
GaspardD 13:3868cbdfa5ce 188 s_section11.lng_section_m = 8.0;
ohlimi2 14:914467165f34 189 s_section11.coef_pos = 20;
ohlimi2 14:914467165f34 190 s_section11.coef_bord = 0.4;
ohlimi2 14:914467165f34 191 s_section11.plagePulseFreinage = 40;
GaspardD 13:3868cbdfa5ce 192
GaspardD 13:3868cbdfa5ce 193 //dernière ligne droite
GaspardD 13:3868cbdfa5ce 194 s_section11_1.nextSection = &s_section12;
GaspardD 13:3868cbdfa5ce 195 s_section11_1.consigne_position = 0.5;
GaspardD 13:3868cbdfa5ce 196 s_section11_1.targetSpeed_mps = 1810;
GaspardD 13:3868cbdfa5ce 197 s_section11_1.lng_section_m = 30.0;
ohlimi2 14:914467165f34 198 s_section11_1.coef_pos = 20;
GaspardD 13:3868cbdfa5ce 199 s_section11_1.coef_bord = 0.4;
GaspardD 13:3868cbdfa5ce 200 s_section11_1.plagePulseFreinage = 100;
GaspardD 12:58ad06f9847d 201
GaspardD 12:58ad06f9847d 202
GaspardD 12:58ad06f9847d 203 //frein
GaspardD 12:58ad06f9847d 204 s_section12.nextSection = NULL;
GaspardD 12:58ad06f9847d 205 s_section12.consigne_position = 0.5;
GaspardD 12:58ad06f9847d 206 s_section12.targetSpeed_mps = 1300;
GaspardD 12:58ad06f9847d 207 s_section12.lng_section_m = 0.1;
GaspardD 12:58ad06f9847d 208 s_section12.coef_pos = 80;
GaspardD 12:58ad06f9847d 209 s_section12.coef_bord = 1.0;
GaspardD 12:58ad06f9847d 210 s_section12.plagePulseFreinage = 20;
GaspardD 3:1b7eb426247e 211
GaspardD 3:1b7eb426247e 212 return;
GaspardD 3:1b7eb426247e 213 }
GaspardD 8:f23601373e8b 214 void update_sm_sections()
GaspardD 8:f23601373e8b 215 {
GaspardD 8:f23601373e8b 216
GaspardD 8:f23601373e8b 217 E_STATE_SECTIONS e_next_state = e_SECTIONS_state;
GaspardD 4:efa207509f63 218
GaspardD 9:1b54bac6d9a7 219 //rs_LOG_pc.printf("\r\nUpdate Section\r\n");
GaspardD 8:f23601373e8b 220
GaspardD 8:f23601373e8b 221 if(b_UTILS_flag_emergency_stop) {
GaspardD 12:58ad06f9847d 222 rs_LOG.printf("emergency stop -> STOPPED\r\n");
GaspardD 4:efa207509f63 223 e_next_state = STOPPED;
GaspardD 4:efa207509f63 224 } else {
GaspardD 8:f23601373e8b 225 switch (e_SECTIONS_state) {
GaspardD 4:efa207509f63 226 case INIT_SECTION:
GaspardD 8:f23601373e8b 227 e_next_state = RUNNING_SECTION;
GaspardD 9:1b54bac6d9a7 228 //rs_LOG_pc.printf("RUNNING SECTION\r\n");
GaspardD 8:f23601373e8b 229 break;
GaspardD 4:efa207509f63 230 case RUNNING_SECTION:
GaspardD 6:ab9f3695633f 231 if(d_ODOM_distFromSectionStart_m > s_UTILS_currentSection->lng_section_m) {
GaspardD 4:efa207509f63 232 e_next_state = LOADING_SECTION;
GaspardD 9:1b54bac6d9a7 233 //rs_LOG_pc.printf("LOADING SECTION !\r\n");
GaspardD 4:efa207509f63 234 }
GaspardD 4:efa207509f63 235 break;
GaspardD 4:efa207509f63 236 case LOADING_SECTION:
GaspardD 8:f23601373e8b 237 if(s_UTILS_currentSection != NULL) {
GaspardD 4:efa207509f63 238 e_next_state = RUNNING_SECTION;
GaspardD 9:1b54bac6d9a7 239 //rs_LOG_pc.printf("RUNNING SECTION !\r\n");
GaspardD 4:efa207509f63 240 } else {
GaspardD 8:f23601373e8b 241 b_UTILS_flag_emergency_stop = true;
GaspardD 11:2156cb77d0d6 242 log_stop();
GaspardD 8:f23601373e8b 243 e_next_state = STOPPED;
GaspardD 4:efa207509f63 244 }
GaspardD 4:efa207509f63 245 break;
GaspardD 4:efa207509f63 246 case STOPPED:
GaspardD 8:f23601373e8b 247 if(b_UTILS_flag_button_SECTIONS) {
GaspardD 8:f23601373e8b 248 e_next_state = INIT_SECTION;
GaspardD 12:58ad06f9847d 249 rs_LOG.printf("INIT SECTION !\r\n");
GaspardD 4:efa207509f63 250 }
GaspardD 4:efa207509f63 251 break;
GaspardD 4:efa207509f63 252 default:
GaspardD 4:efa207509f63 253 break;
GaspardD 4:efa207509f63 254 }
GaspardD 4:efa207509f63 255 }
GaspardD 8:f23601373e8b 256 e_SECTIONS_state = e_next_state;
GaspardD 3:1b7eb426247e 257 return;
GaspardD 3:1b7eb426247e 258 }
GaspardD 8:f23601373e8b 259 void output_sm_sections()
GaspardD 8:f23601373e8b 260 {
GaspardD 8:f23601373e8b 261 switch (e_SECTIONS_state) {
GaspardD 8:f23601373e8b 262 case INIT_SECTION:
GaspardD 8:f23601373e8b 263 b_UTILS_flag_button_SECTIONS = false;
GaspardD 6:ab9f3695633f 264 s_UTILS_currentSection = &s_section1;
GaspardD 12:58ad06f9847d 265 rs_LOG.printf("sect 1 INITIALIZED\r\n");
GaspardD 8:f23601373e8b 266 case RUNNING_SECTION:
GaspardD 8:f23601373e8b 267 break;
GaspardD 8:f23601373e8b 268 case LOADING_SECTION:
GaspardD 9:1b54bac6d9a7 269 //rs_LOG_pc.printf("next section loading\r\n");
GaspardD 8:f23601373e8b 270 s_UTILS_currentSection=s_UTILS_currentSection->nextSection;
GaspardD 8:f23601373e8b 271 d_ODOM_distFromSectionStart_m = 0.0;
GaspardD 8:f23601373e8b 272 break;
GaspardD 8:f23601373e8b 273 case STOPPED:
GaspardD 8:f23601373e8b 274 //on est à l'arret
GaspardD 8:f23601373e8b 275 break;
GaspardD 8:f23601373e8b 276 default:
GaspardD 8:f23601373e8b 277 break;
GaspardD 4:efa207509f63 278 }
GaspardD 3:1b7eb426247e 279 return;
GaspardD 3:1b7eb426247e 280 }