Example code for the UKESF Headstart robotics lab; code to make the PsiSwarm robot move forward and turn.
Dependencies: PsiSwarm-Headstart mbed
Fork of PsiSwarm_V41 by
main.h@10:1b09d4bb847b, 2015-10-26 (annotated)
- Committer:
- jah128
- Date:
- Mon Oct 26 23:58:08 2015 +0000
- Revision:
- 10:1b09d4bb847b
- Parent:
- 9:085e090e1ec1
- Child:
- 11:7b3ee540ba56
Reordered files; updated display
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jah128 | 0:8a5497a2e366 | 1 | /*********************************************************************** |
jah128 | 0:8a5497a2e366 | 2 | ** ██████╗ ███████╗██╗███████╗██╗ ██╗ █████╗ ██████╗ ███╗ ███╗ ** |
jah128 | 0:8a5497a2e366 | 3 | ** ██╔══██╗██╔════╝██║██╔════╝██║ ██║██╔══██╗██╔══██╗████╗ ████║ ** |
jah128 | 0:8a5497a2e366 | 4 | ** ██████╔╝███████╗██║███████╗██║ █╗ ██║███████║██████╔╝██╔████╔██║ ** |
jah128 | 0:8a5497a2e366 | 5 | ** ██╔═══╝ ╚════██║██║╚════██║██║███╗██║██╔══██║██╔══██╗██║╚██╔╝██║ ** |
jah128 | 0:8a5497a2e366 | 6 | ** ██║ ███████║██║███████║╚███╔███╔╝██║ ██║██║ ██║██║ ╚═╝ ██║ ** |
jah128 | 0:8a5497a2e366 | 7 | ** ╚═╝ ╚══════╝╚═╝╚══════╝ ╚══╝╚══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ ** |
jah128 | 0:8a5497a2e366 | 8 | ************************************************************************ |
jah128 | 0:8a5497a2e366 | 9 | **(C) Dr James Hilder - York Robotics Laboratory - University of York ** |
jah128 | 0:8a5497a2e366 | 10 | ***********************************************************************/ |
jah128 | 0:8a5497a2e366 | 11 | |
jah128 | 6:ff3c66f7372b | 12 | /// PsiSwarm Beautiful Meme Project Source Code |
jah128 | 6:ff3c66f7372b | 13 | /// Version 0.1 |
jah128 | 6:ff3c66f7372b | 14 | /// James Hilder, Alan Millard, Homero Elizondo, Jon Timmis |
jah128 | 6:ff3c66f7372b | 15 | /// University of York |
jah128 | 6:ff3c66f7372b | 16 | |
jah128 | 6:ff3c66f7372b | 17 | #ifndef MAIN_H |
jah128 | 6:ff3c66f7372b | 18 | #define MAIN_H |
jah128 | 6:ff3c66f7372b | 19 | |
jah128 | 10:1b09d4bb847b | 20 | #include "psiswarm.h" |
jah128 | 6:ff3c66f7372b | 21 | #include "beacon.h" |
jah128 | 10:1b09d4bb847b | 22 | #include "programs.h" |
jah128 | 6:ff3c66f7372b | 23 | |
jah128 | 9:085e090e1ec1 | 24 | // Define the on-period for a IR pulse in microseconds (eg 50000 for 2Hz system, 20000 for a 5Hz system) |
jah128 | 9:085e090e1ec1 | 25 | #define BEACON_PERIOD 25000 |
jah128 | 9:085e090e1ec1 | 26 | |
jah128 | 6:ff3c66f7372b | 27 | extern char beacon_found; // This will be a 1 if beacon is detected, 0 if it isn't |
jah128 | 6:ff3c66f7372b | 28 | extern int beacon_heading; // The heading from the last time the beacon was detected |
jah128 | 6:ff3c66f7372b | 29 | extern char robots_found[8]; // These will be a 1 when the respective robot [excluding self] was detected during the previous 500ms window |
jah128 | 10:1b09d4bb847b | 30 | extern int robots_heading[8]; // These are the headings from the last time the respective robots were detected |
jah128 | 6:ff3c66f7372b | 31 | extern unsigned short robots_distance[8]; // This is the maximum sensor value from the last time the respective robot was detected |
jah128 | 6:ff3c66f7372b | 32 | extern unsigned short reflected_sensor_data[8]; // The reflected IR values when this robots emitters are on |
jah128 | 6:ff3c66f7372b | 33 | extern unsigned short background_sensor_data[8];// The raw IR values when no robot (or beacon) should have its IR on |
jah128 | 10:1b09d4bb847b | 34 | extern char disable_ir_emitters; |
jah128 | 10:1b09d4bb847b | 35 | extern char step_cycle; |
jah128 | 10:1b09d4bb847b | 36 | extern char target_reached; |
jah128 | 10:1b09d4bb847b | 37 | extern char recharging_state; |
jah128 | 10:1b09d4bb847b | 38 | extern char prog_name [17]; |
jah128 | 10:1b09d4bb847b | 39 | extern char prog_info [17]; |
jah128 | 10:1b09d4bb847b | 40 | extern char main_program_state; |
jah128 | 10:1b09d4bb847b | 41 | extern char program_changed; |
jah128 | 10:1b09d4bb847b | 42 | |
jah128 | 10:1b09d4bb847b | 43 | char * get_program_name(int index); |
jah128 | 10:1b09d4bb847b | 44 | void set_program(int index); |
jah128 | 10:1b09d4bb847b | 45 | void set_program_info(char * info); |
jah128 | 6:ff3c66f7372b | 46 | |
jah128 | 9:085e090e1ec1 | 47 | void update_display(void); |
jah128 | 9:085e090e1ec1 | 48 | void display_debug_info(void); |
jah128 | 9:085e090e1ec1 | 49 | |
jah128 | 0:8a5497a2e366 | 50 | void user_code_setup(void); |
jah128 | 0:8a5497a2e366 | 51 | void user_code_loop(void); |
jah128 | 0:8a5497a2e366 | 52 | void handle_switch_event(char switch_state); |
jah128 | 6:ff3c66f7372b | 53 | int main(void); |
jah128 | 6:ff3c66f7372b | 54 | |
jah128 | 6:ff3c66f7372b | 55 | |
jah128 | 9:085e090e1ec1 | 56 | |
jah128 | 6:ff3c66f7372b | 57 | void display_ir_readings(void); |
jah128 | 6:ff3c66f7372b | 58 | void out(const char* format, ...) ; |
jah128 | 6:ff3c66f7372b | 59 | |
jah128 | 6:ff3c66f7372b | 60 | #endif |