Introduction
Humanoid is a class in a programming code that is used to control the movements of a humanoid robot. The code provides specific pins to control the robot’s movement, and it allows the robot to perform a series of actions such as dancing, flapping, moving forward, and other actions. We can learn how to program a humanoid robot to dance.
Code
sprite = Sprite('Tobi')
quarky=Quarky()
import time
humanoid = Humanoid(7,2,6,3,8,1)
quarky.showemotion("surprise")
humanoid.home()
humanoid.move("forward",1000,1)
quarky.playsound("QuarkyIntro")
humanoid.action("flapping",1000,1)
time.sleep(1)
humanoid.action("dance2",1000,1)
time.sleep(1)
humanoid.action("moonwalker",1000,1)
time.sleep(1)
humanoid.action("dance1",1000,1)
time.sleep(1)
humanoid.action("forward",1000,1)
time.sleep(1)
Humanoid.action("tiptoeswing",1000,1)
time.sleep(1)
Humanoid.action("swing",1000,1)
time.sleep(1)
Humanoid.action("flapping",1000,1)
time.sleep(1)
Humanoid.action("updown",1000,1)
Humanoid.home()
Logic
- This code is an example of how to program a humanoid robot to perform a dance routine.
- The first line code imports the time module for later use.
- Then we initialize the Humanoid object with specific pins to control the movement of the robot. The pins are passed as arguments to the Humanoid function.
- Furthermore, we involve the Quarky object showing emotion, the humanoid robot moving to its home position, and then moving forward for a specified duration and speed.
- Then, Quarky plays a sound, and the humanoid performs a series of different actions, each with specific duration and speed, including flapping, dancing, moving forward, and other actions.
- The time. sleep(1) functions are used to pause the program for one second between each action.
- Finally, the humanoid returns to its home position at the end of the program.