Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
sm_sections.cpp
- Committer:
- GaspardD
- Date:
- 2019-09-29
- Revision:
- 6:ab9f3695633f
- Parent:
- 4:efa207509f63
- Child:
- 8:f23601373e8b
File content as of revision 6:ab9f3695633f:
#include "sm_sections.h" s_Section s_section1; s_Section s_section2; E_STATE_SECTIONS e_stateSections; void init_sm_sections(){ d_ODOM_distFromSectionStart_m = 0.0; e_stateSections = STOPPED; s_UTILS_currentSection = NULL; //section de départ s_section1.nextSection = &s_section2; s_section1.consigne_position = 0.75; s_section1.targetSpeed_mps = 1.0; s_section1.lng_section_m = 1.0; s_section1.coef_p = 1.0; s_section1.coef_d = 0.0; s_section1.coef_i = 0.000; //epingle 1 s_section2.nextSection = NULL; s_section2.consigne_position = 0.75; s_section2.targetSpeed_mps = 1.0; s_section2.lng_section_m = 1.0; s_section2.coef_p = 1.0; s_section2.coef_d = 0.0; s_section2.coef_i = 0.000; return; } void update_sm_sections(){ E_STATE_SECTIONS e_next_state = e_stateSections; //pc.printf("\r\nUpdate Section\r\n"); if(b_UTILS_flag_button){ e_next_state = INIT_SECTION; } else if(s_UTILS_currentSection == NULL && e_stateSections != INIT_SECTION) { e_next_state = STOPPED; } else { switch (e_stateSections) { case INIT_SECTION: e_next_state = LOADING_SECTION; break; case RUNNING_SECTION: if(d_ODOM_distFromSectionStart_m > s_UTILS_currentSection->lng_section_m) { e_next_state = LOADING_SECTION; } else if (b_UTILS_flag_emergency_stop){ e_next_state = STOPPED; } else{ return; } break; case LOADING_SECTION: if(s_UTILS_currentSection != NULL && !b_UTILS_flag_emergency_stop) { //la section a ete chargee dans sectionOutput e_next_state = RUNNING_SECTION; } else { e_next_state=STOPPED; } break; case STOPPED: if(s_UTILS_currentSection != NULL) { e_next_state = RUNNING_SECTION; } else { return; } break; default: break; } } e_stateSections = e_next_state; return; } void output_sm_sections(){ //pc.printf("\r\n Output Section\r\n"); if(s_UTILS_currentSection !=NULL) { switch (e_stateSections) { case INIT_SECTION: b_UTILS_flag_button = false; s_UTILS_currentSection = &s_section1; case RUNNING_SECTION: break; case LOADING_SECTION: s_UTILS_currentSection=s_UTILS_currentSection->nextSection; d_ODOM_distFromSectionStart_m = 0.0; break; case STOPPED: //on est à l'arret break; default: break; } } return; }