do () motion () times at () speed

Description

The block performs the selected motion for the humanoid. The motion runs for the specified times and at the specified speed.

Available Motions:

Available Speeds:

If you want to perform the motion at a different speed, then you can use a variable to define the speed.

Example

Learn about humanoid robots, their form and functionality, and how the program uses arrow keys to control humanoid movement in different directions and speed.

Introduction

A humanoid is a type of robot or artificial system that is designed to resemble a human being in its form and functionality. Humanoid robots are typically equipped with sensors, actuators, and artificial intelligence capabilities that enable them to interact with their environment and perform tasks that are similar to those of a human being. Humanoid robots are used in various fields, including robotics research, entertainment, healthcare, education, and customer service.

Logic

The Humanoid will move according to the following logic:

  1. When the “UP” key is pressed – Humanoid will move forward.
  2. When the “Down” key is pressed – Humanoid will move Backward.
  3. When the “Left” key is pressed – Humanoid will turn left.
  4. When the “Right” key is pressed – Humanoid will turn Right.

Code

The program uses the up, down, left, and right arrows to control the robot and make it move forward, backward, left, and right. Every time you press one of the arrows, Humanoid will move in the direction you choose.

  1. First, we initialize the humanoid extension by dragging and dropping it onto the block we want to use for the humanoid.
  2. Then, we initialize the IF-ELSE block from the control palette.
  3. Here, we use the logic that if the up arrow key is pressed, the humanoid will move forward one step at a specific speed.
  4. If the down arrow key is pressed, the humanoid will move backward one step at a specific speed.
  5. When the right arrow key is pressed, the humanoid will move in the right direction one step at a specific speed using do() motion () times at () speed.
  6. If no key is pressed, the humanoid will return to its home position.

Output

Read More
Learn how to use PictoBlox to control the predefined motions of the Quadruped robot.

Activity Description

In this activity, you use a visual block-based coding environment to program a quadruped robot. The code shows how to set servo motor pins for each leg and define movement patterns such as forward, backward, lateral left, and lateral right. You also learn to control the robot’s speed and timing using variables and wait blocks. The robot starts in a neutral “home” position and performs motion sequences repeatedly or based on your inputs. This activity helps you understand basic robotics, motion control, and sequential logic in a hands-on, engaging way.

Activity 1: Quadruped Movements

Let’s Code

Follow the steps

  1. Open the PictoBlox application from the Start Menu.
  2. Select the inviting realm of Blocks as your coding environment.
  3. Connect “Quarky” to your computer using a USB cable. Then, click the Board button in the toolbar and select board as Quarky.
  4. Next, select the appropriate Serial port if the Quarky is connected via USB or the Bluetooth Port if you want to connect Quarky via Bluetooth and press Connect.
  5. Click on the Add Extension button and add the Quarky Quadruped extension.
  6. Add when flag clicked block from the Event Palette.
  7. To set up the quadruped, you can drag and drop pins for each leg and hip into the initialisation block using set pins FR Hip () FL Hip () FR Leg () FL Leg() BR Hip () BL Hip () BR Leg () BL Leg () blocks. This block sets which pins on the Quarky controller board control each servo motor for the front right (FR), front left (FL), back right (BR), and back left (BL) hips and legs. Drag this block and set each PIN as shown.
  8. Add the “home” block right after setting pins.. This will bring the robot to its initial position.
  9. Add a wait block after home. This gives the robot time to move to the home position before doing the next action.
  10. Add the do forward motion 1 time at Medium speed block. This block instructs the quadruped robot on how to movehow many times, and at what speed.
    For example:

    This makes the robot take one step forward at medium speed.
  11. Add the “home” block right after setting pins.. This will bring the robot to its initial position. Click on the green flag to run the motion sequence.
Note: You can change the direction, number of times, and speed of the motion block. There are 8 predefined motions to choose from for your robot’s movement!

Activity 2: Controlling Speed using Variables

Introduction to Variable

