BAMBINO ------- Bambino is a small Biped Robot driven by two servos, powered by four AAA cells, controlled by a custom Arduino Uno circuit board. It has - one ultrasonic sensor module for detecting obstacles; two forward facing optical sensors (whiskers) for detecting obstacles; two downward pointing optical sensors (Beard) for detecting table edges etc.; one sounder; one red LED to indicate when recording commands; one expansion connector; a reset switch to toggle Bambino's mode; one programming/communication connector. The two LEDs of the forward facing optical sensors glow dim when waiting for a command. Any particular one of the four sensor LEDs will stay on when avoiding a seen obstacle or table edge. Reset/power-on alternately toggles servos-enabled and servos-disabled. Index ----- Bambino programs Program descriptions #1 - #48 Bambino Commands at program #48 ReActs - actions when an obstacle is seen BEHAVES - power-on defaults set from current default Behaviour Example of ?B - print all behaviours in EEPROM Example of ?b - print current behaviour in RAM Example of ?? - print all Acts Example of ?! - print all ReActs //== SECTIONS - sections and tab files at #48 =============================================================================== Programs BambinoProMini |- B_PM01_ServosMid set servos to mid so horns can be put on in the right place |- B_PM02_BoardTest Servos to mid, flash LEDs, sound, test sensors |- B_PM03_BoardInit Initialise the EEPROM then make a sound from the speaker |- B_PM04_Servos calibrate and adjust the servo centres |- B_PM05_Rock example code for Bambino to rock from side to side |- B_PM06_Shuffle example code for Bambino to shuffle its feet |- B_PM07_WalkFd example code for Bambino to walk Forwards |- B_PM08_WalkStop a flag f_walking so Bambino on reset walks or stops |- B_PM09_Forward example code for a Forwards step |- B_PM10_Backward example code for a Backwards step |- B_PM11_TurnRight example code for a Right turn |- B_PM12_TurnLeft example code for a Left turn |- B_PM13_USsense Sense obstacles with the Ultrasonic sensor and avoid obstacles |- B_PM14_USwander Wander using the Ultasonic sensor to avoid obstacles |- B_PM15_BeardTest Test the Beard LEDs and sensors |- B_PM15_WhiskerTest Test the Whisker LEDs and sensors |- B_PM16_BeardWander Wander using the Beard to avoid table edges |- B_PM16_WhiskerWander Wander using the Whiskers to avoid obstacles |- B_PM17_Wander Wander avoiding table edges and obstacles |- B_PM18_AvoidBack a flag f_forwards so Bambino steps backwards when avoiding |- B_PM19_SpeedWander speed-up and speed-down |- B_PM20_Wander program split into Tab files |- B_PM21_PlayTime rock and shuffle routines |- B_PM22_BeAlive a routine to allow Bambino to act alive |- B_PM23_SerialCmnd commanding Bambino from the Serial Monitor or a serial terminal |- B_PM24_Learn learn and remember an Act |- B_PM25_Learn8 learn uo to 8 Acts |- B_PM26_CopyAct copy one Act to another |- B_PM27_loadAct load an Act directly from a serial terminal |- B_PM28_DumpActs Dump Acts to the PC |- B_PM29_Run8 autorun of Act 8 on reset or poweron, |- B_PM30_Wait w to Wait '1' - '9' seconds. |- B_PM31_Speed speed up/down, set speed |- B_PM32_CommanderXE Xplore, user Experiment |- B_PM33_PROGMEM Help text put in PROGMEM |- B_PM34_vbt commands for sound, vitality, turning skills |- B_PM35_Acts0 addition of a second memory page for Acts |- B_PM36_tx turn to light/dark, turn until at light/dark |- B_PM37_Mind print the robot's mind |- B_PM38_NewPrint ? - to print what is in the robot's brain |- B_PM39_Adjust b@ - to calibrate and Adjust the Serovo centres Bambino |- BA40 common program for all arduino variants |- BA41_Name # - assignment of robot Name and Group |- BA42_Autorun bax - to set the Autorun Act |- BA43_Go g0,g1 commands to disable,enable walking |- BA44_ReActs Reactions stored in EEPROM |- BA45_Behaviour 8 behaviours stored in EEPROM |- BA46_Aware background aware bG,bW,bU |- BA47_Centre adjust of paceC and rollC |- BA48_Do Grouping of Acts into a Do =============================================================================== // B_PM01_ServosMid // set servos to mid position so servo horns can be fitted in the correct orientation // servo pulse at mid position =1500 micro-seconds, equivalent to 90 degrees when using the Arduino Servo library // The Servo library is not used in order to avoid future interrupt conflicts. ------------------------------------------------------------------------------- // B_PM02_BoardTest // Set servos to mid positions - feet together, standing straight. // Flash the red LED, make a sound from the speaker, // flash the whisker and beard LEDs and measure light levels with the photo-transistors // and send the light values to the Serial Monitor. // The light values should vary and be between 0 and 1023 ------------------------------------------------------------------------------- // B_PM03_BoardInit // Initialise the EEPROM with default values // Then make a sound from the speaker, ------------------------------------------------------------------------------- // B_PM04_Servos // full instructions require a Duemilinova or bigger, ie ATmega328 or bigger /*Seting the servos with BM04_Servos ================================== This allows you to set the mid positions of both servos. When the servos are set to 90 degrees as in sketch BM01_ServosMid, because of the way each servo is made and the horns can only be put on about every 15 degrees, the feet may not be exactly side by side or flat on the ground. Load this sketch and open the Serial Monitor. Adjust the Roll servo so Bambino stands up straight and doesn't lean to the left or right. Adjust the Pace servo so Bambino stands with both feet side by side. The calibrated values are stored in EEPROM for further programs. Set servos to mid position - rollC and paceC, to check if feet are flat and feet together if not change rollC and paceC until they are Set the Pace length and Roll amount for walking. You can also set servos maximum and minimum safe angles for Roll Right and Roll Left, and Pace Left Forward and Left Back. Use the Arduino Serial Monitor set to 'no line ending', type I, *, -, +, /, C, R, P, S (or L, H) and press ENTER to send I, *, -, +, /, C, R, P, S (or L, H) Or use a Serial Terminal at 9600 baud. [I] to display instructions [*] to display current EEPROM values [-] adjust Servo position -ve [+] adjust Servo position +ve [/] to change servo. [C] to set Centre angles RollC and PaceC [R] to set the default Roll amount [P] to set the default Pace length [S] to set the servos at RollC and PaceC ([L] to set Low=Minimum angle - future use ) ([H] to set High=Maximum angle - future use ) instructions and current settings appear on screen. Servo values are in units of 1 degree nominal servo range is 0 to 180 with centre at 90 */ ------------------------------------------------------------------------------- // B_PM05_Rock // Stand in place and Rock from one foot to the other ------------------------------------------------------------------------------- // B_PM06_Shuffle // Stand in place and move feet backwards and forwards without lifting them. ------------------------------------------------------------------------------- // B_PM07_WalkFd // Walk forwards. ------------------------------------------------------------------------------- // B_PM08_WalkStop // You will have found that while Bambino is connected to the computer // there is no way to turn it off and stop it walking. // This sketch uses a flag f_walking to control whether the servos are // pulsed. Each time the Arduino awakes the value of the flag is toggled // between true and false. If the flag is true then the servo pins are // made output so the servos can be pulsed by the calls to ServoPulse. // Now by pressing the Reset switch you can stop Bambino walking and so // stop it walking off the table whilst you are loading a new sketch. // Experiment with altering rollspeed and pacespeed. ------------------------------------------------------------------------------- // B_PM09_Forward // To take a single step forwards Bambino needs to test which // foot is in front and then move the other one. To do this we // test paceat to see if it is less than paceC, if so then the // right foot is in front so Bambino should move the left foot. ------------------------------------------------------------------------------- // B_PM10_Backward // Walking backwards is the opposite of Forwards // To take a single step forwards Bambino needs to test which // foot is in front and then move the other one. To do this we // test paceat to see if it is less than paceC, if so then the // right foot is in front so Bambino should move the left foot. ------------------------------------------------------------------------------- // B_PM11_TurnRight // If each move ends with both feet flat on the ground then it doesn't // matter whether the next step is a step forward or a turn step. // void loop now has demonstration code for turning right. ------------------------------------------------------------------------------- // B_PM12_TurnLeft // If each move ends with both feet flat on the ground then it doesn't // matter whether the next step is a step forward or a turn step. // void loop now has demonstration code for turning left ------------------------------------------------------------------------------- // B_PM13_USsense // Bambino is fitted with an Ultrasonic Sensor to measure distances to objects. // By reading the sensor and taking action on the distance returned // Bambino can avoid obstacles. // A simple sample routine is given in void loop() // No routine is ever perfect, experiment with other actions. ------------------------------------------------------------------------------- // B_PM14_USwander // To better avoid obstacles three more routines are given // turnAway() turn away from the leading foot, so if the right foot is in front then turn left // turnMemory() turn the same way as last time // turnOther() turn the opposite way from last time ------------------------------------------------------------------------------- // B_PM15_BeardTest // Set servos to mid positions - feet together, standing straight. // flash the beard LEDs and measure light levels with the photo-transistors // and send the light values to the Serial Monitor. // The light values should vary and be between 0 and 1023. // Tungsten light levels fluctuate at 100Hz for 50Hz supply and 120Hz for 60Hz supply. // A 100Hz fluctuation repeats ever 10ms and 120Hz repeats every 8.3ms. // Reading are taken every 1ms for a total of 8ms, // and the max is taken of all the readings against the previous reading // so a peak light level will be included in the readings. // This gives a consistent light level reading. // // Make sure the Beard LEDs shine just in front of the feet and not on the feet. // Make sure the Beard photosensors are aimed at the light spots from the Beard LEDs. // When Bambino is on white paper there should be a big difference between the // light and dark readings. // Darker surface will give smaller differences. // When Bambino is at the edge of a table and the LEDs shine to the floor there // should be only a small difference between the light and dark readings. // In later sketches if the difference is <10 then Bambino thinks it is at an edge. // The threshold of 10 can be changed as you wish. ------------------------------------------------------------------------------- // B_PM15_WhiskerTest // Set servos to mid positions - feet together, standing straight. // flash the whisker LEDs and measure light levels with the photo-transistors // and send the light values to the Serial Monitor. // The light values should vary and be between 0 and 1023. // Tungsten light levels fluctuate at 100Hz for 50Hz supply and 120Hz for 60Hz supply. // A 100Hz fluctuation repeats ever 10ms and 120Hz repeats every 8.3ms. // Reading are taken every 1ms for a total of 8ms, // and the max is taken of all the readings against the previous reading // so a peak light level will be included in the readings. // This gives a consistent light level reading. // // Make sure the Whisker LEDs shine forwards and slightly out. // Make sure the Whisker photosensors are aimed in the same direction. // When Bambino is not in front of an object and there is no reflected light there // should be only a small difference between the light and dark readings. // In later sketches if the difference is >20 then Bambino thinks there is an obstacle. // The threshold of 20 can be changed as you wish. ------------------------------------------------------------------------------- // B_PM16_BeardWander // Use the Beard LEDs and sensors to detect table edges // while walking ------------------------------------------------------------------------------- // B_PM16_WhiskerWander // Use the Whisker LEDs and sensors to detect obstacles while walking // in QueryObstacle() note change of comparison from < for holes to > for obstacles // holes are indicated by no light being reflected, hence threshold ------------------------------------------------------------------------------- // B_PM17_Wander // Use the Beard LEDs and sensors and ultrasonic sensor to detect table edges and obstacles // Ultrasonic routine from B_PM14_USwander incorporated in avoidUObjects() ------------------------------------------------------------------------------- // B_PM18_AvoidBack // You must have noticed that when running B_PM17_Wander that // when avoiding obstacles or holes and turning right or left // Bambino steps forward and sometimes walks into an obstacle // or falls off the table! // Here is introduced f_forwards, set in forward() and backward() // which controls the step direction in turnRight() and turnLeft). // Now when avoiding Bambino will step back. ------------------------------------------------------------------------------- // B_PM19_SpeedWander // Animals including humans tend to slow down when they encounter an obstacle // and to speed up when there are no obstacles // two new functions are defined speedup() and speeddown() // speeddown() reduces the roll and pace speeds each time it is called until each speed==1 // speedup () increases the roll and pace speeds each time it is called until each speed==maxspeed ------------------------------------------------------------------------------- // B_PM20_Wander.ino /* B_PM20_Wander sketch group is functionally identical to B_PM19SpeedWander.ino The sketch was getting long and now all the basic functions are there it has been split into sections with each section in a separate file. When B_PM20_Wander, the main sketch file, is loaded into the Arduino IDE it loads the other files into Tabs. The declarations have been moved to .h Header files which at compile time the IDE includes at the #include "filename.h" statements, - note that these simple header files use "" unlike Libraries which use <>. Also an unchanging part of Setup() has been moved to Init.h. The functions have been moved to .ino files which at compile time the IDE adds, in alphabetical order, to the end of this sketch file. It is not advisable to put declarations of pins, constants or variables in those .ino files since the declarations must be before where they are referenced. So keep declarations in the .h Header files.*/ ------------------------------------------------------------------------------- // B_PM21_PlayTime.ino /* Now Bambino can move about and sense obstacles we can get it come alive. Two new routines rock() and shuffle() allow loop() to have Bambino Wander for a few steps then rock then wander again then shuffle. Routines whee() and whoa() give Bambino a better voice. Build some routines for yourself. */ ------------------------------------------------------------------------------- // B_PM22_BeAlive.ino /* By using a switch statement with a random number as the case variable Bambino can be made to do sequences which don't repeat and it seems to have a mind of its own and looks alive. Note RightStep(repeat) and LeftStep(repeat) which help it from getting stuck. Experiment with different values for the min and max in random(). You could write similar functions to RightStep(repeat) and LeftStep(repeat) for turnAway(), turnMemory(), turnOther() and add them to the switch list. If you do, remember to increase the random range for the case variable. */ ------------------------------------------------------------------------------- // B_PM23_SerialCmnd.ino /* There has to be a better way of telling Bambino what to do than keep modifying this sketch. Here we start by sending commands to bambino from the Serial Monitor, or any terminal program. The commands are 'A' - beAlive() until reset // the loop() from B_M22_BeAlive 'F' - Forwards one step 'B' - Backwards one step 'R' - turn Right one step 'L' - turn Left one step 'H' - Halt with both feet together 'V' - Voice, make a beep 'S' - Stop/Start toggle reset flag stopped/walking 'U' - read Ultrasonic sensor and react to objectRange using avoidUObjects() behaviour rules 'W' - read Whisker sensors and avoid holes (if any) using avoidObstacles() behaviour rules 'G' - read Beard sensors and avoid obstacles (if any) using avoidHoles() behaviour rules '?' - print instructions The whiskerLEDs glowing dim indicate Bambino is ready for a command. If other keys are pressed, including lower case keys, then the Whisker LEDs will flash. */ ------------------------------------------------------------------------------- // B_PM24_Learn.ino /* We can store in EEPROM a sequence of the commands used in B_PM23_SerialCmnd, then replay it. These moves will be remembered even with power off. The whiskerLEDs glowing dim indicate Bambino is ready for a command. The redLED on indicate Bambino is recording commands. The commands are '.',[Esc] - quit current operation - recording, playing 'S' - Stop/Start 'P' - Play moves Act, if included in a recording will restart the Act 'F' - Forwards one step 'B' - Backwards one step 'R' - turn Right one step 'L' - turn Left one step 'H' - Halt with both feet together 'V' - Voice, make a beep 'U' - read Ultrasonic sensor and react to objectRange using avoidUObjects() behaviour rules 'W' - read Whisker sensors and avoid holes (if any) using avoidObstacles() behaviour rules 'G' - read Beard sensors and avoid obstacles (if any) using avoidHoles() behaviour rules 'A' - beAlive() until reset // the loop() from B_M22_BeAlive 'r' - Record moves into EEPROM 'p' - Print moves in Act '?' - print instructions If other keys are pressed, including lower case keys, then the Whisker LEDs will flash badkey(). Upper-case is used for single letter commands and Lower-case will be used for parameter commands. The Act slot has 32 bytes and can have up to 31 commands with the last entry '.' indicating end of Act. Until recording mode is entered any of the commands have immediate effect. In immediate mode keys 'P' will play Act, whatever has been recorded. If 'r' is entered then the Act will start to be recorded. Bambino will 'bip' each time a command is entered in record mode. Any of the keys can be entered in recording mode including 'r' but that makes no sense and is blocked during recording as is 'p' by setting f_recordC to false. 'S','?' operate but are also blocked from being recorded by setting f_recordC to false. eg r,F,F,R,R,P,. records FFRRP. in the Act if in immediate mode 'P' is entered then the Act will be played giving Forward, Forward, turnRight, turnRight, Play so the Act will repeat until '.' or Esc is keyed. */ ------------------------------------------------------------------------------- // B_PM25_Learn8.ino /* We can store in EEPROM sequences of the commands used in B_PM23_SerialCmnd, then replay them. If each sequence which we will call an Act takes less than 32 commands then 8 routines will fit in the second 256 byte page of the EEPROM. The whiskerLEDs glowing dim indicate Bambino is ready for a command. The redLED on indicate Bambino is recording commands. The commands are '.',[Esc] - quit current operation - recording, playing, input 'S' - Stop/Start 'P' - Print moves in all Acts '1'-'8' the routine or Act to record or replay 'F' - Forwards one step 'B' - Backwards one step 'R' - turn Right one step 'L' - turn Left one step 'H' - Halt with both feet together 'V' - Voice, make a beep 'U' - read Ultrasonic sensor and react to objectRange using avoidUObjects() behaviour rules 'W' - read Whisker sensors and avoid holes (if any) using avoidObstacles() behaviour rules 'G' - read Beard sensors and avoid obstacles (if any) using avoidHoles() behaviour rules 'A' - beAlive() until reset // the loop() from B_M22_BeAlive 'r','1'-'8' - Record moves into selected Act in EEPROM 'p','1'-'8' - Print moves in selected Act '1' - '8' '?' - print instructions If other keys are pressed, including lower case keys, then the Whisker LEDs will flash badkey(). Upper-case is used for single letter commands and Lower-case is used for parameter commands. Each Act slot has 32 bytes and can have up to 31 commands with the last entry set to 0 indicating end of Act. Until programming mode is entered any of the commands have immediate effect. In immediate mode keys 1 - 8 will play the corresponding Act, whatever has been recorded. If 'r' is entered then the next key must be 1 - 8 to select the Act to be recorded. If '.' is entered instead then recording will not start. Any of the keys can be entered in recording mode including 'r' but that makes no sense and is blocked during recording as is 'p' by setting f_recordC to false. 'S','?' operate but are also blocked from being recorded by setting f_recordC to false. When recording has started keys 1 - 8 will record a jump to the corresponding Act. However in record mode playback of that Act is suppressed, hence after entering an Act number it makes no sense to add more commands since they will never get done because control will jump to the new Act; so just enter '.', or '.' to quit recording. eg r,1,F,F,R,R,1,Q or r,1,F,F,R,R,1,. records FFRR1. in Act1 if in immediate mode '1' is entered then Act1 will be played giving Forward, Forward, turnRight, turnRight, jump to Act 1 So Act 1 will play forever, Act 1 could also be invoked from another Act eg r,2,1,Q here Act 2 does nothing except jump to Act 1. '.' or Esc quits a playing Act. */ ------------------------------------------------------------------------------- //B_PM26_CopyAct.ino // Binary sketch size: 10,796 bytes (of a 30,720 byte maximum) /* Introducing the command 'c','1'-'8','1'-'8' - copy one Act to another Act slot so 'c25' will copy Act 2 to Act 5, overwriting all of Act 5 In loop() - Recording: if(f_newRec && Ccmnd=='.') {f_recording =false; } // '.',Esc from GetKey() @ case 'r' allows quit recording after keying 'r' but before keying an Act number. The commands are '.',[Esc] - quit current operation - recording, playing, input 'S' - Stop/Start 'P' - Print moves in all Acts '1'-'8' the routine or Act to record or replay 'F' - Forwards one step 'B' - Backwards one step 'R' - turn Right one step 'L' - turn Left one step 'H' - Halt with both feet together 'V' - Voice, make a beep 'U' - read Ultrasonic sensor and react to objectRange using avoidUObjects() behaviour rules 'W' - read Whisker sensors and avoid holes (if any) using avoidObstacles() behaviour rules 'G' - read Beard sensors and avoid obstacles (if any) using avoidHoles() behaviour rules 'A' - beAlive() until reset // the loop() from B_M22_BeAlive 'r','1'-'8' - Record moves into selected Act in EEPROM 'p','1'-'8' - Print moves in selected Act '1' - '8' 'c','1'-'8','1'-'8' - copy one Act to another Act slot '?' - print instructions The whiskerLEDs glowing dim indicate Bambino is ready for a command. If other keys are pressed, including lower case keys, then the Whisker LEDs will flash badkey(). */ ------------------------------------------------------------------------------- //B_PM27_loadAct.ino // Binary sketch size: xx,xxx bytes (of a 30,720 byte maximum) /* Introducing the command 'l','1'-'8' - load an Act directly from Serial Monitor without acting "l8VVVFFV." loads Act 8 with "VVVFFV." You can load command strings which won't Play or do odd things , so beware. E.g. keys 18PVV. will load PVV. into Act 8, but after P the VV will never be done. E.g. l8VVp8VV. will load VVp8VV. and when played Bambino plays VV then does 'p' and wants an Act number to print, when the Act is printed the EEPROMindex will point to the end of the printed Act so Play will end when that is read. However if . is entered instead of an Act number then the '8' after 'p' will be read and Act 8 will be done again The commands are '.',[Esc] - quit current operation - recording, playing, input 'S' - Stop/Start 'P' - Print moves in all Acts '1'-'8' the routine or Act to record or replay 'F' - Forwards one step 'B' - Backwards one step 'R' - turn Right one step 'L' - turn Left one step 'H' - Halt with both feet together 'V' - Voice, make a beep 'U' - read Ultrasonic sensor and react to objectRange using avoidUObjects() behaviour rules 'W' - read Whisker sensors and avoid holes (if any) using avoidObstacles() behaviour rules 'G' - read Beard sensors and avoid obstacles (if any) using avoidHoles() behaviour rules 'A' - beAlive() until reset // the loop() from B_M22_BeAlive 'r','1'-'8' - Record moves into selected Act in EEPROM 'p','1'-'8' - Print moves in selected Act '1' - '8' 'c','1'-'8','1'-'8' - copy one Act to another Act slot 'l','1'-'8' - load Act, like 'r' but records commands into EEPROM without playing them '?' - print instructions The whiskerLEDs glowing dim indicate Bambino is ready for a command. If other keys are pressed, including lower case keys, then the Whisker LEDs will flash badkey(). */ ------------------------------------------------------------------------------- //B_PM28_DumpActs.ino // Binary sketch size: 11,596 bytes (of a 30,720 byte maximum) /* Introducing the command D to dump all Acts the the PC without names or length information. The output from D can be copied from the Serial Monitor, saved to a file, edited and pasted back into the Serial Monitor and loaded into Bambino. Load with 'l' load '1' - '8'. If the Acts are short all can be pasted ay once. Otherwise load one Act at a time to prevent overloading the Aduino serial buffer. As before - You can load command strings which won't Play or do odd things , so beware. E.g. keys 18PVV. will load PVV. into Act 8, but after P the VV will never be done. E.g. l8VVp8VV. will load VVp8VV. and when played Bambino plays VV then does 'p' and wants an Act number to print, when the Act is printed the EEPROMindex will point to the end of the printed Act so Play will end when that is read. However if . is entered instead of an Act number then the '8' after 'p' will be read and Act 8 will be done again The commands are '.',[Esc] - quit current operation - recording, playing, input 'S' - Stop/Start 'P' - Print moves in all Acts 'D' - Dump out all acts to the PC, same as 'P' but without the Act and moves numbers. '1'-'8' the routine or Act to record or replay 'F' - Forwards one step 'B' - Backwards one step 'R' - turn Right one step 'L' - turn Left one step 'H' - Halt with both feet together 'V' - Voice, make a beep 'U' - read Ultrasonic sensor and react to objectRange using avoidUObjects() behaviour rules 'W' - read Whisker sensors and avoid holes (if any) using avoidObstacles() behaviour rules 'G' - read Beard sensors and avoid obstacles (if any) using avoidHoles() behaviour rules 'A' - beAlive() until reset // the loop() from B_M22_BeAlive 'r','1'-'8' - Record moves into selected Act in EEPROM 'p','1'-'8' - Print moves in selected Act '1' - '8' 'c','1'-'8','1'-'8' - copy one Act to another Act slot 'l','1'-'8' - load Act, like 'r' but records commands into EEPROM without playing them '?' - print instructions The whiskerLEDs glowing dim indicate Bambino is ready for a command. If other keys are pressed, including lower case keys, then the Whisker LEDs will flash badkey(). */ ------------------------------------------------------------------------------- //B_PM29_Run8.ino // Binary sketch size: 11,596 bytes (of a 30,720 byte maximum) /* Introducing autorun of Act 8 on reset or poweron, set in the #define below so it is easy to alter. Walking/Stopped still operates as before. The commands are '.',[Esc] - quit current operation - recording, playing, input 'S' - Stop/Start 'P' - Print moves in all Acts 'D' - Dump out all acts to the PC, same as 'P' but without the Act and moves numbers. '1'-'8' the routine or Act to record or replay 'F' - Forwards one step 'B' - Backwards one step 'R' - turn Right one step 'L' - turn Left one step 'H' - Halt with both feet together 'V' - Voice, make a beep 'U' - read Ultrasonic sensor and react to objectRange using avoidUObjects() behaviour rules 'W' - read Whisker sensors and avoid holes (if any) using avoidObstacles() behaviour rules 'G' - read Beard sensors and avoid obstacles (if any) using avoidHoles() behaviour rules 'A' - beAlive() until reset // the loop() from B_M22_BeAlive 'r','1'-'8' - Record moves into selected Act in EEPROM 'p','1'-'8' - Print moves in selected Act '1' - '8' 'c','1'-'8','1'-'8' - copy one Act to another Act slot 'l','1'-'8' - load Act, like 'r' but records commands into EEPROM without playing them '?' - print instructions The whiskerLEDs glowing dim indicate Bambino is ready for a command. If other keys are pressed, including lower case keys, then the Whisker LEDs will flash badkey(). */ ------------------------------------------------------------------------------- //B_PM30_Wait.ino // Binary sketch size: 11,596 bytes (of a 30,720 byte maximum) /* Introducing the command 'w' ' to wait '1' - '9' seconds. GetCcmnd: and Record: made into functions to better handle command parameters The commands are '.',[Esc] - quit current operation - recording, playing, input 'S' - Stop/Start 'P' - Print moves in all Acts 'D' - Dump out all acts to the PC, same as 'P' but without the Act and moves numbers. '1'-'8' the routine or Act to record or replay 'F' - Forwards one step 'B' - Backwards one step 'R' - turn Right one step 'L' - turn Left one step 'H' - Halt with both feet together 'V' - Voice, make a beep 'U' - read Ultrasonic sensor and react to objectRange using avoidUObjects() behaviour rules 'W' - read Whisker sensors and avoid holes (if any) using avoidObstacles() behaviour rules 'G' - read Beard sensors and avoid obstacles (if any) using avoidHoles() behaviour rules 'A' - beAlive() until reset // the loop() from B_M22_BeAlive 'w','1'-'9' - wait 1 - 9 seconds. 'r','1'-'8' - Record moves into selected Act in EEPROM 'p','1'-'8' - Print moves in selected Act '1' - '8' 'c','1'-'8','1'-'8' - copy one Act to another Act slot 'l','1'-'8' - load Act, like 'r' but records commands into EEPROM without playing them '?' - print instructions The whiskerLEDs glowing dim indicate Bambino is ready for a command. If other keys are pressed, including lower case keys, then the Whisker LEDs will flash badkey(). */ ------------------------------------------------------------------------------- //B_PM31_Speed.ino // Binary sketch size: 12,650 bytes (of a 30,720 byte maximum) /* Introducing 'su' - speedup, speed is increased by 1 'sd' - speed down, speed is divided by 2 's', '1'-'9' set speed speeds set by 'su' and 's' are max'd to rollspeedmax and pacespeedmax and min'd to 1 'sr','1'-'9' set roll speed 'sp','1'-'9' set pace speed 'sm' - set rollspeedmax to current rollspeed, set pacespeedmax to current pacespeed 'srm' - set rollspeedmax to current rollspeed 'spm' - set pacespeedmax to current pacespeed 'P' now also prints behaviour variables The commands are '.',[Esc] - quit current operation - recording, playing, input 'S' - Stop/Start 'P' - Print moves in all Acts, and behaviour variables 'D' - Dump out all acts to the PC, same as 'P' but without the Act and moves numbers. '1'-'8' the routine or Act to record or replay 'F' - Forwards one step 'B' - Backwards one step 'R' - turn Right one step 'L' - turn Left one step 'H' - Halt with both feet together 'V' - Voice, make a beep 'U' - read Ultrasonic sensor and react to objectRange using avoidUObjects() behaviour rules 'W' - read Whisker sensors and avoid holes (if any) using avoidObstacles() behaviour rules 'G' - read Beard sensors and avoid obstacles (if any) using avoidHoles() behaviour rules 'A' - beAlive() until reset // the loop() from B_M22_BeAlive 'w','1'-'9' - wait 1 - 9 seconds. 'su' - speedup, speed is increased by 1 up to max 'sd' - speed down, speed is divided by 2 down to 1 's','1'-'9' set speed, both roll and pace speeds set to the same 'sr','1'-'9' set roll speed 'sp','1'-'9' set pace speed 'sm' - set rollspeedmax to current rollspeed, set pacespeedmax to current pacespeed 'srm' - set rollspeedmax to current rollspeed 'spm' - set pacespeedmax to current pacespeed 'r','1'-'8' - Record moves into selected Act in EEPROM 'p','1'-'8' - Print moves in selected Act '1' - '8' 'c','1'-'8','1'-'8' - copy one Act to another Act slot 'l','1'-'8' - load Act, like 'r' but records commands into EEPROM without playing them '?' - print instructions The whiskerLEDs glowing dim indicate Bambino is ready for a command. If other keys are pressed, including lower case keys, then the Whisker LEDs will flash badkey(). */ ------------------------------------------------------------------------------- //B_PM32_CommanderXE.ino /* Introducing 'X' to Xplore which just calls Wander() 'E' Experiment - call your own routines ------------------------------------------------------------------------------- //B_PM33_PROGMEM.ino // Binary sketch size: 12,826 bytes (of a 30,720 byte maximum) /* Sooner or later it had to happen that due to the peculiar(stupid) way the Arduino moves all undefined strings to RAM the program runs out of RAM, so before we can add to the printHelp() messages we need to put the text in PROGMEM. See http://arduino.cc/en/Reference/PROGMEM To use PROGMEM we need to do #include Put the help text strings in program memory, build a table to index the strings then amend printHelp() to read the strings. ------------------------------------------------------------------------------- //B_PM34_vbt.ino // Binary sketch size: 13,720 bytes (of a 30,720 byte maximum) /* Introducing 'v', 'b','e','o' choose sound: 'b' bip, 'e' whee, 'o' whoa 'b', 'p','1'-'9' set behave paceby - step length 't','1'-'9' set behave turnby - step length in turns 'r','1'-'9' set behave rollby - roll amount when stepping A new Tab file skills34.ino for 't', 'a' - turn Away from leading foot, 'm' - turn Memory (same way as last turn, 'o' - turn Other way from last time these will be used in avoid Acts ------------------------------------------------------------------------------- //B_PM35_Acts0.ino // Binary sketch size: 14,022 bytes (of a 30,720 byte maximum) /* Introducing Acts page 0 Eight Acts is not a lot and the Arduino has four 256 byte EEPROM pages. The existing eight Acts only use one of the four pages. One page has initialisation data and one other page will have the rules specifying what to do if the Ultrasonic or optical sensors see something, at present these rules are hard coded in the program but it would be good if they could be changed as easily as the Acts. We can use EEPROM page 2 for eight more Acts leaving page 3 available for the sensor rules. There needs to be a simple way of addressing these next eight Acts. Decoding multi digit numbers involves parsing the numbers from the rest of the commands in the Act and would add complexity. An easier way is if the second set of eight Acts are in logical page 0 and an Act number for these Acts starts with 0 giving Acts 01 to 08, then if a zero is read the next number addresses an Act in page 0. If this logical page 0 is actually in page 3 of the EEPROM then this will work. So far no command starts with the number 0 or 9, we could have had Acts 91 to 98 but I prefer 01 to 08. So 05 would address Act 5 in page 0 and so would ..0FFR5 etc. ------------------------------------------------------------------------------- //B_PM36_tx.ino // Binary sketch size: 14,904 bytes (of a 30,720 byte maximum) /* Introducing tl - turn to light using the whisker light sensors td - turn to dark using the whisker light sensors t@l - turn until @ light using the whisker light sensors t@d - turn until @ dark using the whisker light sensors ------------------------------------------------------------------------------- //B_PM37_Mind.ino // Binary sketch size: 15,168 bytes (of a 30,720 byte maximum) /* Introducing M - print current Behaviour, BeHaves in Mind (RAM values) ------------------------------------------------------------------------------- //B_PM38_NewPrint.ino // Binary sketch size: 15,370 bytes (of a 30,720 byte maximum) /* Introducing ?h print Help ?p print Page ?x print Act ?? print current Act ?b print Behaviour ?m print Mind Removed 'P' 'M' 'D' 'p' ------------------------------------------------------------------------------- //B_PM39_Adjust.ino // Binary sketch size: 17,730 bytes (of a 30,720 byte maximum) /* Re-introducing Adjust Servos of Prog4 invoked here by b@ =============================================================================== //BA40.ino //#define BambinoPM //#define BambinoMM #define BambinoM2 // Binary sketch size: 17,584 bytes (of a 30,720 byte maximum) /*== Notes ================================================== Common program for all Arduino Bambinos No additional changes. ------------------------------------------------------------------------------- //BA41_Name.ino // Binary sketch size: 18,966 bytes (of a 30,720 byte maximum) /*== Notes ================================================== Introducing b# Set the robot Name, where Name can be any character b#<'0'-'9'> Set the robot Group 0 - 9 bq robot turns off Debug messages f_BeQuiet - disable print messages if true f_MsgForMe - read but ignore messages if true f_hashcmnd - waiting for the second byte of a # command so don't Play f_hashhashSTOP - ## Stop from external commander so stop command doesn't get overwritten by GetCommand hashhashAt - remember EEPROMindex at hashhashSTOP boolean Quit() //check for Quit - simplifies checking for Quit Introducing message prefixes #0 all the following commands are for every robot, all robots turn off Debug messages # all the following commands are for the Named robot, other robots are silent # all the following commands are for the Group, robots are silent ## (default) robots stop and obey all commands and send Debug messages robots remember what they were doing in hashhashAt useful to talk to an unknown robot or put all in the stopped state #< robots do their Default Act #> robots resume their Act from hashhashAt #? all robots reply with their name and group - delayed according to name ------------------------------------------------------------------------------- //BA42_Autorun.ino // Binary sketch size: 19,440 bytes (of a 30,720 byte maximum) /*== Notes ================================================== Introducing ba<0-8> = set Act to Autorun on PowerOn or Reset, 0 means no autorun ba9 = set Autorun act to run when there is nothing else to do Bugfix If S was used to disable walking by turning off the servos and further walking c ommands given then the actual feet positions no longer agreed with rollat and paceat so when the servos were re-enabled a jerk often occurred. The new variables Srollat and Spaceat are used to remember rollat and paceat when S is used to turn off walking and rollat and paceat are set to Srollat and Spaceat when walking is re-enabled. ------------------------------------------------------------------------------- //BA43_Go.ino // Binary sketch size: 19,532 bytes (of a 30,720 byte maximum) /*== Notes ================================================== Previously there was no way to set walking on or off specifically except by the # commands. 'S' demands a human look at the robot and send 'S' as appropriate to make the robot walk or stop. Introducing g0 - turn off walking g1 - turn on walking ------------------------------------------------------------------------------- //BA44_ReActs.ino // Binary sketch size: 21,344 bytes (of a 30,720 byte maximum) //set Serial terminal to 9600 baud /*== Notes ================================================== Previously Reactions were hard coded in the program which meant they couldn't be altered as easily as writing a new Act. Behaviour parameters are stored in EEPROM page 0, Acts are stored in EEPROM pages 1 and 2, Acts in page 1 and Acts0 in page 2 Which leaves EEPROM page 3 spare. Reactions will now be stored in EEPROM page 3 which will allow easy experimentation with different Reactions. There are 8 slots available and they are allocated as Reaction-1 - Reaction if Ultrasonic distance is less than 'aware at' value hence objects farther away than 'aware at' value are ignored Reaction-2 - Reaction if Ultrasonic distance is less than 'too close' value i.e. objects are too close Reaction-3 - Reaction if both Left and Right Whiskers sense an object Reaction-4 - Reaction if Left Whisker senses an object Reaction-5 - Reaction if Right Whisker senses an object Reaction-6 - Reaction if both Left and Right Beard sensors detect a hole Reaction-7 - Reaction if Left Beard sensor detects a hole Reaction-8 - Reaction if Right Beard sensor detects a hole Introducing ! to change to EEPROM page 3, Reactions, in the same way as 0 changes to Acts page 0. Reactions can be recorded or loaded just like Acts. !r1 - records Reaction-1 etc. !1 - plays Reaction-1 etc l!1 or !l1 - loads Reaction-1 etc bum+ - set manually SonarAwareAt, units 50mm/2inch bum- - set manually SonarTooNear, units 50mm/2inch bu+,0-9 - set SonarAwareAt, units 50mm, distance beyond which objects are ignored bu-,0-9 - set SonarTooNear, units 50mm, distance at which objects are too near bus - save current Sonar settings to EEPROM ------------------------------------------------------------------------------- //BA45_Behaviour.ino // Binary sketch size: 28,434 bytes (of a 30,720 byte maximum) ProMini // Binary sketch size: 28,434 bytes (of a 32,256 byte maximum) UNO M2 Introducing b,1-8 - set behaviour slot and copy contents to current behaviour in RAM bs,1-8 - save current behaviour to a slot bl,1-8 - load a behaviour slot, ,...,#, etc. otherwise load all byte values/chars., depends on Terminal software used. ?B - print all Behaviour slots as a table ------------------------------------------------------------------------------- //BA46_Aware.ino // Binary sketch size: 29,980 bytes (of a 30,720 byte maximum) ProMini // Binary sketch size: 30,076 bytes (of a 32,256 byte maximum) UNO M2 Introducing Being Aware bG<0,1> - automatic sense Ground, 0=off, 1=on bW<0,1> - automatic sense Whiskers, 0=off, 1=on bU<0,1> - automatic sense Ultrasonic, 0=off, 1=on These commands set up automatic sensing and reacting before each new command (except when recording) They add another state to the program so now there are recording, playing, reacting and aware. ------------------------------------------------------------------------------- //BA47_Centre.ino // Sketch uses 25662 bytes (83%) of program storage space. Maximum is 30720 bytes. ProMini Arduino 1.8.2 // Sketch uses 25662 bytes (79%) of program storage space. Maximum is 32256 bytes. UNO M2 Arduino 1.8.2 Introducing Cr+,Cr- (0-9) - alter rollC in current mind in RAM - offset from rollC in current behaviour in EEPROM Cp+,Cp- (0-9) - alter paceC in current mind in RAM - offset from paceC in current behaviour in EEPROM This gives an easier way to see the effects of rollC and paceC offsets than using b@ to Adjust Servos ------------------------------------------------------------------------------- //BA48_Do.ino // Sketch uses 25906 bytes (80%) of program storage space. Maximum is 32256 bytes. UNO M2 Arduino 1.8.2 // Sketch uses 25906 bytes (84%) of program storage space. Maximum is 30720 bytes. ProMini Arduino 1.8.2 Introducing ( - start of a Do, a jump to an Act will on . continue in the Do will show its location in EEPROM when played If a jump is made to an Act which contains another Do then that Do will become the current Do and the old Do will be forgotten. ) - end of a Do will show its location in EEPROM when played Q or [Esc] to Quit all, needed to quit from a Do =============================================================================== ------------------------------------------------------------------------------- =============================================================================== BambinoCommands48.txt Control of Bambino from the Serial Monitor ------------------------------------------ Just as with a washing machine controller where you wouldn't expect to have to write more microcontroller code just to get it to do a different wash cycle so neither is it desirable to have to continually write Arduino code to change what Bambino does. The following commands can be entered from the Serial Monitor (or other Terminal) set to 9600 baud and sequences of commands can be recorded in the EEPROM so Bambino remembers them even when turned off. The sequences of commands can then be replayed. If each sequence which we will call an Act takes less than 32 commands then 8 Acts will fit in the second 256 byte page of the EEPROM. A second set of eight Acts will fit in the third 256 byte page of the EEPROM. These are addressed as logical Page0 by prefixing with 0 the 1-8 Act number. So sixteen Acts can be remembered. 01,02,03,04,05,06,07,08,1,2,3,4,5,6,7,8 An Act can have up to 31 commands followed by '.' indicating end of the Act. Any of the first 8 Acts can be set to autorun on poweron or reset. A further 8 ReActs which set the moves to make depending on Sensor values are held in EEPROM page3. These can be learned, loaded and played as the Acts. See the ReActs section below. Bambino can have up to 8 different Behaviours holding the BeHave parameters, see ?B, b,1-8, and bs,1-8. These are held in EEPROM page0. Bambino alternately enables or disables the servos after a reset or power on. The whiskerLEDs glowing dim indicate Bambino is ready for a command. The redLED on indicate Bambino is recording commands. The '>' prompt in the Serial Monitor indicates Bambino is ready for a command. Primary command letters used - 012345678 !?#. ABEFGHLRSUVWX bclrstvw The commands are 'Q',[Esc] - quit all, go to command mode '.' - quit current operation - recording, playing, input 'S' - Stop/Start '(' - start of a Do, a jump to an Act will on . continue in the Do will show its location in EEPROM when played If a jump is made to an Act which contains another Do then that Do will become the current Do and the old Do will be forgotten. ')' - end of a Do will show its location in EEPROM when played '0' - use page0 for the next Act or command '!' - use page3=Reacts for the next ReAct or command '1'-'8' the routine or Act to record or replay, Act-8 autoruns on poweron or reset. 'F' - Forwards one step 'B' - Backwards one step 'R' - turn Right one step 'L' - turn Left one step 'H' - Halt with both feet together 'V' - Voice, make a beep, whee 'U' - read Ultrasonic sensor and react to objectRange using avoidUObjects() behaviour rules 'W' - read Whisker sensors and avoid obstacles (if any) using avoidObstacles() behaviour rules 'G' - read Beard sensors and avoid holes (if any) using avoidHoles() behaviour rules 'A' - beAlive() until '.' or reset // the loop() from B_M22_BeAlive 'X' - Xplore() until '.' or reset // Wander() 'E' - Experiment - user routine until '.' or reset 'vb','ve','vo' choose sound: 'b' bip, 'e' whee, 'o' whoa 'w','1'-'9' - wait 1 - 9 seconds 'g0' - (go 0) turn off walking 'g1' - (go 1) turn on walking 's','1'-'9' set speed, both roll and pace speeds set to the same 'u' - speedup, speed up/down enabled, speed is increased by 1 up to max 'd' - speed down, speed up/down enabled, speed is divided by 2 down to 1 'r','1'-'9' set roll speed units of servo degrees change per frame 'p','1'-'9' set pace speed units of servo degrees change per frame 'm' - set rollspeedmax to current rollspeed, set pacespeedmax to current pacespeed 'rm' - set rollspeedmax to current rollspeed 'pm' - set pacespeedmax to current pacespeed 't','a' - turn Away from leading foot, will be used in avoid Acts 'm' - turn Memory (same way as last turn, will be used in avoid Acts 'o' - turn Other way from last time, will be used in avoid Acts 'l' - turn to light 'd' - turn to dark '@l' - turn until @ light '@d' - turn until @ dark MODIFY MACHINE 'mr+','0'-'9' - alter rollC in current behaviour in RAM - +ve offset from rollC in current behaviour in EEPROM 'mr-','0'-'9' - alter rollC in current behaviour in RAM - -ve offset from rollC in current behaviour in EEPROM 'mp+','0'-'9' - alter paceC in current behaviour in RAM - +ve offset from paceC in current behaviour in EEPROM 'mp-','0'-'9' - alter paceC in current behaviour in RAM - -ve offset from paceC in current behaviour in EEPROM BEHAVIOUR 'b','1'-'8' - set current default behaviour and copy to RAM BeHaves 's','1'-'8' - save current RAM BeHaviour to EEPROM Behaviour 1-8 'l','1'-'8' - load behaviour slot 1-8 '#','A-Z','a-z' - robot name A-Z,a-z '1'-'9' - robot group 1 - 9 'a','0'-'8' = set Autorun Act, '0' means no autorun 'a','9' - set Autorun act to run when there is nothing else to do, ## turns it off not remembered through reset/power-off - default off 'p','1'-'9' - set paceby - step length units of 2 servo degrees 't','1'-'9' - set turnby - step length in turns units of 2 servo degrees 'r','1'-'9' - set rollby - roll amount when stepping units of 2 servo degrees 'q' - Quiet - turn off status messages 'um+' - set manually SonarAwareAt, units 5cm 'um-' - set manually SonarTooNear, units 5cm 'u+','0'-'9' - set SonarAwareAt, units 5cm 'u-','0'-'9' - set SonarTooNear, units 5cm 'uc0' - Sonar distance in inches 'uc1' - Sonar distance in centimetres 'us' - save current Sonar settings to EEPROM 'G','0'-'9' - automatic sense Ground, 0=off, 1=on 'W','0'-'9' - automatic sense Whiskers, 0=off, 1=on 'U','0'-'9' - automatic sense Ultrasonic, 0=off, 1=on '@' - Adjust Servos SYSTEM 'r','1'-'8' - Record moves into selected Act in EEPROM 'c','1'-'8','1'-'8' - copy one Act to another Act slot 'l','1'-'8' - load Act, like 'r' but records commands into EEPROM without playing them '?','h' - print Help instructions '1'-'8' - Print moves in selected Act '1' - '8' 'p' - print current Page '?' - print current Page 'd' - Dump out all acts to the PC, same as 'p' but without the Act and moves numbers. 'b' - print Behaviour - behaviour variables in RAM 'B' - print all Behaviours in EEPROM 'm' - print Mind - all Acts, Behaviour '!' - print ReActs '#','0' - message for all robots, robots silent '1-9' - message for robot group 1 - 9, robots silent 'A-Z,a-z' - message for robot name A-Z,a-z, other robots silent '#' - (default) robots stop, obey all commands and send messages useful to talk to an unknown robot or put all in the stopped state '<' - do Default Act '>' - resume Act '?' - all robots reply with their name and group - delayed according to name The whiskerLEDs glowing dim indicate Bambino is ready for a command. If other keys are pressed, including lower case keys, then the Whisker LEDs will flash badkey(). Upper-case is used for single letter commands and Lower-case will be used for parameter commands. Until programming mode is entered any of the commands have immediate effect. In immediate mode keys 1 - 8 will play the corresponding Act, whatever has been recorded. If 'r' is entered then the next key must be 1 - 8 to select the Act to be recorded. If '.' is entered instead then recording will not start. Any of the keys can be entered in recording mode including 'r' but that makes no sense and is blocked during recording as is 'p' by setting f_recordC to false. 'S','?' operate but are also blocked from being recorded by setting f_recordC to false. When recording has started keys 1 - 8 will record a jump to the corresponding Act. However in record mode playback of that Act is suppressed, hence after entering an Act number it makes no sense to add more commands since they will never be done because control will jump to the new Act; so just enter '.' to quit recording. E.g. "r1FFRR1." records "FFRR1." in Act1 if in immediate mode '1' is entered then Act-1 will be played giving Forward, Forward, turnRight, turnRight, jump to Act 1 So Act 1 will play forever, Act 1 could also be invoked from another Act eg "r21." here Act 2 does nothing except jump to Act-1. '.' or Esc quits a playing Act. To autorun 'beAlive' or 'Xplore' or 'Experiment' enter 'l8A.' or l8X.' or l8E.'. If an Act is playing or auto-running then enter '.' first until you get the '>' prompt. The command 'l','1'-'8' - loads an Act directly from the Serial Monitor without acting E.g. "l7VVVFFV." loads Act-7 with "VVVFFV." You can load command strings which either won't Play or do odd things , so beware. E.g. keys l7?pVV. will load "?pPVV." into Act-7, but after '?p' the "VV" will never be done. E.g. "l7VV?7VV." will load "VV?7VV." into Act-7 and when played Bambino plays VV then does '?' which expects an Act number for the Act to print, when the Act is printed the EEPROMindex will point to the end of the printed Act so Play will end. However if '.' is entered instead of an Act number then the '7' after '?' will be read and Act-7 will be done again. '?d' dumps all Acts to the the PC without names or length information. The output from ?d can be copied from the Serial Monitor, saved to a file, edited and pasted back into the Serial Monitor and loaded into Bambino. Load with 'l' then '1' - '8'. If the Acts are short all can be pasted at once. Otherwise load one Act at a time to prevent overloading the Arduino serial buffer. */ /* ============================================================= ReActs ====== Reactions stored in EEPROM page 3 as 8 slots of 32 bytes, Reactions can have the same commands as Acts and ended with ".". When a sensor test is made in an Act and something is detected then the relevant Reaction is played then the Act continues. Reaction-1 - Reaction if Ultrasonic distance is less than 'aware at' value hence objects farther away than 'aware at' value are ignored Reaction-2 - Reaction if Ultrasonic distance is less than 'too close' value i.e. objects are too close Reaction-3 - Reaction if both Left and Right Whiskers sense an object Reaction-4 - Reaction if Left Whisker senses an object Reaction-5 - Reaction if Right Whisker senses an object Reaction-6 - Reaction if both Left and Right Beard sensors detect a hole Reaction-7 - Reaction if Left Beard sensor detects a hole Reaction-8 - Reaction if Right Beard sensor detects a hole Example of ?! - print all ReActs >?! ReAct1 vbtm. - 4 moves ReAct2 vosdBtatmtm. - 11 moves ReAct3 sdBtotmtmtmtm. - 13 moves ReAct4 sdBRRRR. - 7 moves ReAct5 sdBLLLL. - 7 moves ReAct6 sdBtotmtmtmtm. - 13 moves ReAct7 sdBRRRR. - 7 moves ReAct8 sdBLLLL. - 7 moves > ============================================================= BEHAVES - power-on defaults set from current default Behaviour in @EEPROM ======= sense behaves SonarAwareAt is @EEPROM value SonarTooNear is @EEPROM value speed behaves - set in void setup() rollspeed is @EEPROM value pacespeed is @EEPROM value rollspeedmax is @EEPROM value pacespeedmax is @EEPROM value move behaves - set in void setup() init42.h rollby is @EEPROM value, set by B_PM04_Servos or AdjustServos() paceby is @EEPROM value, set by B_PM04_Servos or AdjustServos() turnby is paceby rollC is @EEPROM value, set by B_PM04_Servos or AdjustServos() paceC is @EEPROM value, set by B_PM04_Servos or AdjustServos() react behaves bG is @EEPROM value bW is @EEPROM value bU is @EEPROM value varsCons44.h rollC =90; default, AdjustServos39.ino, roll centre = 90 degrees (ie 1500us) => upright paceC =90; default, AdjustServos39.ino, pace centre = 90 degrees (ie 1500us) => feet together Servoframe =20; never changed, Servo frame rate millisecs ============================================================= Behaviour parameters are stored in EEPROM page 0, 8 sets 32 bytes For a new robot slots initialised and slot8 set as default behaviour Note 26 Erollmin - never altered, not used 25 Erollmax - never altered, not used 24 Epacemin - never altered, not used 23 Epacemax - never altered, not used 9-0 spare Example of ?B - print all behaviours in EEPROM >?B BEHAVIOUR b1 b2 b3 b4 b5 b6 b7 b8 # BeHave -- -- -- -- -- -- -- -- 31 f_walking 1 1 0 0 0 0 0 0 0=false, 1=true 30 rollC 85 85 85 85 85 85 85 85 servo degrees 29 paceC 89 89 89 89 89 89 89 89 servo degrees 28 rollby 15 15 15 15 15 15 15 15 servo degrees 27 paceby 15 15 15 15 15 15 15 15 servo degrees 22 rname a a a a a a a a A-Z,a-z 21 rgroup 1 1 1 1 1 1 1 1 0-9 20 autoAct 1 1 1 1 1 1 1 1 0-8 19 SonarAwareAt 5 5 5 5 5 5 5 5 0-9, units 5cm or 2inch 18 SonarTooNear 2 2 2 2 2 2 2 2 0-9, units 5cm or 2inch 17 Sonar use cm 1 1 1 1 1 1 1 1 0=false, 1=true 16 rollspeedmax 4 4 4 4 4 4 4 4 1-9 15 pacespeedmax 6 6 6 6 6 6 6 6 1-9 14 rollspeed 1 1 1 1 1 1 1 1 1-9 13 pacespeed 1 1 1 1 1 1 1 1 1-9 12 autosenseG 0 0 0 0 0 0 0 0 0,1 11 autosenseW 0 0 0 0 0 0 0 0 0,1 10 autosenseU 0 0 0 0 0 0 0 0 0,1 -- @Behaviour . . @ . . . . . > ============================================================= Example of ?b - print current behaviour in RAM >?b BA46_Aware robot a1 MsgForMe=1 BeQuiet=0 3 Behaviour 0 walking 1 autoAct 0 autorun 1 rollspeed 1 pacespeed 4 rollspeedmax 6 pacespeedmax 15 rollby 15 paceby 15 turnby 85 rollC 89 paceC 5 SonarAwareAt 2 SonarTooNear 0 autosenseG 0 autosenseW 0 autosenseU > ============================================================= Acts are stored in EEPROM pages 1 and 2 Example of ?? - print all Acts >?? Act1 GFVBR1. - 6 moves Act2 B2. - 2 moves Act3 Fsu3. - 4 moves Act4 w2V4. - 4 moves Act5 BBB. - 3 moves Act6 WFsu6. - 5 moves Act7 VVw2VV. - 6 moves Act8 veFvoFvbF8. - 10 moves Act01 FFF. - 3 moves Act02 BBB. - 3 moves Act03 RRR. - 3 moves Act04 GWUFsu04. - 8 moves Act05 VV05. - 4 moves Act06 FBBFVevo05. - 10 moves Act07 FBBFVevo05. - 10 moves Act08 FFFBBB. - 6 moves > ============================================================= //== SECTIONS =============================================== //== NEW //== CHANGED //== INCLUDES // pins20.h - pin usage // varsCons47.h - EEPROM addresses, general, Ultrasonic module HC-SR04 // EEPROM.h - the Arduino EEPROM library // avr/pgmspace.h - to allow the printHelp() text to be in ProgramSpace //== VARIABLES and CONSTANTS //== HELP TEXT // PROGMEM //== SETUP // init46.h - Initialise various things //== LOOP //== FUNCTIONS // GetCcmnd() //reads Serial or playing Act until Ccmnd != 0, prints Ccmnd // RecordCcmnd() // Experiment() //until Quit // Xplore() //Wander() until Quit // makeCcmndDigit() ensure 1-9 // waitCcmndSecs() //read delay time from Act and wait // printMind() // PrintReActs() // loadBehaviour() // get1char() // getnum() // printBehaviour() // PrintBehaviours() // DumpActs() //Dump Acts, Print without names and length // loadAct() // copyAct() // Ccmnd <- PlayAct() // PrintAllActs() // printAct() // Act <- getAct() //called when recording, loading, printing and copying Acts // setEEPROMindexes(char Act) // changes EEPROMindex, ActEnd // badkey() // indicate invalid key // printHelp() // USreact() // read Ultrasonic sensor and react to objectRange using avoidUObjects() behaviour rules // WhiskerReact() // read Whisker sensors and avoid holes (if any) using avoidObstacles() behaviour rules // BeardReact() // read Beard sensors and avoid obstacles (if any) using avoidHoles() behaviour rules // beAlive() // the loop() from BA22_BeAlive // redLEDdim() - BambinoMM only // redLEDon() // redLEDoff() // bip() // make a bip sound // whiskerLEDsDim() - not BambinoMM // whiskerLEDsOff() - not BambinoMM //TAB FILES // AdjustServos45.ino // AdjustServos(), printEEPROMvalues(), printAdjustInstructions() // PROGMEM adjust_instructions // acts23.ino // ACTS - WanderSteps(steps), Wander() // RightStep(steps), LeftStep(steps) // rock(repeats), shuffle(repeats) // SOUND - whee(), whoa() // behaviour44.ino // BEHAVIOUR MODIFIERS - speeddown(), speedup() // BEHAVIOUR RULES - reactUObjects(), reactObstaclesLR(), reactHolesLR() // - avoidUObjects(), avoidObstaclesLR(), avoidHolesLR() // sense44.ino // SENSE - dist_HC_SR04() / - readWhiskers(), QueryObstacle(), showWhiskerLightLevels(), showObstacles() // - readBeard(), QueryEdge(), showBeardLightLevels(), void showHoles() // - readLight() // movement34.ino // MOVEMENT - forward(), backward(), turnRight(), turnLeft(), // halt(), // rollCentre(), rollLeft(), rollRight(), // paceCentre(), paceLeftForward(), paceRightForward(), // paceLeftBackward(), paceRightBackward(), // turnLeftForward(), turnRightForward(), // turnLeftBackward(), turnRightBackward(), // rollmove(), pacemove() // skills41.ino // SKILLS - turnLight(), turnDark(), turnAtLight(), turnAtDark() // META MOVEMENT - turnAway(), turnMemory(), turnOther() // servos23.ino // SERVOS - enableServos(), disableServos(), ServosInitC() // hardware20.ino // HARDWARE - ServoPulse(byte Spin, int Spulse), beep(byte beeppin,int beepfreqHz,long beeptime) // system45.ino // SYSTEM - disable_walking(), enable_walking(), toggle_f_walking(), // initialiseEEPROM(), initialiseEEPROMbehaviours() //=========================================================== ===============================================================================