pyBittle
  • About pyBittle
  • Users guide
    • Installation
    • Usage Examples
      • Connecting to Bittle
      • Movement commands
    • Project Examples
      • BittleXboxController
  • Documentation
    • bittleManager
      • Bittle()
      • Command
      • Direction
      • Gait
    • bluetoothManager
      • BluetoothManager()
    • serialManager
      • SerialManager()
    • wifiManager
      • WifiManager()
  • Changelog
    • v1.0.0
    • V1.1.3
Powered by GitBook
On this page

Was this helpful?

  1. Users guide
  2. Usage Examples

Movement commands

An example of creating a Bittle instance and sending movement commands with different gaits.

Sending movement commands

This example shows how to create a Bittle instance, how to connect to it through WiFi and how to send movements commands.

import pyBittle
import time


forward = pyBittle.Direction.FORWARD
forward_right = pyBittle.Direction.FORWARDRIGHT
stop = pyBittle.Command.BALANCE  # BALANCE is Command type, not Direction type!

crawl = pyBittle.Gait.CRAWL
trot = pyBittle.Gait.TROT

bittle = pyBittle.Bittle()  # Create Bittle instance
bittle.wifiManager.ip = '192.168.1.132'  # Set Bittle IP address

has_connection = bittle.has_wifi_connection()
if has_connection:
    bittle.gait = crawl  # Change current gait (WALK) to CRAWL
    bittle.send_movement_wifi(forward)
    time.sleep(5)
    bittle.send_movement_wifi(forward_right)
    time.sleep(3)
    
    bittle.gait = trot # Change current gait (WALK) to TROT
    bittle.send_movement_wifi(forward)
    time.sleep(5)
    
    bittle.send_command_wifi(stop)  # Send command, not movement (as BALANCE is Command type)
    time.sleep(2)
else:
    print("Can't connect to Bittle!")
PreviousConnecting to BittleNextProject Examples

Last updated 4 years ago

Was this helpful?