Petoi Doc Center
🇺🇸English
🇺🇸English
  • Welcome to Petoi Doc Center
  • Getting Started Guide
  • 🙋‍♂️FAQ(Frequently Asked Questions)
  • Petoi robot joint index
    • Joint Pins on NyBoard
      • Nybble
      • Bittle
    • Joint Pins on BiBoard V0
      • Bittle X
      • Bittle X+Arm
    • Joint Pins on BiBoard V1
      • Bittle X
      • Bittle X+Arm
      • Nybble Q
  • Bluetooth Connection
    • BiBoard
    • NyBoard
  • Upload Firmware
    • NyBoard
    • BiBoard V0
    • BiBoard V1
  • Joint Calibration
  • Infrared Remote
    • Remote Controller
  • Mobile App
    • Introduction
    • Calibrator
      • Nybble
      • Bittle
    • Controller
  • Desktop APP
    • Introduction
    • Firmware Uploader
      • NyBoard
      • BiBoard V0
      • BiBoard V1
    • Joint Calibrator
      • NyBoard Preparation
      • BiBoard Preparation
      • Nybble
      • Bittle / Bittle X
        • Bittle (NyBoard)
        • Bittle X (BiBoard V0)
        • Bittle X (BiBoard V1)
      • Bittle X+Arm
        • BiBoard V1
        • BiBoard V0
    • Skill Composer
      • NyBoard Connection
      • BiBoard Connection
      • Interface
        • Nybble
        • Bittle / Bittle X
        • Bittle X+Arm
    • Tools
  • Block-based programming
    • Petoi Coding Blocks
      • NyBoard Preparation
      • BiBoard Preparation
    • Block-based Coding Curriculum - Learn Quadruped Robotics for Beginners
    • Python coding mode in Mind+
    • Generic Arduino Uno Blocks
    • Install Mind+ on Chromebook
  • Arduino IDE
    • Upload Sketch for NyBoard
    • Upload Sketch for BiBoard
    • Calibrate the joints with Arduino IDE
    • Serial Monitor
    • C++ Curriculum: Learn Quadruped Robotics for Beginners
    • Install Arduino IDE on Chromebook
  • Free Curriculum
    • 📚Download
  • APIs
    • 🖇️Serial Protocol
      • Feedback servos
      • Nested task queue and signal generator
    • 🐍Python API
    • 🐛8266 MicroPython controller
      • Run MicroPython on ESP8266
      • Setup WebREPL
      • Using the ESP-NOW protocol
    • 🦎8266 Arduino C Controller
    • ©️C++ API
    • 🍓Raspberry Pi serial port as an interface
      • For BiBoard V1
    • 💻Set up Development Environment on Chromebook
    • 🤖ROS
  • Nyboard
    • Overview
    • NyBoard V1_0
    • NyBoard V1_1 & NyBoard V1_2
  • BIBOARD
    • BiBoard V0 Guide
    • BiBoard Extension Hat
    • Demo Applications
      • 1.GPIO port
      • 2.Serial port
      • 3.Analog-digital converter
      • 4.Digital-Analog Converter
      • 5.EEPROM (Electrically Erasable Programmable read only memory)
      • 6.Gyro IMU(MPU6050)
      • 7.Infrared remote control
      • 8.PWM(Pulse Width Modulation)
      • 9.Servo(under construction)
      • 10.Classic Bluetooth serial port SPP
      • 11.Bluetooth low energy (BLE) serial port pass-through
      • 12.File system SPIFFS
      • 13.Add hardware partition configuration option in Arduino IDE
      • 14.Play MP3
      • 15.The usage of Wi-Fi OTA(Over-The-Air)
    • BiBoard V1 Guide
  • Communication Modules
    • Introduction (For NyBoard)
    • USB Uploader (CH340C or CH343G)
    • Dual Mode Bluetooth
    • WiFi module ESP8266
      • ESP8266 + Python Scripts Implement wireless crowd control
  • Extensible Modules
    • Introduction
    • MU Camera
    • Ultrasonic Sensor
    • Light Sensor
    • Touch Sensor
    • Gesture Sensor
    • PIR Motion Sensor
    • IR Distance Sensor
    • Voice Command Module
    • Petoi AI Vision Module
    • Advanced development and application of AI vision modules
      • Model Training
      • Model quantification
      • Model deployment
      • Training on the COCO DIY dataset
    • Robot Arm
      • Upgrade your older Bittle/Bittle X for the robotics arm gripper
    • 🎮Joystick with Micro:Bit
  • Applications
    • Melody Creation
    • Skill Creation
    • OpenCat Imitation Tutorial
    • Programmable Puppet Character
    • Tutorial for simulating Bittle In Isaac Sim
  • History
    • Upload Sketch For NyBoard (software 1.0)
  • Technical Support
    • 💾Supporting Application and Software
    • 🔧Burn Bootloader for NyBoard
    • 🛠️Useful Tools
    • 🔋Battery
  • Useful Links 🕸
    • 🔭Home of Petoi Robots
    • 🛒Shop Coding Robots
    • 💿GitHub of OpenCat
    • 🎪PetoiCamp (Forum)
    • 📽️Petoi Robot Videos
    • 📬Users' repositories
Powered by GitBook
On this page

Was this helpful?

Export as PDF
  1. APIs

Serial Protocol

PreviousInstall Arduino IDE on ChromebookNextFeedback servos

Last updated 4 months ago

Was this helpful?

We have defined a set of serial communication protocols for robots:

All the tokens start with a single ASCII-encoded character to specify their parsing format. They are case-sensitive and usually in lowercase.

