mobile robot control with artificial hormones

Dependencies:   Communication_Robot RTC-DS1307 iSerial mbed

Fork of Andante_v00 by potiwat ngamkajornwiwat

Committer:
soulx
Date:
Sun Mar 01 08:50:37 2015 +0000
Revision:
2:b31c4677ebc0
Parent:
0:95d17607a698
Child:
3:12f2ee26a43f
before test communication 1; -receive only

Who changed what in which revision?

UserRevisionLine numberNew contents of line
soulx 0:95d17607a698 1 #include "mbed.h"
soulx 0:95d17607a698 2 #include "param.h"
soulx 0:95d17607a698 3 #include "pin_config.h"
soulx 0:95d17607a698 4
soulx 2:b31c4677ebc0 5 #include "iSerial.h"
soulx 2:b31c4677ebc0 6 //#include "protocol.h"
soulx 2:b31c4677ebc0 7 #include "communication.h"
soulx 2:b31c4677ebc0 8
soulx 2:b31c4677ebc0 9
soulx 0:95d17607a698 10 //control stearing
soulx 0:95d17607a698 11 PwmOut heading_front(PIN_FRONT_SERVO);
soulx 0:95d17607a698 12 PwmOut heading_rear(PIN_REAR_SERVO);
soulx 0:95d17607a698 13 //control speed
soulx 0:95d17607a698 14 PwmOut drive_motor(PIN_RC_SPEED);
soulx 0:95d17607a698 15
soulx 0:95d17607a698 16 //led debugging
soulx 0:95d17607a698 17 DigitalOut myled(LED1);
soulx 0:95d17607a698 18
soulx 0:95d17607a698 19 //set foreground
soulx 0:95d17607a698 20 Ticker Update_command;
soulx 0:95d17607a698 21 Ticker Samping;
soulx 0:95d17607a698 22
soulx 0:95d17607a698 23 void Init_servo()
soulx 0:95d17607a698 24 {
soulx 0:95d17607a698 25 heading_front.period_ms(20);
soulx 0:95d17607a698 26 heading_rear.period_ms(20);
soulx 0:95d17607a698 27 drive_motor.period_ms(20);
soulx 0:95d17607a698 28 }
soulx 0:95d17607a698 29 void Init_communication()
soulx 0:95d17607a698 30 {
soulx 2:b31c4677ebc0 31 COMMUNICATION pan_a(TX_PAN_A, RX_PAN_A,115200,1000,1000); // tx, rx
soulx 2:b31c4677ebc0 32 COMMUNICATION pan_b(TX_PAN_B, RX_PAN_B,115200,1000,100); // tx, rx
soulx 2:b31c4677ebc0 33
soulx 2:b31c4677ebc0 34 }
soulx 0:95d17607a698 35
soulx 2:b31c4677ebc0 36 void setControl()
soulx 2:b31c4677ebc0 37 {
soulx 2:b31c4677ebc0 38
soulx 2:b31c4677ebc0 39 }
soulx 2:b31c4677ebc0 40
soulx 2:b31c4677ebc0 41 void getSensor()
soulx 2:b31c4677ebc0 42 {
soulx 0:95d17607a698 43
soulx 0:95d17607a698 44 }
soulx 0:95d17607a698 45
soulx 0:95d17607a698 46 void Init_foreground()
soulx 0:95d17607a698 47 {
soulx 0:95d17607a698 48 Update_command.attach(&setControl,TIMER_UPDATE);
soulx 0:95d17607a698 49 Samping.attach(&getSensor,TIMER_SAMPING);
soulx 0:95d17607a698 50 }
soulx 0:95d17607a698 51
soulx 0:95d17607a698 52
soulx 2:b31c4677ebc0 53
soulx 0:95d17607a698 54
soulx 2:b31c4677ebc0 55
soulx 2:b31c4677ebc0 56
soulx 0:95d17607a698 57
soulx 0:95d17607a698 58 int main()
soulx 0:95d17607a698 59 {
soulx 0:95d17607a698 60 Init_communication();
soulx 0:95d17607a698 61 Init_servo();
soulx 0:95d17607a698 62
soulx 2:b31c4677ebc0 63 //pan_a.CommunicatePacket
soulx 0:95d17607a698 64 }