Homero Silva / Mbed 2 deprecated PRGP_Pi_Swarm_ground_search_algorithm

Dependencies:   mbed

Fork of Pi_Swarm_Blank by James Hilder

Committer:
jah128
Date:
Mon Dec 22 08:45:36 2014 +0000
Revision:
8:a789ef4fde52
Parent:
7:d03e54d9eb1c
Child:
9:ef0907fda2f1
Converted library to folder

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jah128 2:e806b595f9ce 1 /*******************************************************************************************
jah128 2:e806b595f9ce 2 *
jah128 2:e806b595f9ce 3 * University of York Robot Lab Pi Swarm Robot Library
jah128 1:37502eb3b70f 4 *
jah128 4:823174be9a6b 5 * "Blank" Program
jah128 4:823174be9a6b 6 *
jah128 4:823174be9a6b 7 * Use this file as the template to produce custom controllers
jah128 4:823174be9a6b 8 *
jah128 1:37502eb3b70f 9 * (C) Dr James Hilder, Dept. Electronics & Computer Science, University of York
jah128 1:37502eb3b70f 10 *
jah128 4:823174be9a6b 11 * Version 0.6 February 2014
jah128 1:37502eb3b70f 12 *
jah128 2:e806b595f9ce 13 * Designed for use with the Pi Swarm Board (enhanced MBED sensor board) v1.2
jah128 2:e806b595f9ce 14 *
jah128 2:e806b595f9ce 15 ******************************************************************************************/
jah128 0:46cd1498a39a 16
jah128 3:1aa1de26966a 17 #include "main.h" // Certain parameters can be set by changing the defines in piswarm.h
jah128 0:46cd1498a39a 18
jah128 1:37502eb3b70f 19 PiSwarm piswarm;
jah128 1:37502eb3b70f 20 Serial pc (USBTX,USBRX);
jah128 0:46cd1498a39a 21
jah128 8:a789ef4fde52 22 //This is where the program code goes.
jah128 1:37502eb3b70f 23 int main() {
jah128 1:37502eb3b70f 24 init();
jah128 8:a789ef4fde52 25
jah128 1:37502eb3b70f 26 while(1) {
jah128 8:a789ef4fde52 27
jah128 7:d03e54d9eb1c 28 }
jah128 7:d03e54d9eb1c 29 }
jah128 7:d03e54d9eb1c 30
jah128 2:e806b595f9ce 31 /***************************************************************************************************************************************
jah128 2:e806b595f9ce 32 *
jah128 4:823174be9a6b 33 * Beyond this point, empty code blocks for optional functions is given
jah128 2:e806b595f9ce 34 *
jah128 4:823174be9a6b 35 * These may be left blank if not used, but should not be deleted
jah128 2:e806b595f9ce 36 *
jah128 2:e806b595f9ce 37 **************************************************************************************************************************************/
jah128 2:e806b595f9ce 38
jah128 1:37502eb3b70f 39 // Communications
jah128 1:37502eb3b70f 40
jah128 1:37502eb3b70f 41 // If using the communication stack (USE_COMMUNICATION_STACK = 1), functionality for handling user RF responses should be added to the following functions
jah128 1:37502eb3b70f 42 // If the communication stack is not being used, all radio data is sent to processRawRFData() instead
jah128 1:37502eb3b70f 43
jah128 1:37502eb3b70f 44 void handleUserRFCommand(char sender, char broadcast_message, char request_response, char id, char is_command, char function, char * data, char length){
jah128 1:37502eb3b70f 45 // A 'user' RF Command has been received: write the code here to process it
jah128 1:37502eb3b70f 46 // sender = ID of the sender, range 0 to 31
jah128 1:37502eb3b70f 47 // broadcast_message = 1 is message sent to all robots, 0 otherwise
jah128 1:37502eb3b70f 48 // request_response = 1 if a response is expected, 0 otherwise
jah128 1:37502eb3b70f 49 // id = Message ID, range 0 to 255
jah128 1:37502eb3b70f 50 // is_command = 1 is message is a command, 0 if it is a request. If RF_ALLOW_COMMANDS is not selected, only requests will be sent to this block
jah128 1:37502eb3b70f 51 // function = The function identifier. Range 0 to 15
jah128 1:37502eb3b70f 52 // * data = Array containing extra data bytes
jah128 1:37502eb3b70f 53 // length = Length of extra data bytes held (range 0 to 57)
jah128 8:a789ef4fde52 54
jah128 7:d03e54d9eb1c 55
jah128 4:823174be9a6b 56 //Do something...
jah128 1:37502eb3b70f 57 }
jah128 1:37502eb3b70f 58
jah128 1:37502eb3b70f 59 void handleUserRFResponse(char sender, char broadcast_message, char success, char id, char is_command, char function, char * data, char length){
jah128 1:37502eb3b70f 60 // A 'user' RF Response has been received: write the code here to process it
jah128 1:37502eb3b70f 61 // sender = ID of the sender, range 0 to 31
jah128 1:37502eb3b70f 62 // broadcast_message = 1 is message sent to all robots, 0 otherwise
jah128 1:37502eb3b70f 63 // success = 1 if operation successful, 0 otherwise
jah128 1:37502eb3b70f 64 // id = Message ID, range 0 to 255
jah128 1:37502eb3b70f 65 // is_command = 1 is message is a command, 0 if it is a request. If RF_ALLOW_COMMANDS is not selected, only requests will be sent to this block
jah128 1:37502eb3b70f 66 // function = The function identifier. Range 0 to 15
jah128 1:37502eb3b70f 67 // * data = Array containing extra data bytes
jah128 1:37502eb3b70f 68 // length = Length of extra data bytes held (range 0 to 57)
jah128 4:823174be9a6b 69
jah128 4:823174be9a6b 70 //Do something...
jah128 1:37502eb3b70f 71 }
jah128 1:37502eb3b70f 72
jah128 1:37502eb3b70f 73 void processRawRFData(char * rstring, char cCount){
jah128 1:37502eb3b70f 74 // A raw RF packet has been received: write the code here to process it
jah128 1:37502eb3b70f 75 // rstring = The received packet
jah128 1:37502eb3b70f 76 // cCount = Packet length
jah128 4:823174be9a6b 77
jah128 4:823174be9a6b 78 //Do something...
jah128 0:46cd1498a39a 79 }
jah128 0:46cd1498a39a 80
jah128 1:37502eb3b70f 81 void switch_pressed() {
jah128 1:37502eb3b70f 82 //Switch(es) pressed {1 = Center 2 = Right 4 = Left 8 = Down 16 = Up}
jah128 1:37502eb3b70f 83 char switches = piswarm.get_switches();
jah128 1:37502eb3b70f 84
jah128 1:37502eb3b70f 85 //Do something...
jah128 0:46cd1498a39a 86 }