Some commands, like the c and m commands, can be combined.

For example:

Successive "m8 40", "m8 -35", "m 0 50" can be written as "m8 40 8 -35 0 50".

You can change the limit in the code, but there might be a systematic constraint for the serial buffer.

  • “ksit”

  • “m0 30”

  • “m0 -30”

  • “kbalance”

  • “kwkF”

  • “ktrL”

  • “d”

The quotation mark indicates that they are character strings. Don’t type quotation marks in the serial monitor.

You can refer to the macro definitions in OpenCat.h to utilize the most updated sets of tokens.

Some more available commands for skills:

const char* skillNameWithType[]={"bdFI","bkI","bkLI","crFI","crLI","hlwI","mhFI","mhLI","pcFI","phFI","phLI","trFI","trLI","vtFI","vtLI","wkFI","wkLI","balanceI","buttUpI","calibI","droppedI","liftedI","restI","sitI","strI","zeroN","bfI","ckI","climbCeilI","fdI","ffI","hiI","jyI","pdI","peeI","puI","pu1I","rcI","rlLI","rtI","stpI","tsI",};

All the skill names in the list can be called by adding a 'k' to the front and deleting the suffix. For example, there's "sitI" in the list. You can send "ksit" to call the sitting posture. If a skill has "F" or "L" as the second last character, it's a gait. It means walking forward or left. Walking right is a mirror of walking left. So you can send "kwkF", "kwkL", "kwkR" to make the robot walk. Similarly, there are other gaits like trot ("tr"), crawl ("cr"), and stepping ("vt").

Try the following serial commands in :

The complete set of skills in effect is defined in or : For example:

🖇️
the serial monitor
InstinctBittle.h
InstinctNybble.h
https://github.com/PetoiCamp/OpenCat/blob/3368dfd46d91cb453bb5fcca3ca4cf84712c922e/src/OpenCat.h#L204-L254
//token list
#define T_ABORT 'a'      //abort the calibration values
#define T_BEEP 'b'       //b note1 duration1 note2 duration2 ... e.g. b12 8 14 8 16 8 17 8 19 4 \
                         //a single 'b' will toggle the melody on/off
#define T_CALIBRATE 'c'  //send the robot to calibration posture for attaching legs and fine-tuning the joint offsets. \
                         //c jointIndex1 offset1 jointIndex2 offset2 ... e.g. c0 7 1 -4 2 3 8 5
#define T_REST 'd'
#define T_GYRO_FINENESS 'g'             //adjust the finess of gyroscope adjustment to accelerate motion
#define T_GYRO_BALANCE 'G'              //toggle on/off the gyro adjustment
#define T_INDEXED_SIMULTANEOUS_ASC 'i'  //i jointIndex1 jointAngle1 jointIndex2 jointAngle2 ... e.g. i0 70 8 -20 9 -20 \
                                        //a single 'i' will free the head joints if it were previously manually controlled.
#define T_JOINTS 'j'                    //A single "j" returns all angles. "j Index" prints the joint's angle. e.g. "j 8" or "j11".
#define T_SKILL 'k'
#define T_SKILL_DATA 'K'
#define T_INDEXED_SEQUENTIAL_ASC 'm'  //m jointIndex1 jointAngle1 jointIndex2 jointAngle2 ... e.g. m0 70 0 -70 8 -20 9 -20
// #define T_MELODY 'o'
#define T_PAUSE 'p'
// #define T_SLOPE 'l'
#define T_SAVE 's'  //save the calibration values
// #define T_TILT 't'
// #define T_MEOW 'u'
#define T_PRINT_GYRO 'v'            //print the Gyro data once
#define T_VERBOSELY_PRINT_GYRO 'V'  //toggle verbosely print Gyro data
// #define T_XLEG        'x'
// #define T_ACCELERATE  '.'
// #define T_DECELERATE  ','
#define T_RANDOM_MIND 'z'  //toggle random behaviors in the RANDOM_MIND mode
#define T_QUERY '?'

#ifdef GROVE_SERIAL_PASS_THROUGH
#define T_READ 'R'        //read pin     R
#define T_WRITE 'W'       //write pin                      W
#define TYPE_ANALOG 'a'   //            Ra(analog read)   Wa(analog write)
#define TYPE_DIGITAL 'd'  //            Rd(digital read)  Wd(digital write)
#endif
#define T_COLOR 'C'                     //change the eye colors of the RGB ultrasonic sensor
#define T_INDEXED_SIMULTANEOUS_BIN 'I'  //I jointIndex1 jointAngle1 jointIndex2 jointAngle2 ... e.g. I0 70 8 -20 9 -20
#define T_INDEXED_SEQUENTIAL_BIN 'M'    //M jointIndex1 jointAngle1 jointIndex2 jointAngle2 ... e.g. M0 70 0 -70 8 -20 9 -20

#define BINARY_COMMAND  //disable the binary commands to save space for the simple random demo

#ifdef BINARY_COMMAND
#define T_BEEP_BIN 'B'    //B note1 duration1 note2 duration2 ... e.g. B12 8 14 8 16 8 17 8 19 4
#define T_LISTED_BIN 'L'  //a list of the DOFx joint angles: angle0 angle1 angle2 ... angle15
// #define T_SERVO_MICROSECOND 'w'  //PWM width modulation
#define T_TEMP 'T'  //call the last 'K' skill data received from the serial port
#endif

#define EXTENSION 'X'
#define EXTENSION_VOICE 'A'
#define EXTENSION_ULTRASONIC 'U'