MAI-SR / StudentRobotics-2015-2016

Game Mode: Sunny Side Up
https://mai-robotics.de/
2 stars 2 forks source link

Detect obsticals #5

Open ThorbenH opened 9 years ago

ThorbenH commented 9 years ago

This method is supposed to find out if there is and obstacle and if there is just a wall and in case there is an obstacle the robot will drive around it if not then it will just continue with what it was told to do because there is nothing wrong with the enviroment

picuber commented 9 years ago

def calculateUS(usnumber): #calculates the value the ultrasonic sensor is supposed to give USrotation = robotrotation + usnumber * 90 barrier = false dist = 0.00 while barrier == false: dist = dist + 0.05 tmpPoint = calculatePoint(dist, USrotation) barrier = inBarrier(tmpPoint[0], tmpPoint[1]) return dist

def calculatePoint(dist, rotation): #calculates a point in relation to the robots current position tmpX = robotX + math.cos(rotation) * dist tmpY = robotY + math.sin(rotation) * dist return (tmpX, tmpY)

def inBarrier(x, y): #calculates if a point is inside a barrier print "ToDo"

picuber commented 9 years ago

robotrotation = 45 #current direction the robot is facing robotX = 0 #current x position of the robot robotY = 0 #current y position of the robot token = null #current token the robot is trying to get or null for when its not searching for a token

ThorbenH commented 9 years ago

magic