// 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. char thisrobot[] ="BambinoPM "; char thisprog[] ="B_PM01_ServosMid"; // Binary sketch size: 2,710 bytes (of a 30,720 byte maximum) //=========================================================== /**New* const byte servoRollPin =6; //Roll servo on pin 6 const byte servoPacePin =7; //Pace servo on pin 7 const byte redLEDpin =4; //red LED on pin 4, HIGH=on void ServoPulse(byte Spin, int Spulse) // pulse servo, Sctrl in degrees */ ================================================================================================== // 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 char thisrobot[] ="BambinoPM "; char thisprog[] ="B_PM02_BoardTest"; // Binary sketch size: 5,086 bytes (of a 30,720 byte maximum) //=========================================================== /**New* const byte RwhiskerLEDpin_ =11; //Right whiskerLED on pin 11, LOW=on const byte LwhiskerLEDpin_ =10; //Left whiskerLED on pin 10, LOW=on const byte RwhiskerSensePin =A3; //Right whisker photo-transistor on pin A3 const byte LwhiskerSensePin =A0; //Left whisker photo-transistor on pin A0 const byte RbeardLEDpin_ =8; //Right BeardLED on pin 8, LOW=on const byte LbeardLEDpin_ =9; //Left BeardLED on pin 9, LOW=on const byte RbeardSensePin =A2; //Right Beard photo-transistor on pin A2 const byte LbeardSensePin =A1; //Left Beard photo-transistor on pin A1 int RwhiskerLight; // reading from Right Whisker sensor int LwhiskerLight; // reading from Left Whisker sensor int RbeardLight; // reading from Right Beard sensor int LbeardLight; // reading from Left Beard sensor void showWhiskerLightLevelsOn() //print light levels to Serial Monitor void showBeardLightLevels() //print light levels to Serial Monitor */ ================================================================================================== // B_PM03_BoardInit // Initialise the EEPROM with default values // Then make a sound from the speaker, char thisrobot[] ="BambinoPM "; char thisprog[] ="B_PM03_BoardInit"; // Binary sketch size: 4,100 bytes (of a 30,720 byte maximum) //=========================================================== /**New* #include to read and write internal EEPROM //EEPROM addresses void initialiseEEPROM() */ ================================================================================================== // B_PM04_Servos // full instructions require a Duemilinova or bigger, ie ATmega328 or bigger //#define(__AVR_ATmega168__) // for reduced instructions char thisrobot[] ="BambinoPM "; char thisprog[] ="B_PM04_Servos"; //Binary sketch size: 5,654 bytes (of a 30,720 byte maximum) /* 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 */ //=========================================================== /**New* byte Servoframe =20; byte rollat ; // roll servo position byte paceat ; // pace servo position byte rollby ; // roll angles about rollC byte paceby ; // pace angles about paceC byte cmnd =0; // current command boolean f_paceservo =true; // for switch case byte rollC =EEPROM.read(ErollC); // initialise rollC from current EEPROM ErollC byte paceC =EEPROM.read(EpaceC); // initialise paceC from current EEPROM EpaceC in setup() if (rollC==255) {rollC =90;} // in case it is not initialised if (paceC==255) {paceC =90;} // in case it is not initialised servoR.write(roll); // tell servo to go to position rollC servoP.write(pace); // tell servo to go to position paceC */ ================================================================================================== // B_PM05_Rock // Stand in place and Rock from one foot to the other char thisrobot[] ="BambinoPM "; char thisprog[] ="B_PM05_Rock"; // Binary sketch size: 3,216 bytes (of a 30,720 byte maximum) //=========================================================== /**New* byte rollat ; // Roll servo position byte paceat ; // Pace servo position byte rollspeed ; // roll servo speed byte pacespeed ; // pace servo speed byte rollto ; // roll servo value to move to byte paceto ; // pace servo value to move to void loop() // Stand in place and Rock from one foot to the other void rollmove() // do roll move void pacemove() // do pace move */ ================================================================================================== // B_PM06_Shuffle // Stand in place and move feet backwards and forwards without lifting them. char thisrobot[] ="BambinoPM "; char thisprog[] ="B_PM06_Shuffle"; // Binary sketch size: 3,216 bytes (of a 30,720 byte maximum) //=========================================================== /**New* void loop() // Stand in place and move feet backwards and forwards without lifting them. */ ================================================================================================== // B_PM07_WalkFd // Walk forwards. char thisrobot[] ="BambinoPM "; char thisprog[] ="B_PM07_WalkFd"; // Binary sketch size: 3,416 bytes (of a 30,720 byte maximum) //=========================================================== /**New* void loop() // 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. // 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. char thisrobot[] ="BambinoPM "; char thisprog[] ="B_PM08_WalkStop"; // Binary sketch size: 3,520 bytes (of a 30,720 byte maximum) //=========================================================== /**New* boolean f_walking ; // 1=> walking enabled , 0=>walking disabled void setup() f_walking =EEPROM.read(Ef_walking); // read old state f_walking =!f_walking ; // !true ->false, !false ->true EEPROM.write(Ef_walking,f_walking); // save new state Serial.print(" "); if (f_walking) {Serial.println("walking");} else {Serial.println("stopped");} if (f_walking) { enableServos();} */ ================================================================================================== // 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. char thisrobot[] ="BambinoPM "; char thisprog[] ="B_PM09_Forward"; // Binary sketch size: 3,558 bytes (of a 30,720 byte maximum) //=========================================================== /**New* void forward() // Walk one step forwards void rollRight() { rollto =rollC +rollby; rollmove(); } void rollCentre() { rollto =rollC; rollmove(); } void rollLeft() { rollto =rollC -rollby; rollmove(); } void paceRightForward() { paceto =paceC -paceby; pacemove(); } void paceCentre() { paceto =paceC; pacemove(); } void paceLeftForward() { paceto =paceC +paceby; pacemove(); } */ ================================================================================================== // 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. char thisrobot[] ="BambinoPM "; char thisprog[] ="B_PM10_Backward"; // Binary sketch size: 3,614 bytes (of a 30,720 byte maximum) //=========================================================== /**New* void backwards() // Walk one step backwards void paceRightBackward() { paceLeftForward(); } void paceLeftBackward() { paceRightForward(); } */ ================================================================================================== // 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. char thisrobot[] ="BambinoPM "; char thisprog[] ="B_PM11_TurnRight"; // Binary sketch size: 3,520 bytes (of a 30,720 byte maximum) //=========================================================== /**New* void turnRight() */ ================================================================================================== // 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 char thisrobot[] ="BambinoPM "; char thisprog[] ="B_PM12_TurnLeft"; // Binary sketch size: 3,682 bytes (of a 30,720 byte maximum) //=========================================================== /**New* void turnLeft() */ ================================================================================================== // 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. char thisrobot[] ="BambinoPM "; char thisprog[] ="B_PM13_USsense"; // Binary sketch size: 4,566 bytes (of a 30,720 byte maximum) //== NEW ==================================================== /* // Ultrasonic module HC-SR04 debug =1; // turn on debug printing loop() // Wander and avoid void beep(byte beeppin,int beepfreqHz,long beeptime) byte dist_HC_SR04() void toggle_f_walking() // toggles on reset */ ================================================================================================== // 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 char thisrobot[] ="BambinoPM "; char thisprog[] ="B_PM14_USwander"; // Binary sketch size: 4,566 bytes (of a 30,720 byte maximum) //== NEW ==================================================== /* // 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 */ //== CHANGED ================================================ /* void turnRight() f_TurnedRight =1; void turnLeft() f_TurnedRight =0; */ ================================================================================================== // B_M15_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. char thisrobot[] ="BambinoPM "; char thisprog[] ="B_PM15_BeardTest"; // Binary sketch size: 3,316 bytes (of a 30,720 byte maximum) //== NEW ==================================================== /* pinMode(LbeardLEDpin_, OUTPUT); // sets the digital pin as output pinMode(RbeardLEDpin_, OUTPUT); // sets the digital pin as output void showBeardLightLevels() //print light levels to Serial Monitor */ //== CHANGED ================================================ /* void setup() f_walking=1; //override EEPROM value for this test digitalWrite(LwhiskerLEDpin_, HIGH);// beard LED OFF digitalWrite(RwhiskerLEDpin_, HIGH);// beard LED OFF pinMode(LbeardLEDpin_, OUTPUT); // sets the digital pin as output pinMode(RbeardLEDpin_, OUTPUT); // sets the digital pin as output void loop() */ ================================================================================================== // 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. char thisrobot[] ="BambinoPM "; char thisprog[] ="B_PM15_WhiskerTest"; // Binary sketch size: 3,904 bytes (of a 30,720 byte maximum) //== NEW ==================================================== /* pinMode(LwhiskerLEDpin_, OUTPUT); // sets the digital pin as output pinMode(RwhiskerLEDpin_, OUTPUT); // sets the digital pin as output void showWhiskerLightLevels() //print light levels to Serial Monitor */ //== CHANGED ================================================ /* void setup() f_walking=1; //override EEPROM value for this test digitalWrite(LbeardLEDpin_, HIGH);// beard LED OFF digitalWrite(RbeardLEDpin_, HIGH);// beard LED OFF pinMode(LwhiskerLEDpin_, OUTPUT); // sets the digital pin as output pinMode(RwhiskerLEDpin_, OUTPUT); // sets the digital pin as output void loop() */ ================================================================================================== // B_PM16_BeardWander // Use the Beard LEDs and sensors to detect table edges // while walking char thisrobot[] ="BambinoPM "; char thisprog[] ="B_PM16_BeardWander"; // Binary sketch size: 3,904 bytes (of a 30,720 byte maximum) //== NEW ==================================================== /* int RbeardDifference; // difference between RbeardLight and RbeardDark int LbeardDifference; // difference between LbeardLight and LbeardDark boolean f_holeRight; // 0=> no hole, 1=> hole eg a table edge, boolean f_holeLeft; // 0=> no hole, 1=> hole eg a table edge const byte holeThresholdRight =10; // difference between RbeardLight and RbeardDark for a hole const byte holeThresholdLeft =10; // difference between LbeardLight and LbeardDark for a hole void readBeard() QueryEdge() */ //== CHANGED ================================================ /* void setup() deleted f_walking=1; //override EEPROM value for this test digitalWrite(LwhiskerLEDpin_, HIGH);// beard LED OFF digitalWrite(RwhiskerLEDpin_, HIGH);// beard LED OFF */ ================================================================================================== // 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 char thisrobot[] ="BambinoPM "; char thisprog[] ="B_PM16_WhiskerWander"; // Binary sketch size: 3,904 bytes (of a 30,720 byte maximum) //== NEW ==================================================== /* int RwhiskerDifference; // difference between RwhiskerLight and RwhiskerDark int LwhiskerDifference; // difference between LwhiskerLight and LwhiskerDark boolean f_obstacleRight; // 0=> no obstacle, 1=> obstacle boolean f_obstacleLeft; // 0=> no obstacle, 1=> obstacle const byte obstacleThresholdRight =20; // difference between RwhiskerLight and RwhiskerDark for an obstacle const byte obstacleThresholdLeft =20; // difference between LwhiskerLight and LwhiskerDark for an obstacle void readWhiskers() QueryObstacle() */ //== CHANGED ================================================ /* void loop */ ================================================================================================== // 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() char thisrobot[] ="BambinoPM "; char thisprog[] ="B_PM17_Wander"; // Binary sketch size: 6,910 bytes (of a 30,720 byte maximum) //== NEW ==================================================== /* int objectRange // distance to object detected by HC-SR04 sensor void Wander() void avoidUObjects() */ //== CHANGED ================================================ /* void loop() */ ================================================================================================== // 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. char thisrobot[] ="BambinoPM "; char thisprog[] ="B_PM18_AvoidBack"; // Binary sketch size: 6,910 bytes (of a 30,720 byte maximum) //== NEW ==================================================== /* boolean f_forwards =1; // current direction, 1=>forwards, 0=>backwards, controls step direction in turns */ //== CHANGED ================================================ /* void avoidUObjects() - reduced number of backward() calls since turn now does backwards() void avoidObstacles() - reduced number of backward() calls since turn now does backwards() void avoidHoles() - reduced number of backward() calls since turn now does backwards() void forward() - set f_forwards void backward() - unset f_forwards void turnRight() - act on f_forwards void turnLeft() - act on f_forwards */ ================================================================================================== // 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 char thisrobot[] ="BambinoPM "; char thisprog[] ="B_PM19_SpeedWander"; // Binary sketch size: 7,058 bytes (of a 30,720 byte maximum) //== NEW ==================================================== /* byte rollspeedmax ; byte pacespeedmax ; //== BEHAVIOUR MODIFIERS void speeddown() // reduce by half rollspeed and pacespeed with a minimum of 1 void speedup() // increase by 1 rollspeed and pacespeed upto rollspeedmax and pacespeedmax */ //== CHANGED ================================================ /* void setup() Wander() - speedup() void avoidUObjects() - speeddown() void avoidObstacles() - speeddown() void avoidHoles() - speeddown() */ ================================================================================================== // 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. */ char thisrobot[] ="BambinoM "; char thisprog[] ="B_PM20_Wander"; // Binary sketch size: 6,198 bytes (of a 30,720 byte maximum) //== NEW ==================================================== /* #include "pinsPM20.h" #include "varsConsPM20.h" #include "initPM20.h" */ //== CHANGED ================================================ /* Pin declarations moved to Pins.h which opens in a Tab Variables and Constant declarations moved to VarsCons.h which opens in a Tab The unchanging initialisation in Setup() moved to Init.h which opens in a Tab Functions moved to .ino files which open in Tabs */ ================================================================================================== // 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. */ char thisrobot[] ="BambinoPM "; char thisprog[] ="B_PM21_PlayTime"; // Binary sketch size: 7,176 bytes (of a 30,720 byte maximum) //== NEW ==================================================== /* actsPM21.ino - void WanderSteps(int repeat) // accepts a repeat parameter, calls Wander() void rock(repeats) void shuffle(repeats) void whee() // make rising sound void whoa() // make falling sound */ //== CHANGED ================================================ /* loop() */ ================================================================================================== // 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. */ char thisrobot[] ="BambinoPM "; char thisprog[] ="B_PM22_BeAlive"; // Binary sketch size: 8,030 bytes (of a 30,720 byte maximum) //== NEW ==================================================== /* void RightStep(int repeat) //turnRight for repeat steps void LeftStep(int repeat) //turnLeft for repeat steps */ //== CHANGED ================================================ /* loop() */ ================================================================================================== // 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. */ char thisrobot[] ="BambinoPM "; char thisprog[] ="B_PM23_SerialCmnd"; // Binary sketch size: 9,196 bytes (of a 30,720 byte maximum) //== NEW ==================================================== /* void beAlive() // the loop() from B_M22_BeAlive void whiskerLEDsDim() //indicate ready for command void USreact() // read Ultrasonic sensor and react to objectRange .... movement23.ino - added halt() actsPM23.ino - added from B_M22_BeAlive.ino RightStep(steps), LeftStep(steps), rock(repeats), shuffle(repeats), whee(), whoa() varsConsPM23.h - added byte cmnd =0; // current command badkey() // indicate invalid key servos23.ino - added enableServos() disableServos() */ //== CHANGED ================================================ /* #include "varsConsPM20.h" -> #include "varsConsPM23.h" movement20.ino -> movement23.ino actsPM21.ino -> actsPM23.ino loop() - act on the single letter commands from the Serial Monitor or other terminal */ ================================================================================================== // 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. */ char thisrobot[] ="BambinoPM "; char thisprog[] ="B_PM24_Learn"; // Binary sketch size: 10,086 bytes (of a 30,720 byte maximum) //== NEW ==================================================== /* boolean f_recording =false; //recording an Act boolean f_recordC =false; //record current Command boolean f_play =false; //Play Act const byte Esc =27; //Esc key value int EEPROMindex; // index to moves in an Act in second page of EEPROM int ActEnd; // end address of current recording Act in EEPROM int moves =0; // current move char Ccmnd =0; // current Character command, default null command char PlayAct() void printAct() void setEEPROMindexes() void bip() // make a bip sound void redLEDon() void redLEDoff() */ //== CHANGED ================================================ /* setup() - Serial.print(">"); //ready prompt loop() - switchcase expanded section added at end to record Ccmnds - if (f_recording && f_recordC) red LED on indicates recording bip() when recording void printHelp() - amended */ ================================================================================================== // 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. */ char thisrobot[] ="BambinoPM "; char thisprog[] ="B_PM25_Learn8"; // Binary sketch size: 10,126 bytes (of a 30,720 byte maximum) //== NEW ==================================================== /* char Act; //current Act as '1' - '8' byte actIndex =0; // current Act number, set to default void PrintAllActs() void getAct() */ //== CHANGED ================================================ /* loop() - case 'P' changed from Play to Print all Acts case '1' - '8' added to select more acts and to play them case 'r' now needs to be followed by an act number '1'-'8' case 'p' now needs to be followed by an act number '1'-'8' void printAct() - changed to print Act number void setEEPROMindexes() is now void setEEPROMindexes(char Act) void printHelp() - amended instructions sensePM20.ino changed to sensePM25.ino - dist_HC_SR04() removed if (debug) {Serial.print('U');} - showWhiskerLightLevels() - added Serial.println(); - showBeardLightLevels() - added Serial.println(); */ ================================================================================================== //B_PM26_CopyAct.ino char thisrobot[] ="BambinoPM "; char thisprog[] ="B_PM26_CopyAct"; // 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(). */ //== NEW ==================================================== /* void copyAct() */ //== CHANGED ================================================ /* loop() - case 'c': if (!f_recording) { copyAct(); break; loop() - Recording: if(f_newRec && Ccmnd=='.') {f_recording =false; } // '.',Esc from GetKey() @ case 'r' void printHelp() - amended instructions */ ================================================================================================== //B_PM27_loadAct.ino char thisrobot[] ="BambinoPM "; char thisprog[] ="B_PM27_loadAct"; // 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(). */ //== NEW ==================================================== /* void loadAct() */ //== CHANGED ================================================ /* loop() - case 'l': if (!f_recording) { loadAct(); } break; void printHelp() - amended instructions */ ================================================================================================== //B_PM28_DumpActs.ino char thisrobot[] ="BambinoPM "; char thisprog[] ="B_PM28_DumpActs"; // 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(). */ //== NEW ==================================================== /* const byte NL =10; //NewLine value const byte LF =10; //LineFeed value const byte CR =13; //Carriage Return value " " NL CR "," are ignored in switch(Ccmnd) void DumpActs() //Dump Acts, Print without names and length */ //== CHANGED ================================================ /* loop() - case 'D' void printHelp() - amended instructions */ ================================================================================================== //B_PM29_Run8.ino char thisrobot[] ="BambinoPM "; char thisprog[] ="B_PM29_Run8"; // 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(). */ //== #define ================================================ #define autoAct '8' //Act '1' - '8' to autorun //== NEW ==================================================== /* #define autoAct '8' //Act to autorun boolean f_firstRun =true; //true for the first loop only */ //== CHANGED ================================================ /* loop() - if (f_firstRun) { Ccmnd ='8'; f_firstRun =false; } to autoplay Act 8 void printHelp() - amended instructions */ ================================================================================================== //B_PM30_Wait.ino char thisrobot[] ="BambinoPM "; char thisprog[] ="B_PM30_Wait"; // 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(). */ //== #define ================================================ #define autoAct '8' //Act '1' - '8' to autorun //== NEW ==================================================== /* void GetCcmnd() //reads Serial or playing Act until Ccmnd != 0, prints Ccmnd void RecordCcmnd() void makeCcmndDigit() //ensure 1-9 void waitCcmndSecs() //read delay time from Act and wait */ //== CHANGED ================================================ /* loop() - GetCcmnd(), RecordCcmnd(), case 'w' loop() - removed Serial.print(Ccmnd); from start of DoCommand: section void printHelp() - amended instructions */ ================================================================================================== //B_PM31_Speed.ino char thisrobot[] ="BambinoPM "; char thisprog[] ="B_PM31_Speed"; // 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(). */ //== #define ================================================ #define autoAct '8' //Act '1' - '8' to autorun //== NEW ==================================================== /* */ //== CHANGED ================================================ /* loop() - case 's' void PrintAllActs() void printHelp() - amended instructions */ ================================================================================================== //B_PM32_CommanderXE.ino char thisrobot[] ="BambinoPM "; char thisprog[] ="B_PM32_CommanderXE"; // Binary sketch size: 13,022 bytes (of a 30,720 byte maximum) /* Introducing 'X' to Xplore which just calls Wander() 'E' Experiment - call your own routines ------------------------------------------ Note - The Arduino Serial Monitor can't send [Esc]. If another Terminal is used which can send [Esc] then at GetCcmnd() this will be printed, which may print as a symbol or the Terminal may change it to "." Bugs - GetAct should use GetCcmnd to read Act from current act rather than a prompt. rx,px,lx,cx would then be playable improvements? - void GetCcmnd() could use case 0: To do next - v(1-9) - voice mp(1-9) - paceby mt(1-9) - turnby - paceby used in turns mr(1-9) - rollby //advanced use only, otherwise Bambino doesn't walk properly or falls over t(a,m,o) - turn away,memory,other pm - Print Mind - EEPROM values (255 - 247) - f_walking, rollC, paceC, rollby, paceby, rollmin, rollmax, pacemin, pacemax lm - Load Mind - EEPROM values (255 - down) - byte values - how to load byte values? b(1-9) - behaviour set - same format as Acts +current behaviour rules in page2 ------------------------------------------ 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 '.' or reset // the loop() from B_PM22_BeAlive 'X' - Xplore() until '.' or reset // Wander() 'E' - Experiment - user routine until '.' or reset '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(). */ //== #define ================================================ #define autoAct '8' //Act '1' - '8' to autorun //== NEW ==================================================== /* void Experiment() //until Quit void Xplore() //Wander() until Quit */ //== CHANGED ================================================ /* loop() - case 'E','X' void printHelp() - amended instructions */ ================================================================================================== //B_PM33_PROGMEM.ino char thisrobot[] ="BambinoPM "; char thisprog[] ="B_PM33_PROGMEM"; // 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. ------------------------------------------ Note - The Arduino Serial Monitor can't send [Esc]. If another Terminal is used which can send [Esc] then at GetCcmnd() this will be printed, which may print as a symbol or the Terminal may change it to "." Bugs - GetAct should use GetCcmnd to read Act from current act rather than a prompt. rx,px,lx,cx would then be playable To do next - v(1-9) - voice mp(1-9) - paceby mt(1-9) - turnby - paceby used in turns mr(1-9) - rollby //advanced use only, otherwise Bambino doesn't walk properly or falls over t(a,m,o) - turn away,memory,other pm - Print Mind - EEPROM values (255 - 247) - f_walking, rollC, paceC, rollby, paceby, rollmin, rollmax, pacemin, pacemax lm - Load Mind - EEPROM values (255 - down) - byte values - how to load byte values? b(1-9) - behaviour set - same format as Acts +current behaviour rules in page2 ------------------------------------------ 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 '.' or reset // the loop() from B_PM22_BeAlive 'X' - Xplore() until '.' or reset // Wander() 'E' - Experiment - user routine until '.' or reset '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(). */ //== #define ================================================ #define autoAct '8' //Act '1' - '8' to autorun //== NEW ==================================================== /* #include // for the printHelp() text //== HELP TEXT */ //== CHANGED ================================================ /* void printHelp() - amended for */ ================================================================================================== //B_PM34_vbt.ino char thisrobot[] ="BambinoPM "; char thisprog[] ="B_PM34_vbt"; // 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 ------------------------------------------ Note - The Arduino Serial Monitor can't send [Esc]. If another Terminal is used which can send [Esc] then at GetCcmnd() this will be printed, which may print as a symbol or the Terminal may change it to "." improvements? - void GetCcmnd() could use case 0: Bugs - GetAct should use GetCcmnd to read Act from current act rather than a prompt. rx,px,lx,cx would then be playable To do next - pm - Print Mind - EEPROM values (255 - 247) - f_walking, rollC, paceC, rollby, paceby, rollmin, rollmax, pacemin, pacemax lm - Load Mind - EEPROM values (255 - down) - byte values - how to load byte values? b(1-9) - behaviour set - same format as Acts +current behaviour rules in page2 ------------------------------------------ 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, whee '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 '.' or Esc or reset // the loop() from B_PM22_BeAlive 'X' - Xplore() until '.' or Esc or reset // Wander() 'E' - Experiment - user routine until '.' or Esc or reset 'v','b','e','o' choose sound: 'b' bip, 'e' whee, 'o' whoa '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 units of servo degrees change per frame 'sp','1'-'9' set pace speed units of servo degrees change per frame 'sm' - set rollspeedmax to current rollspeed, set pacespeedmax to current pacespeed 'srm' - set rollspeedmax to current rollspeed 'spm' - set pacespeedmax to current pacespeed 'b','p','1'-'9' set behave paceby - step length - units of 2 servo degrees 't','1'-'9' set behave turnby - step length in turns - units of 2 servo degrees 'r','1'-'9' set behave rollby - roll amount when stepping - units of 2 servo degrees '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 '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(). */ //== #define ================================================ #define autoAct '8' //Act '1' - '8' to autorun //== NEW ==================================================== /* varsConsPM34.h - byte turnby; // servo turn angles about paceC boolean f_turning =0; // controls pace in paceLeftForward() and paceRightForward() when turning movement34.ino - turnRightForward(), turnLeftForward(), turnRightBackward(), turnLeftBackward() skills34.ino - turnAway(), turnMemory(), turnOther() */ //== CHANGED ================================================ /* //== HELP TEXT - amended instructions void setup() { #include "initPM33.h" //Initialise various things loop() - cases 'v','t','b' varsConsPM23.h -> varsConsPM34.h - turnby void PrintAllActs() - now prints paceby, rollby, turnby initPM20.h -> initPM34.h - initialises turnby movement34.ino - turnRight() //now uses turnRightForward(), turnLeftForward(), turnRightBackward(), turnLeftBackward(), sets f_turning movement34.ino - turnLeft() //now uses turnRightForward(), turnLeftForward(), turnRightBackward(), turnLeftBackward(), sets f_turning movement34.ino - paceLeftForward(), paceRightForward() test f_turning */ ================================================================================================== //B_PM35_Acts0.ino char thisrobot[] ="BambinoPM "; char thisprog[] ="B_PM35_Acts0"; // 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. ------------------------------------------ Note - The Arduino Serial Monitor can't send [Esc]. If another Terminal is used which can send [Esc] then at GetCcmnd() this will be printed, which may print as a symbol or the Terminal may change it to "." Bugs - improvements? - - GetAct should use GetCcmnd to read Act from current act rather than a prompt. rx,px,lx,cx would then be playable - void GetCcmnd() could use case 0: - why? To do next - tl - turn to light td - turn to dark pb - Print Mind - EEPROM values (255 - 247) all moveby values are 2* command values, only print command values - f_walking, rollC, paceC, rollby, paceby, rollmin, rollmax, pacemin, pacemax lb - Load Mind - EEPROM values (255 - down) - byte values - how to load byte values? - lb(1-8) - load mind (1-8) with current values lb(1-8) - load b(1-8) with current values b(1-8) - change to behaviour set - same format as Acts +current behaviour rules in page2 Cr+,Cr-(1-9) - alter rollC in RAM and EEPROM in current mind Cp+,Cp-(1-9) - alter paceC in RAM and EEPROM in current mind u+(1-8) - ultrasonic furthest range aware at, further ignored u-(1-8) - ultrasonic closest range, less is too close b0 - reinitialise behaves - do a software restart using the watchdog b<1-8> - select current behaviour 16 bytes for behaves => 8 in 128 bytes sr,sp,srm,spm,mr,mp,mt,u-,u+,(spare 7) two bytes each => 16 bytes, => 8 in 128 bytes bG-<{0},1-8> - Act to be done on hole-tests left & right true bGR<{0},1-8> - Act to be done on hole-test right true bGL<{0},1-8> - Act to be done on hole-test left true bW-<{0},1-8> - Act to be done on Whisker-tests left & right true bWR<{0},1-8> - Act to be done on Whisker-test right true bWL<{0},1-8> - Act to be done on Whisker-test left true bU+<{0},1-8> - Act to be done on Ultrasonic distance <= aware at bU-<{0},1-8> - Act to be done on Ultrasonic distance <= too near ------------------------------------------ COMMANDS ======== '.',[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 '0' - use page0 for the next Act '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, whee '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 '.' or Esc or reset // the loop() from B_PM22_BeAlive 'X' - Xplore() until '.' or Esc or reset // Wander() 'E' - Experiment - user routine until '.' or Esc or reset 'v', 'b','e','o' choose sound: 'b' bip, 'e' whee, 'o' whoa '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 units of servo degrees change per frame 'sp','1'-'9' set pace speed units of servo degrees change per frame 'sm' - set rollspeedmax to current rollspeed, set pacespeedmax to current pacespeed 'srm' - set rollspeedmax to current rollspeed 'spm' - set pacespeedmax to current pacespeed 'b','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 '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 '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(). BEHAVES ======= power-on defaults ---------------- speed behaves - set in void setup() rollspeed is 1 pacespeed is 1 rollspeedmax is 4 pacespeedmax is 6 move behaves - set in void setup() initPM34.h rollby is EEPROM value, set by B_PM04_Servos paceby is EEPROM value, set by B_PM04_Servos turnby is paceby */ //== #define ================================================ #define autoAct '8' //Act '1' - '8' to autorun //== NEW ==================================================== /* byte epage; //the Act page for the current Act, page =1 for Acts 1-8 and page =2 for 01-08 */ //== CHANGED ================================================ /* //== HELP TEXT loop() //epage back to default=1 void DumpActs() //Dump Acts, Print without names and length, //epage void PrintAllActs() //epage void printAct() //epage void getAct() //epage */ ================================================================================================== //B_PM36_turns.ino char thisrobot[] ="BambinoPM "; char thisprog[] ="B_PM36_turns"; // 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 ------------------------------------------ Note - The Arduino Serial Monitor can't send [Esc]. If another Terminal is used which can send [Esc] then at GetCcmnd() this will be printed, which may print as a symbol or the Terminal may change it to "." Bugs - improvements? - - GetAct should use GetCcmnd to read Act from current act rather than a prompt. rx,px,lx,cx would then be playable - void GetCcmnd() could use case 0: - why? To do next - Reactions page ! Behaviour page @ 32 byte slots load only, make so can load short string starting with autoAct - make first byte '@' Ef_walking =255; ErollC =254; rollC 0-9 units of 10us set in initialiseEEPROM() 0-90 EpaceC =253; paceC 0-9 units of 10us set in initialiseEEPROM() 0-90 Erollby =252; rollby 0-9 units of 20us set in initPM34.h from EEPROM set in initialiseEEPROM() 15 physical max 20 Epaceby =251; paceby 0-9 units of 20us set in initPM34.h from EEPROM set in initialiseEEPROM() 15 physical max 20 Erollmin =250; Erollmax =249; Epacemin =248; Epacemax =247; autoAct 1-8 turnby 0-9 units of 20us set in initPM34.h from EEPROM set in initialiseEEPROM() paceby rollspeed 1-9 =1 slow pacespeed 1-9 =1 slow rollspeedmax 1-9 =4; // quite fast pacespeedmax 1-9 =6; // quite fast LeftRightLightTurnThreshold - 0-9 in units of 5% giving a range of 50% - or maybe units of 2% holeThresholdRight =10; - 0-9 units of 2% // difference between RbeardLight and RbeardDark for a hole holeThresholdLeft =10; - 0-9 units of 2% // difference between LbeardLight and LbeardDark for a hole obstacleThresholdRight =20; - 0-9 units of 2% // difference between RwhiskerLight and RwhiskerDark for an obstacle obstacleThresholdLeft =20; - 0-9 units of 2% pb0 - print current Behaviour, BeHaves in Mind (RAM values) pb(1-8) - print Behaviour in EEPROM (1-8) all moveby values are 2* command values, only print command values - f_walking, rollC, paceC, rollby, paceby, rollmin, rollmax, pacemin, pacemax lb(1-8) - load b(1-8) Load Mind - EEPROM values - byte values - prefix with # b(1-8) - load Mind (RAM values) with behaviour from EEPROM (1-8) b8 - default behaviour loaded to Mind (RAM) in Init Cr+,Cr-(1-9) - alter rollC in RAM and EEPROM in current mind Cp+,Cp-(1-9) - alter paceC in RAM and EEPROM in current mind u+(1-8) - ultrasonic furthest range aware at, further ignored u-(1-8) - ultrasonic closest range, less is too close b0 - reinitialise behaves - do a software restart using the watchdog b<1-8> - select current behaviour 16 bytes for behaves => 8 in 128 bytes sr,sp,srm,spm,mr,mp,mt,u-,u+,(spare 7) two bytes each => 16 bytes, => 8 in 128 bytes bG-<{0},1-8> - Act to be done on hole-tests left & right true bGR<{0},1-8> - Act to be done on hole-test right true bGL<{0},1-8> - Act to be done on hole-test left true bW-<{0},1-8> - Act to be done on Whisker-tests left & right true bWR<{0},1-8> - Act to be done on Whisker-test right true bWL<{0},1-8> - Act to be done on Whisker-test left true bU+<{0},1-8> - Act to be done on Ultrasonic distance <= aware at bU-<{0},1-8> - Act to be done on Ultrasonic distance <= too near ------------------------------------------ COMMANDS ======== '.',[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 '0' - use page0 for the next Act '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, whee '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 '.' or Esc or reset // the loop() from B_PM22_BeAlive 'X' - Xplore() until '.' or Esc or reset // Wander() 'E' - Experiment - user routine until '.' or Esc or reset 'v', 'b','e','o' choose sound: 'b' bip, 'e' whee, 'o' whoa '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 units of servo degrees change per frame 'sp','1'-'9' set pace speed units of servo degrees change per frame 'sm' - set rollspeedmax to current rollspeed, set pacespeedmax to current pacespeed 'srm' - set rollspeedmax to current rollspeed 'spm' - set pacespeedmax to current pacespeed 'b','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 '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 '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(). BEHAVES ======= power-on defaults ---------------- speed behaves - set in void setup() rollspeed is 1 pacespeed is 1 rollspeedmax is 4 pacespeedmax is 6 move behaves - set in void setup() initPM34.h rollby is EEPROM value, set by B_PM04_Servos paceby is EEPROM value, set by B_PM04_Servos turnby is paceby */ //== #define ================================================ #define autoAct '8' //Act '1' - '8' to autorun //== NEW ==================================================== /* varsConsPM36.h - LeyeLight, ReyeLight, LeftRightLightTurnThreshold, f_AtLight, f_AtDark skills34.ino -> skills36.ino - turnLight(), turnDark(), turnAtLight(), turnAtDark() */ //== CHANGED ================================================ /* varsConsPM34.h -> varsConsPM36.h - LeyeLight, ReyeLight, LeftRightLightTurnThreshold, f_AtLight, f_AtDark //== HELP TEXT loop() */ ================================================================================================== //B_PM37_Mind.ino char thisrobot[] ="BambinoPM "; char thisprog[] ="B_PM37_Mind"; // Binary sketch size: 15,168 bytes (of a 30,720 byte maximum) /* Introducing M - print current Behaviour, BeHaves in Mind (RAM values) ------------------------------------------ Note - The Arduino Serial Monitor can't send [Esc]. If another Terminal is used which can send [Esc] then at GetCcmnd() this will be printed, which may print as a symbol or the Terminal may change it to "." Bugs - improvements? - - GetAct should use GetCcmnd to read Act from current act rather than a prompt. rx,px,lx,cx would then be playable - void GetCcmnd() could use case 0: - why? To do next - Reactions page ! Behaviour page @ 32 byte slots load only, make so can load short string starting with autoAct - make first byte '@' print 23 to 31 for 'm' machine 31 Ef_walking =255; 30 ErollC =254; 90 rollC set in initPM34.h from EEPROM set in initialiseEEPROM() 29 EpaceC =253; 90 paceC set in initPM34.h from EEPROM set in initialiseEEPROM() 28 Erollby =252; 15 rollby set in initPM34.h from EEPROM set in initialiseEEPROM() physical max 20 27 Epaceby =251; 15 paceby set in initPM34.h from EEPROM set in initialiseEEPROM() physical max 20 26 [Erollmin =250;] 25 [Erollmax =249;] 24 [Epacemin =248;] 23 [Epacemax =247;] 22 246 21 245 20 244 19 243 18 242 [ boolean f_cm ] print 0 to here plus 31 for Mind 17 Sonar awareAt - 5cm units - 1 to 9 = 5cm to 45cm 16 Sonar TooNear - 5cm units - 1 to 9 = 5cm to 45cm 15 LeftRightLightTurnThresholdScale - 1-9 in units of 1% 14 LeftRightLightTurnThreshold - 0-9 in units of Scale 13 holeThresholdScale - 1-9 in units of 1% 12 holeThresholdRight =10; % - 0-9 units of 5% // difference between RbeardLight and RbeardDark for a hole 11 holeThresholdLeft =10; % - 0-9 units of Scale // difference between LbeardLight and LbeardDark for a hole 10 obstacleThresholdScale - 0-9 units of 1% 9 obstacleThresholdRight =20; % - 0-9 units of 5% // difference between RwhiskerLight and RwhiskerDark for an obstacle 8 obstacleThresholdLeft =20; % - 0-9 units of 5% 7 rollspeedmax 1-9 =4; // quite fast 6 pacespeedmax 1-9 =6; // quite fast 5 rollspeed 1-9 =1 slow 4 pacespeed 1-9 =1 slow 3 turnby 0-9 units of 20us set in initPM34.h from EEPROM set in initialiseEEPROM() paceby 2 rollby 1 paceby 0 autoAct 1-8 bp(1-8) - print Behaviour in EEPROM (1-8) all moveby values are 2* command values, only print command values - f_walking, rollC, paceC, rollby, paceby, rollmin, rollmax, pacemin, pacemax lb(1-8) - load b(1-8) Load Mind - EEPROM values - byte values - prefix with # b(1-8) - load Mind (RAM values) with behaviour from EEPROM (1-8) b8 - default behaviour loaded to Mind (RAM) in Init Cr+,Cr-(1-9) - alter rollC in RAM and EEPROM in current mind Cp+,Cp-(1-9) - alter paceC in RAM and EEPROM in current mind u+(1-8) - ultrasonic furthest range aware at, further ignored u-(1-8) - ultrasonic closest range, less is too close b0 - reinitialise behaves - do a software restart using the watchdog b<1-8> - select current behaviour 16 bytes for behaves => 8 in 128 bytes sr,sp,srm,spm,mr,mp,mt,u-,u+,(spare 7) two bytes each => 16 bytes, => 8 in 128 bytes bG-<{0},1-8> - Act to be done on hole-tests left & right true bGR<{0},1-8> - Act to be done on hole-test right true bGL<{0},1-8> - Act to be done on hole-test left true bW-<{0},1-8> - Act to be done on Whisker-tests left & right true bWR<{0},1-8> - Act to be done on Whisker-test right true bWL<{0},1-8> - Act to be done on Whisker-test left true bU+<{0},1-8> - Act to be done on Ultrasonic distance <= aware at bU-<{0},1-8> - Act to be done on Ultrasonic distance <= too near ------------------------------------------ COMMANDS ======== '.',[Esc] - quit current operation - recording, playing, input 'S' - Stop/Start 'M' - print Mind - behaviour variables in RAM 'P' - Print moves in all Acts 'D' - Dump out all acts to the PC, same as 'P' but without the Act and moves numbers '0' - use page0 for the next Act '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, whee '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 '.' or Esc or reset // the loop() from B_PM22_BeAlive 'X' - Xplore() until '.' or Esc or reset // Wander() 'E' - Experiment - user routine until '.' or Esc or reset 'v', 'b','e','o' choose sound: 'b' bip, 'e' whee, 'o' whoa '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 units of servo degrees change per frame 'sp','1'-'9' set pace speed units of servo degrees change per frame 'sm' - set rollspeedmax to current rollspeed, set pacespeedmax to current pacespeed 'srm' - set rollspeedmax to current rollspeed 'spm' - set pacespeedmax to current pacespeed 'b','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 '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 '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(). BEHAVES ======= power-on defaults ---------------- speed behaves - set in void setup() rollspeed is 1 pacespeed is 1 rollspeedmax is 4 pacespeedmax is 6 move behaves - set in void setup() initPM34.h rollby is EEPROM value, set by B_PM04_Servos paceby is EEPROM value, set by B_PM04_Servos turnby is paceby */ //== #define ================================================ #define autoAct '8' //Act '1' - '8' to autorun //== NEW ==================================================== /* void printMind() */ //== CHANGED ================================================ /* //== HELP TEXT loop() - 'M' */ ================================================================================================== //B_PM38_NewPrint.ino char thisrobot[] ="BambinoPM "; char thisprog[] ="B_PM38_NewPrint"; // 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' ------------------------------------------ Note - The Arduino Serial Monitor can't send [Esc]. If another Terminal is used which can send [Esc] then at GetCcmnd() this will be printed, which may print as a symbol or the Terminal may change it to "." Bugs - improvements? - - GetAct should use GetCcmnd to read Act from current act rather than a prompt. rx,lx,cx would then be playable - void GetCcmnd() could use case 0: - why? ?m print machine ?r print Reactions /R change to Reactions page1 0 changes to Rpage0 8x16 byte slots in each Rpage /A change to Acts Apage1 0 changes to Apage0 /B change to BeHave page To do next - Reactions page ! Behaviour page @ 32 byte slots load only, make so can load short string starting with autoAct - make first byte '@' print 23 to 31 for 'm' machine 31 Ef_walking =255; 30 ErollC =254; 90 rollC set in initPM34.h from EEPROM set in initialiseEEPROM() 29 EpaceC =253; 90 paceC set in initPM34.h from EEPROM set in initialiseEEPROM() 28 Erollby =252; 15 rollby set in initPM34.h from EEPROM set in initialiseEEPROM() physical max 20 27 Epaceby =251; 15 paceby set in initPM34.h from EEPROM set in initialiseEEPROM() physical max 20 26 [Erollmin =250;] 25 [Erollmax =249;] 24 [Epacemin =248;] 23 [Epacemax =247;] 22 246 21 245 20 244 19 243 18 242 [ boolean f_cm ] print 0 to here plus 31 for Mind 17 Sonar awareAt - 5cm units - 1 to 9 = 5cm to 45cm 16 Sonar TooNear - 5cm units - 1 to 9 = 5cm to 45cm 15 LeftRightLightTurnThresholdScale - 1-9 in units of 1% 14 LeftRightLightTurnThreshold - 0-9 in units of Scale 13 holeThresholdScale - 1-9 in units of 1% 12 holeThresholdRight =10; % - 0-9 units of 5% // difference between RbeardLight and RbeardDark for a hole 11 holeThresholdLeft =10; % - 0-9 units of Scale // difference between LbeardLight and LbeardDark for a hole 10 obstacleThresholdScale - 0-9 units of 1% 9 obstacleThresholdRight =20; % - 0-9 units of 5% // difference between RwhiskerLight and RwhiskerDark for an obstacle 8 obstacleThresholdLeft =20; % - 0-9 units of 5% 7 rollspeedmax 1-9 =4; // quite fast 6 pacespeedmax 1-9 =6; // quite fast 5 rollspeed 1-9 =1 slow 4 pacespeed 1-9 =1 slow 3 turnby 0-9 units of 20us set in initPM34.h from EEPROM set in initialiseEEPROM() paceby 2 rollby 1 paceby 0 autoAct 1-8 bp(1-8) - print Behaviour in EEPROM (1-8) all moveby values are 2* command values, only print command values - f_walking, rollC, paceC, rollby, paceby, rollmin, rollmax, pacemin, pacemax lb(1-8) - load b(1-8) Load Mind - EEPROM values - byte values - prefix with # b(1-8) - load Mind (RAM values) with behaviour from EEPROM (1-8) b8 - default behaviour loaded to Mind (RAM) in Init Cr+,Cr-(1-9) - alter rollC in RAM and EEPROM in current mind Cp+,Cp-(1-9) - alter paceC in RAM and EEPROM in current mind u+(1-8) - ultrasonic furthest range aware at, further ignored u-(1-8) - ultrasonic closest range, less is too close b0 - reinitialise behaves - do a software restart using the watchdog b<1-8> - select current behaviour 16 bytes for behaves => 8 in 128 bytes sr,sp,srm,spm,mr,mp,mt,u-,u+,(spare 7) two bytes each => 16 bytes, => 8 in 128 bytes bG-<{0},1-8> - Act to be done on hole-tests left & right true bGR<{0},1-8> - Act to be done on hole-test right true bGL<{0},1-8> - Act to be done on hole-test left true bW-<{0},1-8> - Act to be done on Whisker-tests left & right true bWR<{0},1-8> - Act to be done on Whisker-test right true bWL<{0},1-8> - Act to be done on Whisker-test left true bU+<{0},1-8> - Act to be done on Ultrasonic distance <= aware at bU-<{0},1-8> - Act to be done on Ultrasonic distance <= too near ------------------------------------------ Primary commands used 012345678 ? ABEFGHLRSUVWX bclrstvw COMMANDS ======== '.',[Esc] - quit current operation - recording, playing, input 'S' - Stop/Start '0' - use page0 for the next Act '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, whee '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 '.' or Esc or reset // the loop() from B_PM22_BeAlive 'X' - Xplore() until '.' or Esc or reset // Wander() 'E' - Experiment - user routine until '.' or Esc or reset 'v', 'b','e','o' choose sound: 'b' bip, 'e' whee, 'o' whoa '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 units of servo degrees change per frame 'sp','1'-'9' set pace speed units of servo degrees change per frame 'sm' - set rollspeedmax to current rollspeed, set pacespeedmax to current pacespeed 'srm' - set rollspeedmax to current rollspeed 'spm' - set pacespeedmax to current pacespeed 'b','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 '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 '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 'm' - print Mind - all Acts, Behaviour 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(). BEHAVES ======= power-on defaults ---------------- speed behaves - set in void setup() rollspeed is 1 pacespeed is 1 rollspeedmax is 4 pacespeedmax is 6 move behaves - set in void setup() initPM34.h rollby is EEPROM value, set by B_PM04_Servos paceby is EEPROM value, set by B_PM04_Servos turnby is paceby */ //== #define ================================================ #define autoAct '8' //Act '1' - '8' to autorun //== NEW ==================================================== /* void printBehaviour() */ //== CHANGED ================================================ /* //== HELP TEXT void loop() case '?': void printMind() */ ================================================================================================== //B_PM39_Adjust.ino char thisrobot[] ="BambinoPM "; char thisprog[] ="B_PM39_Adjust"; // Binary sketch size: 17,730 bytes (of a 30,720 byte maximum) /* Re-introducing Adjust Servos of Prog4 invoked here by b@ ------------------------------------------ Note - The Arduino Serial Monitor can't send [Esc]. If another Terminal is used which can send [Esc] then at GetCcmnd() this will be printed, which may print as a symbol or the Terminal may change it to "." Bugs - improvements? - - GetAct could use GetCcmnd then Actx=px would get x from Actx rather than a prompt. This would mean px could be recorded - void GetCcmnd() could use case 0: - why? ?m print machine ?r print Reactions /R change to Reactions page1 0 changes to Rpage0 8x16 byte slots in each Rpage /A change to Acts Apage1 0 changes to Apage0 /B change to BeHave page To do next - Reactions page ! Behaviour page @ 32 byte slots load only, make so can load short string starting with autoAct - make first byte '@' print 23 to 31 for 'm' machine 31 Ef_walking =255; 30 ErollC =254; 90 rollC set in initPM34.h from EEPROM set in initialiseEEPROM() 29 EpaceC =253; 90 paceC set in initPM34.h from EEPROM set in initialiseEEPROM() 28 Erollby =252; 15 rollby set in initPM34.h from EEPROM set in initialiseEEPROM() physical max 20 27 Epaceby =251; 15 paceby set in initPM34.h from EEPROM set in initialiseEEPROM() physical max 20 26 [Erollmin =250;] 25 [Erollmax =249;] 24 [Epacemin =248;] 23 [Epacemax =247;] 22 246 21 245 20 244 19 243 18 242 [ boolean f_cm ] print 0 to here plus 31 for Mind 17 Sonar awareAt - 5cm units - 1 to 9 = 5cm to 45cm 16 Sonar TooNear - 5cm units - 1 to 9 = 5cm to 45cm 15 LeftRightLightTurnThresholdScale - 1-9 in units of 1% 14 LeftRightLightTurnThreshold - 0-9 in units of Scale 13 holeThresholdScale - 1-9 in units of 1% 12 holeThresholdRight =10; % - 0-9 units of 5% // difference between RbeardLight and RbeardDark for a hole 11 holeThresholdLeft =10; % - 0-9 units of Scale // difference between LbeardLight and LbeardDark for a hole 10 obstacleThresholdScale - 0-9 units of 1% 9 obstacleThresholdRight =20; % - 0-9 units of 5% // difference between RwhiskerLight and RwhiskerDark for an obstacle 8 obstacleThresholdLeft =20; % - 0-9 units of 5% 7 rollspeedmax 1-9 =4; // quite fast 6 pacespeedmax 1-9 =6; // quite fast 5 rollspeed 1-9 =1 slow 4 pacespeed 1-9 =1 slow 3 turnby 0-9 units of 20us set in initPM34.h from EEPROM set in initialiseEEPROM() paceby 2 rollby 1 paceby 0 autoAct 1-8 bp(1-8) - print Behaviour in EEPROM (1-8) all moveby values are 2* command values, only print command values - f_walking, rollC, paceC, rollby, paceby, rollmin, rollmax, pacemin, pacemax lb(1-8) - load b(1-8) Load Mind - EEPROM values - byte values - prefix with # b(1-8) - load Mind (RAM values) with behaviour from EEPROM (1-8) b8 - default behaviour loaded to Mind (RAM) in Init Cr+,Cr-(1-9) - alter rollC in RAM and EEPROM in current mind Cp+,Cp-(1-9) - alter paceC in RAM and EEPROM in current mind u+(1-8) - ultrasonic furthest range aware at, further ignored u-(1-8) - ultrasonic closest range, less is too close b0 - reinitialise behaves - do a software restart using the watchdog b<1-8> - select current behaviour 16 bytes for behaves => 8 in 128 bytes sr,sp,srm,spm,mr,mp,mt,u-,u+,(spare 7) two bytes each => 16 bytes, => 8 in 128 bytes bG-<{0},1-8> - Act to be done on hole-tests left & right true bGR<{0},1-8> - Act to be done on hole-test right true bGL<{0},1-8> - Act to be done on hole-test left true bW-<{0},1-8> - Act to be done on Whisker-tests left & right true bWR<{0},1-8> - Act to be done on Whisker-test right true bWL<{0},1-8> - Act to be done on Whisker-test left true bU+<{0},1-8> - Act to be done on Ultrasonic distance <= aware at bU-<{0},1-8> - Act to be done on Ultrasonic distance <= too near ------------------------------------------ Primary commands used 012345678 ? ABEFGHLQRSUVWX bclrstvw COMMANDS ======== '.',[Esc] - quit current operation - recording, playing, input 'S' - Stop/Start '0' - use page0 for the next Act '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, whee '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 '.' or reset // the loop() from B_PM22_BeAlive 'X' - Xplore() until '.' or reset // Wander() 'E' - Experiment - user routine until '.' or reset 'v', 'b','e','o' choose sound: 'b' bip, 'e' whee, 'o' whoa '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 units of servo degrees change per frame 'sp','1'-'9' set pace speed units of servo degrees change per frame 'sm' - set rollspeedmax to current rollspeed, set pacespeedmax to current pacespeed 'srm' - set rollspeedmax to current rollspeed 'spm' - set pacespeedmax to current pacespeed 'b','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 '@' - Adjust Servos and set mid positions '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 '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 'm' - print Mind - all Acts, Behaviour 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(). BEHAVES ======= power-on defaults ---------------- speed behaves - set in void setup() rollspeed is 1 pacespeed is 1 rollspeedmax is 4 pacespeedmax is 6 move behaves - set in void setup() initPM34.h rollby is EEPROM value, set by B_PM04_Servos paceby is EEPROM value, set by B_PM04_Servos turnby is paceby */ //== #define ================================================ #define autoAct '8' //Act '1' - '8' to autorun //== NEW ==================================================== /* AdjustServos39.ino //This uses Serial.print(F(" text ")); which saves RAM by leaving the text in Program memory //and is a lot easier to use than the PROGMEM construct used for the help text - we can learn something every day! */ //== CHANGED ================================================ /* //== HELP TEXT void loop() case '@': */ ==================================================================================================