Midterm Post – Scavenger Robot – Andres Malaga

Research proposal:

               Konrad and I decided to attempt to recreate the behavior of a scavenger. A scavenger is an animal that feeds off of carrion (the decaying flesh of a dead animal). The only animals who are purely scavengers are vultures, since they are able to identify carrion while they fly and thus can find food more easily than terrestrial (land) animals. There are terrestrial animals who scavenge, but they don’t rely solely on this, they also predate. Such is the case of wolves, foxes and hyenas, just to name a few. In order to see how the behavior we wanted to imitate was like, we watched a video by BBC Earth that shows a crow, a group of vultures and a fox feeding on a dead cow’s carcass. We saw that the crow landed on top of a dead cow and started inspecting it, then a flock of vultures arrived and also started inspecting the body of the cow and after a minute or so of inspecting the carrion, they started eating it. We decided to imitate this behavior with our robot. We want our robot to approach an object, round it and inspect it to determine whether or not it is food. The idea is that the robot uses its ultrasonic sensor to measure the size of the object it is going around and determine through changes in its measurement whether it is of ideal size, too big, or a wall, thus determining whether or not the object is food. The embedded video is the video we saw to come up with the idea for the behavior.

Documentation:

               We were looking at different animals’ behavior and Konrad said he was thinking about making a robot that could identify whether an object was food or not; I then associated it with a scavenger, so we started planning how we would mimic the behavior. We first thought of using a pointed temperature sensor (which ended up only working with Arduino) along with the Kittenbot’s ultrasonic sensor, but ultimately just used the latter, as it would take a lot of work to connect the Arduino to our Kittenbot and program it so that it preferred objects within a certain temperature range. Thus, we decided to go on only using the ultrasonic sensor. No components other than the Kittenbot were used. We chose to program the Kittenbot to approach an object to a certain distance at a constant speed and move around it with its ultrasonic sensor pointed at it so that it measured the distance between the object and itself. The idea was that once it detected the distance increased it would do a 90 degree turn and repeat the same assessment, determining whether or not the object is small enough for it to ‘eat’ (if it kept advancing in the same direction for a long time it would have interpreted it as a wall), representing the “eating” with a sound and displaying ‘eat’ on the microbit’s screen. Once Konrad programmed the robot to behave that way (I couldn’t contribute much to the programming, since I don’t know much python), we found out that it ended up detecting anything but food, so he decided to reprogram it so that it moved more slowly and in a circle, which would give more precise readings and would result in the robot not spinning in circles because the distance was beyond the threshold, which was the main problem we found.

It ended up working like this:

Here is the code we used:


  1. from microbit import *

  2. import music

  3. import robotbit

  4. counter = 0

  5. initMovesCount = 12

  6. circleMovesCount = 60

  7. radius = 125

  8. def initialMove():

  9. global counter

  10. degree = 0

  11. if (counter < 10):

  12. degree = counter * 10

  13. elif (counter >= 10):

  14. degree = 100

  15. robotbit.servo(0,90-degree)

  16. robotbit.motor(1, 100, 50)

  17. counter += 1

  18. sleep(50)

  19. def initialMoves():

  20. global initMovesCount

  21. for i in range(int(initMovesCount)):

  22. display.show(robotbit.sonar(pin1))

  23. initialMove()

  24. def circleMove():

  25. global radius

  26. robotbit.motor(1, radius, 100)

  27. robotbit.motor(4, radius * 2, 100)

  28. sleep(100)

  29. def circleMoves():

  30. global circleMovesCount

  31. d = int(robotbit.sonar(pin1))

  32. isFood = True

  33. counter = 0

  34. for i in range(int(circleMovesCount)):

  35. d = int(robotbit.sonar(pin1))

  36. if (d < 1 or d > 50):

  37. isNotFood()

  38. break

  39. circleMove()

  40. counter += 1

  41. if (int(counter) >= 59):

  42. display.scroll('FOOD!!!')

  43. def foodNoticed():

  44. global initMovesCount

  45. global circleMovesCount

  46. initialMoves()

  47. circleMoves()

  48. def isNotFood():

  49. display.scroll('NAAHT')

  50. robotbit.motor(0, 100, 500)robotbit.servo(0,90)

  51. sleep(500)

  52. while True:

  53. d = int(robotbit.sonar(pin1))

  54. if (d < 1 or d > 50):

  55. foodNoticed()

  56. else:

  57. robotbit.motor(0, 100, 500)

  58. robotbit.motor(1, 100, 300)

  59. sleep(500)

  60. #sleep((initMovesCount * 50) + (circleMovesCount + 100))

Leave a Reply