API version 2.4
Dependencies: mbed Map API_E4 3_wheel_vehicule Servo DC_Motor
main.cpp@0:e389f98132a4, 2020-07-07 (annotated)
- Committer:
- evgeniik
- Date:
- Tue Jul 07 08:22:07 2020 +0000
- Revision:
- 0:e389f98132a4
Speed control added. In app, gain of speed command is changed.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
evgeniik | 0:e389f98132a4 | 1 | #include <string> |
evgeniik | 0:e389f98132a4 | 2 | #include <vector> |
evgeniik | 0:e389f98132a4 | 3 | |
evgeniik | 0:e389f98132a4 | 4 | #include "mbed.h" |
evgeniik | 0:e389f98132a4 | 5 | #include "ConsoleAPI.h" |
evgeniik | 0:e389f98132a4 | 6 | #include "Device.h" |
evgeniik | 0:e389f98132a4 | 7 | |
evgeniik | 0:e389f98132a4 | 8 | #include "Motor.h" |
evgeniik | 0:e389f98132a4 | 9 | #include "Servo.h" |
evgeniik | 0:e389f98132a4 | 10 | #include "3_wheels_Vehicule.h" |
evgeniik | 0:e389f98132a4 | 11 | |
evgeniik | 0:e389f98132a4 | 12 | using namespace std; |
evgeniik | 0:e389f98132a4 | 13 | |
evgeniik | 0:e389f98132a4 | 14 | Serial pc(D1, D0); |
evgeniik | 0:e389f98132a4 | 15 | Serial bt(PB_6, PB_7); |
evgeniik | 0:e389f98132a4 | 16 | |
evgeniik | 0:e389f98132a4 | 17 | Motor m1(PB_4 ,PC_10, PC_12, PA_0, PA_4, PC_3); // Create a L298HBridge object |
evgeniik | 0:e389f98132a4 | 18 | Motor m2(PB_5, PB_2, PB_12, PB_14, PC_7, PC_4); // Create a L298HBridge object |
evgeniik | 0:e389f98132a4 | 19 | Motor m3(PC_8, PD_2, PC_11, PC_6, PA_15, PC_2); // Create a L298HBridge object |
evgeniik | 0:e389f98132a4 | 20 | |
evgeniik | 0:e389f98132a4 | 21 | Servo servo1(PA_1); |
evgeniik | 0:e389f98132a4 | 22 | Servo servo2(PA_10); |
evgeniik | 0:e389f98132a4 | 23 | Servo servo3(PA_9); |
evgeniik | 0:e389f98132a4 | 24 | |
evgeniik | 0:e389f98132a4 | 25 | |
evgeniik | 0:e389f98132a4 | 26 | |
evgeniik | 0:e389f98132a4 | 27 | void led_switch(void); |
evgeniik | 0:e389f98132a4 | 28 | |
evgeniik | 0:e389f98132a4 | 29 | /*Ticker time_up; |
evgeniik | 0:e389f98132a4 | 30 | |
evgeniik | 0:e389f98132a4 | 31 | void led_switch() { |
evgeniik | 0:e389f98132a4 | 32 | //pc.printf("%f \t %f \t %f\n",m1.getOut(), m2.getOut(), m3.getOut()); //m1.getOut()); |
evgeniik | 0:e389f98132a4 | 33 | //pc.printf("%f \t %f \t %f\n",m1.getCom(), m2.getCom(), m3.getCom()); |
evgeniik | 0:e389f98132a4 | 34 | }*/ |
evgeniik | 0:e389f98132a4 | 35 | |
evgeniik | 0:e389f98132a4 | 36 | int main() { |
evgeniik | 0:e389f98132a4 | 37 | |
evgeniik | 0:e389f98132a4 | 38 | pc.baud(115200); |
evgeniik | 0:e389f98132a4 | 39 | bt.baud(9600); |
evgeniik | 0:e389f98132a4 | 40 | //Add serial to API |
evgeniik | 0:e389f98132a4 | 41 | ConsoleAPI::add_serial(&pc); |
evgeniik | 0:e389f98132a4 | 42 | ConsoleAPI::add_serial(&bt); |
evgeniik | 0:e389f98132a4 | 43 | |
evgeniik | 0:e389f98132a4 | 44 | servo1.calibrate(0.001,90); //portée de -90 à 90 |
evgeniik | 0:e389f98132a4 | 45 | servo2.calibrate(0.001,90); |
evgeniik | 0:e389f98132a4 | 46 | servo3.calibrate(0.001,90); |
evgeniik | 0:e389f98132a4 | 47 | |
evgeniik | 0:e389f98132a4 | 48 | servo1.write(0.5); |
evgeniik | 0:e389f98132a4 | 49 | servo2.write(0.48); |
evgeniik | 0:e389f98132a4 | 50 | servo3.write(0.5); |
evgeniik | 0:e389f98132a4 | 51 | |
evgeniik | 0:e389f98132a4 | 52 | Vehicule3 robot(&m1, &m2, &m3, &servo1, &servo2, &servo3, 0.125); |
evgeniik | 0:e389f98132a4 | 53 | |
evgeniik | 0:e389f98132a4 | 54 | while (1){ |
evgeniik | 0:e389f98132a4 | 55 | ConsoleAPI::check_command_line_argument(); |
evgeniik | 0:e389f98132a4 | 56 | } |
evgeniik | 0:e389f98132a4 | 57 | } |