![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
the fish that looks like a jet
Dependencies: ADXL345 ADXL345_I2C IMUfilter ITG3200 mbed Servo
main.cpp@3:666c1bae1a34, 2014-01-24 (annotated)
- Committer:
- sandwich
- Date:
- Fri Jan 24 21:58:04 2014 +0000
- Revision:
- 3:666c1bae1a34
- Parent:
- 2:430c068cf570
- Parent:
- 1:80e0af42f876
- Child:
- 5:090ef6275773
merged changes
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sandwich | 0:ff9bc5f69c57 | 1 | #include "mbed.h" |
sandwich | 0:ff9bc5f69c57 | 2 | #include "motor_controller.h" |
sandwich | 2:430c068cf570 | 3 | #include "guardian.h" |
sandwich | 0:ff9bc5f69c57 | 4 | #include "IMU.h" |
sandwich | 2:430c068cf570 | 5 | #include "Servo.h" |
sandwich | 2:430c068cf570 | 6 | #include "rtos.h" |
sandwich | 2:430c068cf570 | 7 | |
sandwich | 2:430c068cf570 | 8 | bool quit=false; |
sandwich | 0:ff9bc5f69c57 | 9 | |
sandwich | 0:ff9bc5f69c57 | 10 | PololuMController mcon(p22, p6, p5); |
sandwich | 2:430c068cf570 | 11 | Servo servo(p21); |
sandwich | 2:430c068cf570 | 12 | Guardian ap(p21, p23, p24, p25, p26, p26); |
sandwich | 2:430c068cf570 | 13 | Serial xbee(p13, p14); |
sandwich | 2:430c068cf570 | 14 | Serial pc(USBTX, USBRX); |
sandwich | 0:ff9bc5f69c57 | 15 | |
sandwich | 2:430c068cf570 | 16 | //IMU imu(0.1, 0.3, 0.005, 0.005); |
sandwich | 3:666c1bae1a34 | 17 | void motor_thread(void const *args) { |
sandwich | 2:430c068cf570 | 18 | |
sandwich | 0:ff9bc5f69c57 | 19 | Timer t; |
sandwich | 0:ff9bc5f69c57 | 20 | t.start(); |
sandwich | 2:430c068cf570 | 21 | while (quit==false) { |
sandwich | 2:430c068cf570 | 22 | mcon.drive_sinusoidal(t.read(), 1, 2*3.14, 0); |
sandwich | 0:ff9bc5f69c57 | 23 | } |
sandwich | 0:ff9bc5f69c57 | 24 | t.stop(); |
sandwich | 0:ff9bc5f69c57 | 25 | } |
sandwich | 2:430c068cf570 | 26 | |
sandwich | 2:430c068cf570 | 27 | int main() |
sandwich | 2:430c068cf570 | 28 | { |
sandwich | 2:430c068cf570 | 29 | Thread thread(motor_thread); |
sandwich | 2:430c068cf570 | 30 | ap.calibrate(); |
sandwich | 2:430c068cf570 | 31 | ap.set2D(); |
sandwich | 2:430c068cf570 | 32 | while(1) { |
sandwich | 2:430c068cf570 | 33 | char buf[128]; |
sandwich | 2:430c068cf570 | 34 | if (xbee.readable()) |
sandwich | 2:430c068cf570 | 35 | { |
sandwich | 2:430c068cf570 | 36 | xbee.gets(buf, 128); |
sandwich | 2:430c068cf570 | 37 | pc.puts(buf); |
sandwich | 2:430c068cf570 | 38 | } |
sandwich | 2:430c068cf570 | 39 | memset(buf, 0, 128); |
sandwich | 2:430c068cf570 | 40 | } |
sandwich | 2:430c068cf570 | 41 | } |