import sys
import select

from unifr_api_epuck import wrapper


ip_addr = '192.168.10.232'
r = wrapper.get_robot(ip_addr)
r.set_speed(2,-2)#sets the speed of the wheels
r.init_sensors()#initiates the proximity sensor
#infinite loop

def is_k_pressed():
    if select.select([sys.stdin],[],[],0)[0]: # check if there is anything on stdin 
        key = sys.stdin.read(1) # read a character from the stdin

        if key == 'k': # checks if k was pressed 
            return True
    return False


while r.go_on():
    print(r.get_prox()) #prints the proximity sensor values on the terminal


    if is_k_pressed():
        break

    

#
#insert some more code here to control your robot
#
r.clean_up()
