导航

    • 登录
    • 搜索
    • 版块
    • 产品
    • 教程
    • 论坛
    • 淘宝
    1. 主页
    2. 一路漫歌
    一
    • 举报资料
    • 资料
    • 关注
    • 粉丝
    • 屏蔽
    • 帖子
    • 楼层
    • 最佳
    • 群组

    一路漫歌

    @一路漫歌

    0
    声望
    12
    楼层
    1191
    资料浏览
    0
    粉丝
    0
    关注
    注册时间 最后登录

    一路漫歌 关注

    一路漫歌 发布的帖子

    • TypeError:unsupported types for _truediv_:'NoneType','float'

      编译错误TypeError:unsupported types for truediv:'NoneType','float'
      0_1531123770395_搜狗截图18年07月09日1605_7.png

      def find_Error(GRAYSCALE_THRESHOLD):
      
          weight_sum = 0 #权值和初始化
          #利用颜色识别分别寻找三个矩形区域内的线段
          for r in ROIS:
              blobs = img.find_blobs(GRAYSCALE_THRESHOLD, roi=r[0:4], pixels_threshold=200, area_threshold=200, merge=True)
              # find_blobs就是找黑色区域色块, r[0:4] 是roi元组.
              # 找到视野中的线,merge=true,将找到的图像区域合并成一个
      
              centroid_sum = find_Line(blobs)
      
              weight_sum += r[4]
          center_pos = (centroid_sum / weight_sum)   # 三个ROI区域中心x坐标,进行加权平均后获得的x坐标值,用来确定小车偏转方向
          x_error = center_pos - img.width()/2 + 5   #用于计算目标色块的中心值x坐标值和整个画面中心x坐标值的差值,max_blob[5]代表检测到色块的x坐标值,
                                      #整个画面中心x坐标值为80,由于实际有误差小车偏向一侧,经校正为75
          print("x_error: ",x_error)
          return x_error
      
      发布在 OpenMV Cam
      一
      一路漫歌
    • 相机有畸变该如何解决

      0_1529894912953_搜狗截图18年06月25日1048_4.png

      发布在 OpenMV Cam
      一
      一路漫歌
    • RE: 运行示例程序Servo-shield程序时,报错OSError:[Error 110]ETIMEDOUT

      @kidswong999 我已经扫描地址了,但是返回的结果的是空的,我是不是哪里写错了0_1529411835783_搜狗截图18年06月19日2034_1.png

      发布在 OpenMV Cam
      一
      一路漫歌
    • RE: 运行示例程序Servo-shield程序时,报错OSError:[Error 110]ETIMEDOUT

      @kidswong999我开始怀疑你们这个程序有问题,这个程序没有问题是吗?你们测试过这个程序吗?

      发布在 OpenMV Cam
      一
      一路漫歌
    • 运行示例程序Servo-shield程序时,报错OSError:[Error 110]ETIMEDOUT

      OpenMV已经与PCA9685硬件连接,运行Servo-shield程序时,但是会报错OSError:[Error 110]ETIMEDOUT,该如何解决
      0_1529311920405_搜狗截图18年06月18日1637_1.png
      mian.py

      # Servo Shield Example.
      #
      # This example demonstrates the servo shield. Please follow these steps:
      #
      #   1. Connect a servo to any PWM output.
      #   2. Connect a 3.7v battery (or 5V source) to VIN and GND.
      #   3. Copy pca9685.py and servo.py to OpenMV and reset it.
      #   4. Connect and run this script in the IDE.
      
      import time
      from servo import Servos
      from machine import I2C, Pin
      
      i2c = I2C(sda=Pin('P5'), scl=Pin('P4'))
      servo = Servos(i2c, address=0x40, freq=50, min_us=650, max_us=2800, degrees=180)
      
      while True:
          for i in range(0, 8):
              servo.position(i, 0)
          time.sleep(500)
          for i in range(0, 8):
              servo.position(i, 180)
          time.sleep(500)
      
      

      PCA9685.py

      import utime
      import ustruct
      class PCA9685:
      	def __init__(self, i2c, address=0x40):
      		self.i2c = i2c
      		self.address = address
      		self.reset()
      	def _write(self, address, value):
      		self.i2c.writeto_mem(self.address, address, bytearray([value]))
      	def _read(self, address):
      		return self.i2c.readfrom_mem(self.address, address, 1)[0]
      	def reset(self):
      		self._write(0x00, 0x00)
      	def freq(self, freq=None):
      		if freq is None:
      			return int(25000000.0 / 4096 / (self._read(0xfe) - 0.5))
      		prescale = int(25000000.0 / 4096.0 / freq + 0.5)
      		old_mode = self._read(0x00)
      		self._write(0x00, (old_mode & 0x7F) | 0x10)
      		self._write(0xfe, prescale)
      		self._write(0x00, old_mode)
      		utime.sleep_us(5)
      		self._write(0x00, old_mode | 0xa1)
      	def pwm(self, index, on=None, off=None):
      		if on is None or off is None:
      			data = self.i2c.readfrom_mem(self.address, 0x06 + 4 * index, 4)
      			return ustruct.unpack('<HH', data)
      		data = ustruct.pack('<HH', on, off)
      		self.i2c.writeto_mem(self.address, 0x06 + 4 * index,  data)
      	def duty(self, index, value=None, invert=False):
      		if value is None:
      			pwm = self.pwm(index)
      			if pwm == (0, 4096):
      				value = 0
      			elif pwm == (4096, 0):
      				value = 4095
      			value = pwm[1]
      			if invert:
      				value = 4095 - value
      			return value
      		if not 0 <= value <= 4095:
      			raise ValueError("Out of range")
      		if invert:
      			value = 4095 - value
      		if value == 0:
      			self.pwm(index, 0, 4096)
      		elif value == 4095:
      			self.pwm(index, 4096, 0)
      		else:
      			self.pwm(index, 0, value)
      
      

      servo.py

      import pca9685
      import math
      
      class Servos:
          def __init__(self, i2c, address=0x40, freq=50, min_us=600, max_us=2400, degrees=180):
              self.period = 1000000 / freq
              self.min_duty = self._us2duty(min_us)
              self.max_duty = self._us2duty(max_us)
              self.degrees = degrees
              self.freq = freq
              self.pca9685 = pca9685.PCA9685(i2c, address)
              self.pca9685.freq(freq)
      
          def _us2duty(self, value):
              return int(4095 * value / self.period)
      
          def position(self, index, degrees=None, radians=None, us=None, duty=None):
              span = self.max_duty - self.min_duty
              if degrees is not None:
                  duty = self.min_duty + span * degrees / self.degrees
              elif radians is not None:
                  duty = self.min_duty + span * radians / math.radians(self.degrees)
              elif us is not None:
                  duty = self._us2duty(us)
              elif duty is not None:
                  pass
              else:
                  return self.pca9685.duty(index)
              duty = min(self.max_duty, max(self.min_duty, int(duty)))
              self.pca9685.duty(index, duty)
      
          def release(self, index):
              self.pca9685.duty(index, 0)
      
      
      发布在 OpenMV Cam
      一
      一路漫歌
    • RE: I2C报错OSError:[Error 110]ETIMEDOUT

      @kidswong999
      我跑这个程序,也会报错
      0_1528878561809_搜狗截图18年06月13日1629_2.png

      发布在 OpenMV Cam
      一
      一路漫歌
    • RE: I2C报错OSError:[Error 110]ETIMEDOUT

      @kidswong999 哪有没有什么方法验证I2C通讯正常

      发布在 OpenMV Cam
      一
      一路漫歌
    • RE: I2C报错OSError:[Error 110]ETIMEDOUT

      @kidswong999 我已经连上PCA9685了

      发布在 OpenMV Cam
      一
      一路漫歌
    • RE: I2C报错OSError:[Error 110]ETIMEDOUT

      @kidswong999 请问这个报错是什么意思啊

      发布在 OpenMV Cam
      一
      一路漫歌