Skip to main content

Case 03: Dance in Figure-of-eight

Introduction

Make Cutebot travel along a figure-of-8 track.

Programming Preparation

Please refer to: Preparation for the Programming

Sample code :

from cutebot import *
from time import *

# Create a sample for Cutebot category
cutebot = Cutebot()

# Turnning by adjusting the different speed of the left and right wheels of the cutebot.
while True:
cutebot.set_speed(100,50)
sleep(2)
cutebot.set_speed(50,100)
sleep(2)

Code details

  1. Import the modules that we need: cutebot module contains classes and functions for Cutebot smart car operations, and time module contains functions for time operations.
from cutebot import *
from time import *
  1. Create a sample for Cutebot category
cutebot = Cutebot()
  1. Directions turning is done by controlling the speed difference between the left and right wheels of the cutebot smart car.
while True:
cutebot.set_speed(100,50)
sleep(2)
cutebot.set_speed(50,100)
sleep(2)

Results

After turning on the power, the cutebot smart car travels in a figure of 8 trajectory.

Exploration

How should I program the car if I want it to travel in a square trajectory?