老哥请问你搞出来了吗?能分享一下源码吗?感谢!
P
pm1f
@pm1f
0
声望
9
楼层
1100
资料浏览
1
粉丝
0
关注
pm1f 发布的帖子
-
关于openmv星瞳官网的PID代码理解
from pyb import millis from math import pi, isnan class PID: _kp = _ki = _kd = _integrator = _imax = 0 _last_error = _last_derivative = _last_t = 0 _RC = 1/(2 * pi * 20) def __init__(self, p=0, i=0, d=0, imax=0): self._kp = float(p) self._ki = float(i) self._kd = float(d) self._imax = abs(imax) self._last_derivative = float('nan') def get_pid(self, error, scaler): tnow = millis() dt = tnow - self._last_t output = 0 if self._last_t == 0 or dt > 1000: dt = 0 self.reset_I() self._last_t = tnow delta_time = float(dt) / float(1000) output += error * self._kp if abs(self._kd) > 0 and dt > 0: if isnan(self._last_derivative): derivative = 0 self._last_derivative = 0 else: derivative = (error - self._last_error) / delta_time derivative = self._last_derivative + \ ((delta_time / (self._RC + delta_time)) * \ (derivative - self._last_derivative)) self._last_error = error self._last_derivative = derivative output += self._kd * derivative output *= scaler if abs(self._ki) > 0 and dt > 0: self._integrator += (error * self._ki) * scaler * delta_time if self._integrator < -self._imax: self._integrator = -self._imax elif self._integrator > self._imax: self._integrator = self._imax output += self._integrator return output def reset_I(self): self._integrator = 0 self._last_derivative = float('nan')
请问这个PID是增量式PID调节吗?还有就是请问这是串级PID调节吗?想知道用python如何写串级PID(做板球系统)
-
openmv IO口相关问题
请问我想在mv上接一个按键,可以随便接一个io口吗?怎么定义这个io用于按键操作并按下执行相关功能?接线是不是一端接io口一端接gnd就行了呢?,感谢回答
-
openmv串口和测距模块
import sensor, image, time from machine import I2C from vl53l1x import VL53L1X from pyb import LED from pyb import UART, Timer from pyb import Servo from pid import PID uart = UART(1,115200) i2c = I2C(2) distance = VL53L1X(i2c) test_state = 1 L = 0 chang = 0 #cir.r = 300 pan_pid=PID(p=0.05, i=0.01, d=0, imax=90) #在线调试PID tilt_pid=PID(p=0.05, i=0.012,d=0, imax=90) #pan_pid=PID(p=0.06, i=0.1, d=0.02, imax=100) #脱机运行PID #tilt_pid=PID(P=0.05, i=0.05, d=0, imax=90) ''' rect_threshold=(20, 47, 29, 70, 12, 58) #(24, 45, 32, 70, 12, 58) circle_threshold=(61, 23, 31, 81, 5, 59) ''' all_thresholds = [(30, 100, 15, 127, 15, 127), # _red_thresholds (30, 100, -64, -8, -32, 32), # _green_thresholds (0, 15, 0, 40, -80, -20)] # _blue_thresholds sensor.reset() sensor.set_pixformat(sensor.RGB565) # 灰度更快(160x120 max on OpenMV-M7) sensor.set_framesize(sensor.QQVGA) sensor.skip_frames(time = 2000) sensor.set_auto_gain(False) sensor.set_auto_whitebal(False) clock = time.clock() def uart_singal(): buff = 0 buff = uart.any() if buff > 0: _data_receive(readchar()) else: pass def _data_receive(data): if data == 65: test_state = 1 elif data == 66: test_state = 2 else: print('error!!!') def test1_2(): for r in img.find_rects(threshold = 20000): area_rectangle = (r.rect()) #是为了在检测矩形的基础上检测有颜色的矩形 for blob in img.find_blobs(all_thresholds, pixels_threshold=100, area_threshold=100, merge=True, margin=10,roi = area_rectangle): img.draw_rectangle(area_rectangle, color = (0, 255, 0)) LED(1).toggle() for c in img.find_circles(threshold = 2200): area_circle = (c.x()-c.r(), c.y()-c.r(), 2*c.r(), 2*c.r())#是为了在检测有圆的基础上检测有颜色的圆 draw_cir = (c.x(), c.y(), c.r())#画圆的轮廓 for blob in img.find_blobs(all_thresholds, pixels_threshold=100, area_threshold=100, merge=True, margin=10, roi = area_circle): img.draw_circle(draw_cir, thickness=1, color = (0,255,0), fill=False) LED(3).toggle() L = distance.read()-50 print(L) chang = L uart.write(chang) def test3_4(): pass def find_max(blobs): max_size=0 for blob in blobs: if blob[2]*blob[3]>max_size: max_blob=blob max_size=blob[2]*blob[3] return max_blob while(True): clock.tick() img = sensor.snapshot() if(test_state == 1): test1_2() elif(test_state == 2): test3_4() else: pass uart_singal()
我想问问为啥我用串口1发送openmv测距模块得到的距离值他会报错,测距模块不是占用的串口3吗?
-
RE: Apriltag识别中,怎么定位/测距?输出的tx ty tz的单位是什么?怎么就得到实际的距离了?
@yuan 请问Apriltag咋测距的?这个视频已经看不到了,感谢!