[英]Using Time with Micropython Mac OSX Python2.7
I am using a sensor fusing python module base off of the Madwick Algorithm. 我正在使用基于Madwick算法的传感器融合python模块。 The source code can be found here https://github.com/micropython-IMU/micropython-fusion/blob/master/fusion.py.
可以在这里找到源代码https://github.com/micropython-IMU/micropython-fusion/blob/master/fusion.py。
Is there any way I could implement the function below pyb.elapsed_micro() and pyb.micros() without using the import pyb library with python2.7? 有什么办法可以实现pyb.elapsed_micro()和pyb.micros()下面的功能,而无需在python2.7中使用导入pyb库?
import pyb
# Integrate to yield quaternion
deltat = pyb.elapsed_micros(self.start_time) / 1000000
self.start_time = pyb.micros()
q1 += qDot1 * deltat
q2 += qDot2 * deltat
q3 += qDot3 * deltat
q4 += qDot4 * deltat
# normalise quaternion
norm = 1 / sqrt(q1 * q1 + q2 * q2 + q3 * q3 + q4 * q4)
self.q = q1 * norm, q2 * norm, q3 * norm, q4 * norm
pyb.micros() - sets starting in microseconds pyb.micros()-设置以微秒为单位
pyb.elapsed_time(start_time) - determines the elapsed time between startime and the time it took to call this function pyb.elapsed_time(start_time)-确定从开始时间到调用此函数所花费的时间之间的经过时间
import time
def micros():
return time.time() * 1000000 ##turns seconds into microseconds
def elapsed_micros(start_time):
return start_time - time.time()*1000000
For more support check github link to issue - https://github.com/micropython-IMU/micropython-fusion/issues/1 要获得更多支持,请检查发出的github链接-https: //github.com/micropython-IMU/micropython-fusion/issues/1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.