导航

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

    3qho

    @3qho

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

    3qho 关注

    3qho 发布的帖子

    • 在openmv中使用mqtt经常会在通信过程中报OSError:-6或者OSError:-12的错误是为什么呢?

      大致内容如下

      forkliftid = 'A01'
      containerid = '00000001'
      def pub_push_position(forkliftid,containerid='',x='',y='',theta=''):
          tempPic = sensor.snapshot().save("position.jpg", quality=35)
          imagePath = '.\\position.jpg'
          with open(imagePath, 'rb') as p:
              tempPic = p.read()
              base64pic = ubinascii.b2a_base64(tempPic)
              pic = str(base64pic, 'utf-8').strip()
          msg = 'B@POSITION,{0},{1},{2},{3},{4},{5}'.format(forkliftid,containerid,x,y,theta,pic)
          client.publish('/v1/device/push', msg)
      
      SSID='myInternet' # 无线网络名称
      KEY='12345677'  # 无线网络密码
      wlan = network.WINC()
      wlan.connect(SSID, key=KEY, security=wlan.WPA_PSK)
      client = MQTTClient("test", '192.168.99.250', port=1883)
      client.connect()
      
      
      while True:
          p_in = pyb.Pin('P9', pyb.Pin.IN, pyb.Pin.PULL_UP)
          if p_in.value() == 0:
              pub_push_position(forkliftid,containerid,x,y,theta)  
              # x,y,theta是apriltags的x,y和z_rotation
          client.check_msg()
      
      发布在 OpenMV Cam
      3
      3qho
    • RE: 想把openmv代码print出的数据显示在自己的lcd屏上,请问该怎么操作?自己的lcd屏更大

      img.draw_string(x轴位置,y轴位置,要打印的东西,字体颜色color=(),字体大小scale=)

      发布在 OpenMV Cam
      3
      3qho
    • 如何求解空间中openmv的位置?

      通过Apriltags可以进行测距,如何使用AprilTags提供的坐标转换为空间中openmv的位置。例如我将AprilTag摆放在{'x':500,'y':500,'z':0}的位置得到tx,ty,tz,rx,ry,rz的值,并通过移动距离/tx(ty)的方式得出的xk、yk

      cosPitch = math.cos(Ry)
      cosYaw = math.cos(Rz)
      cosRoll = math.cos(Rx)
      
      sinPitch = math.sin(Ry)
      sinYaw = math.sin(Rz)
      sinRoll = math.sin(Rx)
      
      if tag.id() in range(len(tags)):  # tags是存放规定tag坐标的列表
          X = cosPitch * cosYaw * Tx * xk + cosPitch * sinYaw * Ty * yk - sinPitch * Tz * zk
          Y = (-cosRoll * sinYaw + sinRoll * sinPitch * cosYaw) * Tx * xk + (cosRoll * cosYaw + sinRoll * sinPitch * sinYaw) * Ty * yk + sinRoll * cosPitch * Tz * zk
          Z = (sinRoll * sinYaw + cosRoll * sinPitch * cosYaw) * Tx * xk + (-sinRoll * cosYaw + cosRoll * sinPitch * sinYaw) * Ty * yk + cosRoll * cosPitch * Tz * zk
      
          changed = (X, Y, Z)
      
          currentX = str(round((tags[currentID].get('x') - X) / 10, 2)) + 'cm'
          currentY = str(round((tags[currentID].get('y') - Y) / 10, 2)) + 'cm'
          currentZ = str(round((tags[currentID].get('z') - Z) / 10, 2)) + 'cm'``
      

      是否能通过这种方式正确的得出openmv自身的位置?另外xk、yk的值是否和求z方向的k值的方式一致?

      发布在 OpenMV Cam
      3
      3qho
    • RE: openmv如何保存内容倒文本文档?

      已解决,在with as语句之后使用pyb.hard_reset()软重启

      发布在 OpenMV Cam
      3
      3qho
    • openmv如何保存内容倒文本文档?

      在使用mqtt接收指令之后需要将指令的标题和信息内容保存到文本文档中

      filename = 'sub.txt'
      
      def callback(topic, msg):
          topic = str(topic, 'utf-8')
          msg = str(msg, 'utf-8').split(',')    
          with open(filename, 'a') as subTxt:
              msg2str = ','.join(msg)
              textContent = topic + ' ' + msg2str + '\n'
              subTxt.write(textContent)
      

      确认写入的字符串没有问题,使用open(filename, 'r')也能读取到写入的内容

      但是无论如何在磁盘中没有出现相应的文本文档,并且在重新开启脚本之后会重置内容

      是否能够证明内容实际一直存储在缓冲区并未实际写入?

      应该如何解决?

      发布在 OpenMV Cam
      3
      3qho