BIRS Midterm Documentation // Konrad Krawczyk

 

1. Idea

The animal behaviour Andres and I wanted to simulate was one of a scavenger. Scavengers are animals that prey on other recently dead animals that have died from causes other than predation. Depending on the hunting behavior, scavengers vary greatly in terms of the type of food they look for, as well as their hunting style. In out exercise, we wanted to imitate the hunting style of foxes. The peculiar tendency they have is to approach their prey slowly and apprehensively, measuring the prey and watching for signs of movement, and then proceeding to eat.

2. Project.

The three parts we wanted to accomplish were: checking for movement, checking for temperature and avoiding non-animal-sized objects such as walls. In the process, we decided to skip step 2 and only use ultrasonic sensors to check for movement and size. The robot, if close enough to an object, would start a process of approaching the object and moving around it, while observing it from all different angles, and after a successful measurement it would determine that the object is food. Otherwise, in case the object moved away, or the object is not one of the desired shape, the robot’s verdict would be negative, and the robot would go away and search for another potential prey.

 

3. Project production:

This project has been marked with many technical challenges, therefore multiple iterations were delivered. We started off with the basic RobotBit setup utilising an ultrasonic sensor. To accomplish part 2, we also tested a directed laser thermometer. We tried plugging it to the I2C port on the RobotBit board, however, no signal was received. Later, we had an idea to use Arduino as a converter for the thermometer. However, we have been rightfully advised against it, as the complexity of such a connection would be extremely unfeasible and possibly would not even be effective. Therefore, we decided to focus on the ultrasonic sensor only.

The initial project involved a different pattern of measurement, as we planned the animal to move in a square. Values from the ultrasonic sensor would be stored, and if there was a large enough difference in distance, the robot would turn 90 degrees.

However, this could not possibly work because after the direction of the robot changed, the values also changed, resulting in the robot endlessly moving around itself.

Later, we decided to change the movement pattern into a circular one. In this case, if at any point the sensor lost the object out of sight, the robot would stop the process immediately and decide that the object was not food.

This was a far more successful approach. Using a circular object (garbage bin lid) we got the robot to go full circle and detect food. When the object was removed, the robot acted accordingly and stopped.

However, the limitation of this project is that it needs a highly controlled environment. One would not be able to simply put it in one room with another object and let it detect food on its own. It could technically do so, but achieving this would certainly take a long time and a lot of luck. Lastly, it doesn’t work on irregularly-shaped objects, especially when there are crevices involved. However, the project to some degree successfully implements the desired behavior. One improvement suggested during presentation would be to imitate herd behavior by letting the robot call on other foxes to signal food has been found.

Code: 

from microbit import *
import robotbit

counter = 0
initMovesCount = 12
circleMovesCount = 60
radius = 125

def initialMove():
global counter
degree = 0
if (counter < 10):
degree = counter * 10
elif (counter >= 10):
degree = 100
robotbit.servo(0,90-degree)
robotbit.motor(1, 100, 50)
counter += 1
sleep(50)

def initialMoves():
global initMovesCount
for i in range(int(initMovesCount)):
display.show(robotbit.sonar(pin1))
initialMove()

def circleMove():
global radius
robotbit.motor(1, radius, 100)
robotbit.motor(4, radius * 2, 100)
sleep(100)

def circleMoves():
global circleMovesCount
d = int(robotbit.sonar(pin1))
isFood = True
counter = 0
for i in range(int(circleMovesCount)):
d = int(robotbit.sonar(pin1))
if (d < 1 or d > 50):
isNotFood()
break
circleMove()
counter += 1
if (int(counter) >= 59):
display.scroll(‘FOOD!!!’)

def foodNoticed():
global initMovesCount
global circleMovesCount
initialMoves()
circleMoves()

def isNotFood():
display.scroll(‘NAAHT’)
robotbit.motor(0, 100, 500)
robotbit.servo(0,90)
sleep(500)

while True:
d = int(robotbit.sonar(pin1))
if (d < 1 or d > 50):
foodNoticed()
else:
robotbit.motor(0, 100, 500)
robotbit.motor(1, 100, 300)
sleep(500)
#sleep((initMovesCount * 50) + (circleMovesCount + 100))

Leave a Reply