YRL Maze lab made more script-y
Dependencies: PsiSwarmLab-ScriptingBased mbed
Fork of UKESF_Lab by
Diff: main.cpp
- Revision:
- 17:da524989b637
- Parent:
- 16:976a1d0ea897
- Child:
- 18:5921c1853e8a
--- a/main.cpp Fri Oct 30 12:15:54 2015 +0000 +++ b/main.cpp Thu Jan 07 17:58:07 2016 +0000 @@ -33,8 +33,8 @@ unsigned short reflected_sensor_data[8]; // The reflected IR values when this robots emitters are on unsigned short background_sensor_data[8];// The raw IR values when no robot (or beacon) should have its IR on -char default_normal_program = 7; // The program to run on turn on (after 'face beacon' program) -char use_recharging_program = 1; // Set to 1 to force robot to run recharging program when battery voltage drops below a threshold +char default_normal_program = 8; // The program to run on turn on (after 'face beacon' program) +char use_recharging_program = 0; // Set to 1 to force robot to run recharging program when battery voltage drops below a threshold char user_code_debug = 1; // Set to 1 to show terminal messages from "out" function [specific to this code] char display_debug_inf = 0; // Set to 1 to show debug info about beacon\robots on display [instead of running program info] char main_program_state; // Index of the currently running program @@ -52,11 +52,19 @@ char choose_program_mode = 0; char program_count = 8; char program_selection; +int flocking_heading = 0; float battery_low_threshold = 3.60; // Threshold at which to interrupt program and start recharging routine: suggest 3.55 float battery_high_threshold = 3.95; // Threshold at which to end battery recharging routine and resume normal program: suggest 4.0 Ticker main_loop_ticker; +Ticker flocking_ticker; + +void flocking_heading_update() +{ + flocking_heading += 5; + flocking_heading %= 360; +} ///This is the main loop for the Beautiful Meme code. The code block is run once every 250mS* [with 4Hz beacon] once all the IR samples have been collected. void main_loop() @@ -108,6 +116,9 @@ case 7: tag_game_program(); break; + case 8: + flocking_program(); + break; case 255: stop_program(); break; @@ -129,6 +140,7 @@ out("------------------------------------------------------\n"); out("Beautiful Meme Project Demo Code \n"); out("------------------------------------------------------\n"); + while(1); locate_beacon(); while(beacon_found == 0) { wait(0.5); @@ -136,6 +148,7 @@ } start_infrared_timers(); main_loop_ticker.attach_us(&main_loop,BEACON_PERIOD * 10); + flocking_ticker.attach(&flocking_heading_update, 1); set_program(0); set_leds(0x00,0x00); set_center_led(3,0.5); @@ -227,6 +240,9 @@ case 7: strcpy(ret_name,"TAG GAME"); break; + case 8: + strcpy(ret_name,"FLOCKING"); + break; case 255: strcpy(ret_name,"PROGRAM:"); break;