KRTMI 2019
/
Inverse_Kine_Lengan3
Boleh bisa langsung dicoba, tap servo base belum dikalibrasi
main.cpp@0:9dfae2e18414, 2019-04-10 (annotated)
- Committer:
- harrymunli
- Date:
- Wed Apr 10 15:18:37 2019 +0000
- Revision:
- 0:9dfae2e18414
- Child:
- 1:9284c57e84da
first_commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
harrymunli | 0:9dfae2e18414 | 1 | #include "mbed.h" |
harrymunli | 0:9dfae2e18414 | 2 | #include "Servo.h" |
harrymunli | 0:9dfae2e18414 | 3 | #include "Motor.h" |
harrymunli | 0:9dfae2e18414 | 4 | |
harrymunli | 0:9dfae2e18414 | 5 | /* Nama servo |
harrymunli | 0:9dfae2e18414 | 6 | 4 |
harrymunli | 0:9dfae2e18414 | 7 | 3 |
harrymunli | 0:9dfae2e18414 | 8 | 21 22 |
harrymunli | 0:9dfae2e18414 | 9 | 1 */ |
harrymunli | 0:9dfae2e18414 | 10 | |
harrymunli | 0:9dfae2e18414 | 11 | Servo servo1(PA_1); |
harrymunli | 0:9dfae2e18414 | 12 | Servo servo21(PA_2); |
harrymunli | 0:9dfae2e18414 | 13 | Servo servo22(PA_3); |
harrymunli | 0:9dfae2e18414 | 14 | Servo servo3(PA_4); |
harrymunli | 0:9dfae2e18414 | 15 | Servo servo4(PA_5); |
harrymunli | 0:9dfae2e18414 | 16 | Motor motorKanan(PB_3, PA_10, PC_4); |
harrymunli | 0:9dfae2e18414 | 17 | Motor motorKiri(PB_7, PC_3, PC_0); |
harrymunli | 0:9dfae2e18414 | 18 | |
harrymunli | 0:9dfae2e18414 | 19 | void kalibrasi(float deg){ |
harrymunli | 0:9dfae2e18414 | 20 | servo1.calibrate(0.0005,deg); |
harrymunli | 0:9dfae2e18414 | 21 | servo21.calibrate(0.0005,deg); |
harrymunli | 0:9dfae2e18414 | 22 | servo22.calibrate(0.0005,deg); |
harrymunli | 0:9dfae2e18414 | 23 | servo3.calibrate(0.0005,deg); |
harrymunli | 0:9dfae2e18414 | 24 | servo4.calibrate(0.0005,deg); |
harrymunli | 0:9dfae2e18414 | 25 | } |
harrymunli | 0:9dfae2e18414 | 26 | |
harrymunli | 0:9dfae2e18414 | 27 | void idle(float s1,float s21,float s22, float s3, float s4){ |
harrymunli | 0:9dfae2e18414 | 28 | servo1.position(s1); |
harrymunli | 0:9dfae2e18414 | 29 | wait_ms(1); |
harrymunli | 0:9dfae2e18414 | 30 | servo21.position(s21); |
harrymunli | 0:9dfae2e18414 | 31 | servo22.position(s22); |
harrymunli | 0:9dfae2e18414 | 32 | wait_ms(1); |
harrymunli | 0:9dfae2e18414 | 33 | servo3.position(s3); |
harrymunli | 0:9dfae2e18414 | 34 | wait_ms(1); |
harrymunli | 0:9dfae2e18414 | 35 | servo4.position(s4); |
harrymunli | 0:9dfae2e18414 | 36 | wait_ms(1); |
harrymunli | 0:9dfae2e18414 | 37 | } |
harrymunli | 0:9dfae2e18414 | 38 | |
harrymunli | 0:9dfae2e18414 | 39 | int main() { |
harrymunli | 0:9dfae2e18414 | 40 | /***Gerak Jalan*** |
harrymunli | 0:9dfae2e18414 | 41 | //Maju |
harrymunli | 0:9dfae2e18414 | 42 | motorKanan.speed(0.3); |
harrymunli | 0:9dfae2e18414 | 43 | motorKiri.speed(0.3); |
harrymunli | 0:9dfae2e18414 | 44 | |
harrymunli | 0:9dfae2e18414 | 45 | //Mundur |
harrymunli | 0:9dfae2e18414 | 46 | motorKanan.speed(0.3); |
harrymunli | 0:9dfae2e18414 | 47 | motorKiri.speed(0.3); |
harrymunli | 0:9dfae2e18414 | 48 | |
harrymunli | 0:9dfae2e18414 | 49 | //PivotKiri |
harrymunli | 0:9dfae2e18414 | 50 | motorKanan.brake(); |
harrymunli | 0:9dfae2e18414 | 51 | motorKiri.speed(0.3); |
harrymunli | 0:9dfae2e18414 | 52 | |
harrymunli | 0:9dfae2e18414 | 53 | //PivotKanan |
harrymunli | 0:9dfae2e18414 | 54 | motorKiri.brake(); |
harrymunli | 0:9dfae2e18414 | 55 | motorKanan.speed(0.3); |
harrymunli | 0:9dfae2e18414 | 56 | */ |
harrymunli | 0:9dfae2e18414 | 57 | |
harrymunli | 0:9dfae2e18414 | 58 | /***Gerak Tangan***/ |
harrymunli | 0:9dfae2e18414 | 59 | //kalibrasi |
harrymunli | 0:9dfae2e18414 | 60 | kalibrasi(300); |
harrymunli | 0:9dfae2e18414 | 61 | |
harrymunli | 0:9dfae2e18414 | 62 | //mode1(idle) |
harrymunli | 0:9dfae2e18414 | 63 | idle(0.0,90.0,90.0,90.0,0.0); |
harrymunli | 0:9dfae2e18414 | 64 | |
harrymunli | 0:9dfae2e18414 | 65 | //mode2(gerakan keluar) |
harrymunli | 0:9dfae2e18414 | 66 | } |