I'm working on controlling robot with commands send from android app through HTTPRequestHandler on Raspberry Pi.
class RequestHandler_httpd(BaseHTTPRequestHandler):
def do_GET(self):
global Request
messagetosend = bytes('x',"utf")
self.send_response(200)
self.send_header('Content-Type', 'text/plain')
self.send_header('Content-Length', len(messagetosend))
self.end_headers()
self.wfile.write(messagetosend)
Request = self.requestline
Request = Request[5 : int(len(Request)-9)]
print(Request)
global hight, speed, sleep
while Request == 'forward':
Forward()
while Request == 'turnleft':
TurnLeft()
while Request == 'turnright':
TurnRight()
while Request == 'base':
BasePosition()
return
My problem is that when I send command from my phone which is basically ip:port/x robot gets stuck on one function. If I for example want to use function "Forward" it will keep doing forward even when next request will be "turnleft". It works if I just use if statements but I want my robot to constantly execute function until I want to use different function. There's no loop in the functions Forward, TurnLeft, TurnRight, BasePosition.