我只想要函数的距离值



我只想要函数的距离值,如果我打印working_odo,它会在while循环中驱动我。我只想要距离

def working_odo(): 
last_state=IO.input(15)
state_count=0
while 1:
current_state=IO.input(15)
if(current_state!=last_state):
state_count+=1
#print(state_count)
last_state=current_state
distance = 0.001*state_count

这是编码器的树莓gpio代码

我不确定这是否正确,也许是:

def working_odo(): 
# YOUR implementation here
while ... :
if (current_state != ... :
return distance # ?

最新更新