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!")