A variable is a named storage that holds a value which can change during the program. In programming, a variable is a named space in memory used to store data that can change during the execution of a program. It acts like a container that holds information—such as numbers, text, or other data types—which you can create, modify, and use throughout your code. Variables make programs flexible and dynamic by allowing data to be reused and updated.
Example:

Think of a school bag with your favourite toy inside. You can change the toy anytime — today it’s a car, tomorrow it’s a doll.

Let’s Code

  1. Click on the Variables category in the blocks palette.
  2. Create a New Variable: Click on the “Make a Variable” button.
  3. Enter Variable Name: In the New Variable window, type your variable name in the box.
    (e.g., type Speed as shown in the picture)
  4. Click the OK button to create your variable.
  5. Add when flag clicked block from the Event Palette.
  6. To set up the quadruped, you can drag and drop pins for each leg and hip into the initialisation block using set pins FR Hip () FL Hip () FR Leg () FL Leg() BR Hip () BL Hip () BR Leg () BL Leg () blocks. This block sets which pins on the Quarky controller board control each servo motor for the front right (FR), front left (FL), back right (BR), and back left (BL) hips and legs. Drag this block and set each PIN as shown.
  7. Add the “home” block right after setting pins.. This will bring the robot to its initial position.
  8. Set the variable Speed to the value 5000 (this controls how fast the robot moves).
  9. Add a wait block after home. This gives the robot time to move to the home position before doing the next action.
  10. Add the do (forward) motion (1) times at () speed block to move forward for 1 motion cycle at the speed set by the variable Speed.
  11. Add the “home” block right after setting pins.. This will bring the robot to its initial position.

Note: You can change the value of the ‘Speed’ variable to test how it affects the robot’s movement, and program the quadruped robot to perform predefined motions such as forward, backward, left, and right using motion blocks.

Output

Activity 3: Quadruped Predefined Motions

  1. Click on the Events palette and choose the ‘when flag clicked’ block. This block starts the program when the green flag is clicked.
  2. Set the servo motion pins using the ‘set pins’ block from the Quarky Quadruped palette. Assign the pins exactly as shown in the image for all 8 legs and hips.
  3. Add the ‘home’ block from the Quarky Quadruped palette. This brings the robot to a stable starting position.
  4. Add a ‘forever’ block from the Control palette. This repeats the movement continuously.
  5. Inside the ‘forever’ block, add the block: do (forward) motion (1) times at (Medium) speed This makes the robot take one forward step at medium speed.
  6. Finally, add a ‘wait (0.2 seconds)’ block from the Control palette. This gives a short pause before the next step is repeated.
  7. Similarly, repeat Steps 5 and 6 for the movement of the Robot in the different directions.

Output

Read More
Learn how to code logic for video input detection .set the bounding box threshold, and detect signals to control Humanoid movements.

Introduction

A sign detector Humanoid robot is a robot that can recognize and interpret certain signs or signals, such as hand gestures or verbal commands, given by a human. The robot uses sensors, cameras, and machine learning algorithms to detect and understand the sign, and then performs a corresponding action based on the signal detected.

These robots are often used in manufacturing, healthcare, and customer service industries to assist with tasks that require human-like interaction and decision-making.

Code

Logic

  1. Initialise the video on stage and set the transparency as 0%
  2. Show the bounding box and set its threshold to 0.8.
  3. Get the input from the camera forever.
  4. If the signal is detected as ‘Go’ then it displays an ‘up arrow’, sounds go straight and the Humanoid will move 2 steps forward at high speed using do () motion () times at () speed block.
  5. If the signal is detected as ‘TurnRight’ then it displays a ‘right arrow’, sounds Turn right and Humanoid will take a right turn at high speed using do () motion () times at () speed block.
  6. If the signal is detected as ‘TurnLeft’ then it displays a ‘Left arrow’, sounds Turn Left and Humanoid will take a left turn at high speed using do () motion () times at () speed block.
  7. If it detects as stop the display will be cleared in the quirky and the humanoid will be at a home() posture.

Output

Read More
All articles loaded
No more articles to load
Table of Contents