Spring 2018: Biped FOBO Existing obstacle avoidance software test
Written By: Jorge Hernandez (Electronics & Control)
Verified By: Miguel Gonzalez (Project Manager)
Approved By: Miguel Garcia (Quality Assurance)
In order to avoid obstacles, we implemented the SEN136B5B sensor ultrasonic code within the given navigation program from projectbiped.com. I also did my own code which turned on an LED to detect when the ultrasonic detected 8cm or less. This was made because Micro Fobo already had navigation code which used Ultrasonic to turn Right when it detected 5 cm and I did not want to take credit for code that was not mine. Within the provided code, the only changes we had to make is to have the function found Obstacle read the value of 8 cm. If Micro FOBO’s ultrasonic read anything above 8 cms, it would provide a zero, or a false to the function found Obstacle. Below is the given code with the minor changes in order for Robot avoidance.
Below is a video of the testing performed which would essentially have Micro FOBO walk and when detecting an obstacle at 8cm’s, instead of the LED going on, it would stop Micro FOBO completely.
https://drive.google.com/open?id=1ppkFJqBtTFxKPoDTRbCh50Uc4DUi5A1O
Initially, we wanted to have the LEDs that were on top of Micro FOBO’s head turn on when it detected 8cm but in our dem,o there was a loose wire which caused miscommunication and could not make FOBO move at all. Below is a video on how we would have used the idea of Robot avoidance with the Arduino code provided as well.
// Jorge Hernandez //Ultrasonic Sensor HC-SR04 and Arduino Tutorial //Dejan Nedelkovsk // defines pins numbers const int trigPin = 9; const int echoPin = 10; const int ledPin=13; // defines variables long duration; int distance; void setup() { pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output pinMode(echoPin, INPUT); // Sets the echoPin as an Input Serial.begin(9600); // Starts the serial communication } void loop() { // Clears the trigPin digitalWrite(trigPin, LOW); delayMicroseconds(2); // Sets the trigPin on HIGH state for 10 micro seconds digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW); // Reads the echoPin, returns the sound wave travel time in microseconds duration = pulseIn(echoPin, HIGH); // Calculating the distance distance= duration*0.034/2; if (distance <9){ // if less than 9 cm's then the LED will turn on digitalWrite(ledPin,HIGH); } else{ digitalWrite(ledPin,LOW); // if not, LED will stay on } // Prints the distance on the Serial Monitor Serial.print("Distance: "); Serial.println(distance); }