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.
main.cpp@6:ab9f3695633f, 2019-09-29 (annotated)
- Committer:
- GaspardD
- Date:
- Sun Sep 29 20:07:54 2019 +0000
- Revision:
- 6:ab9f3695633f
- Parent:
- 5:8bbe640528bc
- Child:
- 7:23bb20892c8c
jules guesde mc gyver;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
GaspardD | 1:8faddee0e52f | 1 | #include "sm_esc.h" |
GaspardD | 2:e9d928fd327a | 2 | #include "sm_servo.h" |
GaspardD | 4:efa207509f63 | 3 | #include "sm_sections.h" |
GaspardD | 6:ab9f3695633f | 4 | #include "MPU6050.h" |
GaspardD | 6:ab9f3695633f | 5 | |
GaspardD | 6:ab9f3695633f | 6 | |
GaspardD | 6:ab9f3695633f | 7 | MPU6050 mpu; |
GaspardD | 6:ab9f3695633f | 8 | int16_t ax, ay, az; |
GaspardD | 6:ab9f3695633f | 9 | float ax_g,ay_g,az_g; |
GaspardD | 6:ab9f3695633f | 10 | int16_t gx, gy, gz; |
GaspardD | 0:38b6065539a0 | 11 | |
GaspardD | 3:1b7eb426247e | 12 | int main() |
GaspardD | 3:1b7eb426247e | 13 | { |
GaspardD | 5:8bbe640528bc | 14 | //on met le jumper sur le chassis le plus récent. Avec le jumper, chassisMode = 0. |
GaspardD | 6:ab9f3695633f | 15 | init_chassis_mode(); |
GaspardD | 6:ab9f3695633f | 16 | |
GaspardD | 6:ab9f3695633f | 17 | mpu.initialize(); |
GaspardD | 6:ab9f3695633f | 18 | odroid.printf("MPU6050 testConnection \r\n"); |
GaspardD | 6:ab9f3695633f | 19 | |
GaspardD | 6:ab9f3695633f | 20 | bool mpu6050TestResult = mpu.testConnection(); |
GaspardD | 6:ab9f3695633f | 21 | if(mpu6050TestResult) { |
GaspardD | 6:ab9f3695633f | 22 | odroid.printf("MPU6050 test passed \r\n"); |
GaspardD | 6:ab9f3695633f | 23 | } else { |
GaspardD | 6:ab9f3695633f | 24 | odroid.printf("MPU6050 test failed \r\n"); |
GaspardD | 6:ab9f3695633f | 25 | } |
GaspardD | 6:ab9f3695633f | 26 | |
GaspardD | 4:efa207509f63 | 27 | //init timers |
GaspardD | 4:efa207509f63 | 28 | timerSinceStart.start(); |
GaspardD | 0:38b6065539a0 | 29 | |
GaspardD | 4:efa207509f63 | 30 | //init_interruptions |
GaspardD | 6:ab9f3695633f | 31 | button.fall(&it_pressed); |
GaspardD | 4:efa207509f63 | 32 | odom.fall(&it_odom); |
GaspardD | 3:1b7eb426247e | 33 | |
GaspardD | 1:8faddee0e52f | 34 | //init state machines |
GaspardD | 4:efa207509f63 | 35 | pc.printf("init state machines\r\n"); |
GaspardD | 3:1b7eb426247e | 36 | |
GaspardD | 6:ab9f3695633f | 37 | //init_sm_sections(); |
GaspardD | 6:ab9f3695633f | 38 | init_sm_esc(); |
GaspardD | 3:1b7eb426247e | 39 | init_sm_servo(); |
GaspardD | 2:e9d928fd327a | 40 | |
GaspardD | 1:8faddee0e52f | 41 | while(1) { |
GaspardD | 6:ab9f3695633f | 42 | mpu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz); |
GaspardD | 6:ab9f3695633f | 43 | //correction pour avoir une acceleration coef empirique |
GaspardD | 6:ab9f3695633f | 44 | ax_g = (float)ax /1658.0 ; |
GaspardD | 6:ab9f3695633f | 45 | ay_g = (float)ay /1658.0 ; |
GaspardD | 6:ab9f3695633f | 46 | az_g = (float)az /1658.0 ; |
GaspardD | 6:ab9f3695633f | 47 | |
GaspardD | 6:ab9f3695633f | 48 | if(e_stateESC == ESC_COMMAND) |
GaspardD | 6:ab9f3695633f | 49 | { |
GaspardD | 6:ab9f3695633f | 50 | odroid.printf("acc X =%.2f; acc Y =%.2f; acc Z=%.2f;gyr X =%d; gyr Y =%d; gyr Z=%d;\n\r",ax_g,ay_g,az_g,gx,gy,gz); |
GaspardD | 6:ab9f3695633f | 51 | } |
GaspardD | 6:ab9f3695633f | 52 | //update_sm_sections(); |
GaspardD | 1:8faddee0e52f | 53 | update_sm_esc(); |
GaspardD | 4:efa207509f63 | 54 | update_sm_servo(); |
GaspardD | 3:1b7eb426247e | 55 | |
GaspardD | 6:ab9f3695633f | 56 | //output_sm_sections(); |
GaspardD | 4:efa207509f63 | 57 | output_sm_esc(); |
GaspardD | 3:1b7eb426247e | 58 | output_sm_servo(); |
GaspardD | 0:38b6065539a0 | 59 | } |
GaspardD | 0:38b6065539a0 | 60 | } |