petoi-camp-logo.png
Chinese
ZH
Chinese
ZH
English
EN
  • 主页

  • 论坛

  • Shop

  • 简介

  • 图鉴

  • 资源

    • Documentation Center
    • GitHub 源代码
    • 教程视频
    • NyBoard V0_1 手册
    • NyBoard V0_2 手册
    • Smartphone App
    • GitHub/CatMini
  • 社区

    • 成员
  • More

    Use tab to navigate through the menu items.
    Hanna Ovr
    8月02日

    Pest Control Software

    2
    0
    Rafael Marín
    3天前

    Error moving joints simultaneously in Mobile app

    5
    0
    Tomi Ade
    6天前

    Trouble Uploading to Nyboard - stk500_recv(): programmer is not responding

    3
    0
    若要查看作用方式,請前往您的即時網站。
    • 類別
    • 所有文章
    • 我的文章
    Gero
    2021年1月20日

    Make Nybble do random stuff

    在 Software

    Hi there,


    For those of you, who are using the Bluetooth-module I wrote some lines to make Nybble do random stuff within random time intervals. All the actions are send from the computer via Python PySerial and give "life" to Nybble. The next step is to read out the ultrasonic sensor via the serial port and implement obstacles avoidance. I already implemented the ultrasonic sensor via protothreading (see my other post named Protothreading) without losing movement performance.

    The serial port would be a substitution of the Raspberry Pi as a "Brain" and might be more efficient concerning battery usage.


    Make sure to set up the correct serial port in the code.


    import time
    import serial
    import random
    
    # Establish serial connection via PySerial
    ser = serial.Serial(
        port='/dev/rfcomm0', # Change according to your port
        baudrate=115200,
        parity=serial.PARITY_NONE,
        stopbits=serial.STOPBITS_ONE,
        bytesize=serial.EIGHTBITS,
        timeout=1
    )
    catStuff = ['kbalance', 'kwkF', 'kwkF', 'kwkF', 'kwkL','kwkR', 'ksit', 'khi', 'kbuttUp',  'kpee', 'd', 'd', 'd', 'kbk', 'klu']
    
    time.sleep(10)
    currentAction = 'kbalance'
    
    while(True):
        ser.write(str.encode(currentAction))
        currentAction = random.choice(catStuff)
        time.sleep(random.random()*20)
    
    

    3 則留言
    3 則留言
    R
    Rongzhong Li
    2021年1月20日

    Nice implementation!

    One note: I noticed that you put three 'd's in the list to increase their chance. There should be some Python functions to define specific probabilities for certain choices. It's necessary to stop Nybble from staying in a walking state for too long.

    按讚
    Gero
    2021年1月21日
    回覆

    Thanks!

    Yes, your annotation is correct, that I tried to increase chance. I've seen a function, but I have to take a closer look at it.

    What is your recommendation for the maximum time in walking state?

    按讚

    R
    Rongzhong Li
    2021年1月22日
    回覆

    @Gero Maybe a few seconds. It's just to avoid the cat walking off table or hitting something, before it can really see the surroundings.

    按讚
    3 則留言
    相似文章
    • Nybble with JavaScript ?
    • Making nybble work with pro micro!
    • Simulator for nybble

    Pittsburgh, PA, USA | info@petoi.com 

    © 2019 Petoi LLC

    © 2019 Petoi LLC