Introduction
In this project, we will explain how to run predefined motions in PictoBlox for the Quadruped. The predefined motions allow users to make the robot move forward, backward, left, right, and much more.
Code
sprite = Sprite('Tobi')
quirky = Quarky()
import time
quad=Quadruped(4,1,8,5,3,2,7,6)
while True:
quad.home()
time.sleep(0.5)
quad.move("forward",1000,2)
time.sleep(0.5)
quad.move("backward",1000,2)
time.sleep(0.5)
quad.move("lateral left",1000,2)
time.sleep(0.5)
quad.move("lateral Right",1000,2)
quad.home()
Logic
- First, import time imports the built-in time module, which provides functions for dealing with time.
- While True creates an infinite loop that will continue running until the program is interrupted.
- Then we call quad.home() is the home method of the Quadruped class, which resets the position of the quadruped object to its starting position.
- Now,time.sleep(0.5) causes the program to pause for 0.5 seconds before continuing to the next line of code.
- Then quad.move(“forward”,1000,2) causes the quadruped to move forward 1000 steps at a speed of 2 steps per second.
- Steps 7 and 8 are repeated for the “backward“, “lateral left“, and “lateral right” movements, each with a pause in between.
- Furthermore,home () is called again to return the quadruped to its starting position.
- Overall, We can program a quadruped robot to move in predefined motions, such as forward, backward, left, and right.