![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
wheelchair code for driver assitance
Fork of wheelchairalexa by
wheelchair.cpp@3:a5e71bfdb492, 2018-07-16 (annotated)
- Committer:
- ryanlin97
- Date:
- Mon Jul 16 20:46:42 2018 +0000
- Revision:
- 3:a5e71bfdb492
- Parent:
- 1:c0beadca1617
- Child:
- 4:29a27953fe70
using joystick
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ryanlin97 | 0:fc0c4a184482 | 1 | #include "wheelchair.h" |
ryanlin97 | 1:c0beadca1617 | 2 | |
ryanlin97 | 1:c0beadca1617 | 3 | Wheelchair::Wheelchair(PinName xPin, PinName yPin) |
ryanlin97 | 1:c0beadca1617 | 4 | { |
ryanlin97 | 3:a5e71bfdb492 | 5 | x = new PwmOut(xPin); |
ryanlin97 | 3:a5e71bfdb492 | 6 | y = new PwmOut(yPin); |
ryanlin97 | 1:c0beadca1617 | 7 | } |
ryanlin97 | 3:a5e71bfdb492 | 8 | /* |
ryanlin97 | 3:a5e71bfdb492 | 9 | * joystick has analog out of 200-700, scale values between 1.3 and 3.3 |
ryanlin97 | 3:a5e71bfdb492 | 10 | */ |
ryanlin97 | 3:a5e71bfdb492 | 11 | void Wheelchair::move(float x_coor, float y_coor) |
ryanlin97 | 1:c0beadca1617 | 12 | { |
ryanlin97 | 3:a5e71bfdb492 | 13 | printf("x is %f y is %f \n", 1.6*x_coor + 2.5, 1.6*y_coor + 2.5 + offset); |
ryanlin97 | 3:a5e71bfdb492 | 14 | x->write(1.6*x_coor + 2.5); |
ryanlin97 | 3:a5e71bfdb492 | 15 | y->write(1.6*y_coor + 2.5 + offset); |
ryanlin97 | 3:a5e71bfdb492 | 16 | |
ryanlin97 | 1:c0beadca1617 | 17 | } |
ryanlin97 | 1:c0beadca1617 | 18 | |
ryanlin97 | 1:c0beadca1617 | 19 | void Wheelchair::forward() |
ryanlin97 | 1:c0beadca1617 | 20 | { |
ryanlin97 | 0:fc0c4a184482 | 21 | x->write(high); |
ryanlin97 | 3:a5e71bfdb492 | 22 | y->write(def+offset); |
ryanlin97 | 0:fc0c4a184482 | 23 | } |
ryanlin97 | 0:fc0c4a184482 | 24 | |
ryanlin97 | 1:c0beadca1617 | 25 | void Wheelchair::backward() |
ryanlin97 | 1:c0beadca1617 | 26 | { |
ryanlin97 | 0:fc0c4a184482 | 27 | x->write(low); |
ryanlin97 | 0:fc0c4a184482 | 28 | y->write(def); |
ryanlin97 | 0:fc0c4a184482 | 29 | } |
ryanlin97 | 0:fc0c4a184482 | 30 | |
ryanlin97 | 1:c0beadca1617 | 31 | void Wheelchair::right() |
ryanlin97 | 1:c0beadca1617 | 32 | { |
ryanlin97 | 0:fc0c4a184482 | 33 | x->write(def); |
ryanlin97 | 0:fc0c4a184482 | 34 | y->write(high); |
ryanlin97 | 0:fc0c4a184482 | 35 | } |
ryanlin97 | 0:fc0c4a184482 | 36 | |
ryanlin97 | 1:c0beadca1617 | 37 | void Wheelchair::left() |
ryanlin97 | 1:c0beadca1617 | 38 | { |
ryanlin97 | 0:fc0c4a184482 | 39 | x->write(def); |
ryanlin97 | 0:fc0c4a184482 | 40 | y->write(low); |
ryanlin97 | 0:fc0c4a184482 | 41 | } |
ryanlin97 | 0:fc0c4a184482 | 42 | |
ryanlin97 | 1:c0beadca1617 | 43 | void Wheelchair::stop() |
ryanlin97 | 1:c0beadca1617 | 44 | { |
ryanlin97 | 0:fc0c4a184482 | 45 | x->write(def); |
ryanlin97 | 0:fc0c4a184482 | 46 | y->write(def); |
ryanlin97 | 1:c0beadca1617 | 47 | } |