Controlling the Motion of Quarky Robot with PictoBlox and Python

Description
Learn how to control the motion of Quarky Robot using PictoBlox Block Coding and Python Coding Environment.

Quarky has an inbuild motor driver to drive 2 motors on the back side.

With Innovator Kit and Ultimate Kit, you get the motors assembled. The Robot looks like this:

Robot Motion Logic

Before we go ahead, we first need to understand how to make Quarky move.

  1. If both the wheels of the robot rotate in the forward direction, then it will move forward. That makes sense, right?Robot Forward
  2. Similarly, if both wheels rotate in the backward direction, the robot will move backward.Robot Backward
  3. Making the robot turn left and right is the tricky part. To make Quarky turn left, its right wheel should rotate in the forward direction but its left wheel should rotate in the backward direction.Left Robot
  4. On the other hand, to make Quarky turn right, its left wheel should rotate in the forward direction and the right wheel should rotate in the backward direction.Right Robot

Block Coding

In PictoBlox, you have the following blocks available for the Quarky Robot:

The block moves the Quarky robot in the specified direction. The direction can be “FORWARD”, “BACKWARD”, “LEFT”, and “RIGHT”.
The block moves the Quarky robot in the specified direction for the specified time. The direction can be “FORWARD”, “BACKWARD”, “LEFT”, and “RIGHT”.
The block stops both the motors of the Quarky robot.
The block initializes the following line parameters for the Quarky robot – F. T1 and T2.
The block performs the automatic line following logic with the parameters specified in the set parameter F () T1 () T2 () block.
The block sets the orientation of the robot to align the left and right movement of the robot in horizontal robot position and vertical robot position.
The block sets the specified motor of the Quarky robot to the specified direction (“FORWARD” or “BACKWARD”) and specified speed.
The function stops the specified motor of the Quarky.
All articles loaded
No more articles to load

Block Coding Examples

All articles loaded
No more articles to load

Python Coding

In PictoBlox, you have the following functions available for the Quarky Robot:

The function moves the Quarky robot in the specified direction. The direction can be “FORWARD”, “BACKWARD”, “LEFT”, and “RIGHT”.
Syntax: runrobot(direction = “FORWARD”, speed = 100)
The function moves the Quarky robot in the specified direction for the specified time. The direction can be “FORWARD”, “BACKWARD”, “LEFT”, and “RIGHT”.
Syntax: runtimedrobot(direction = “FORWARD”, speed = 100, time = 1)
The function stops both the motors of the Quarky robot.
Syntax: stoprobot()
The function sets the orientation of the robot to align the left and right movement of the robot in horizontal robot position and vertical robot position.
Syntax: setorientation(orientation = “HORIZONTAL”)
The function sets the specified motor of the Quarky robot to the specified direction (“FORWARD” or “BACKWARD”) and specified speed.
Syntax: runmotor(motor = “L”, direction = “FORWARD”, speed = 100)
The function stops the specified motor of the Quarky.
Syntax: stopmotor(motor = “L”)
All articles loaded
No more articles to load

Stage Mode

Stage mode is one of the two modes you can write your programs in Pictoblox. In this mode, you can write scripts for the sprite and boards to interact with sprites in real time. If you disconnect the board with Pictoblox, you cannot interact with the board anymore. In this mode, you can make games and animations by interacting with Quarky.

You can toggle between the upload mode and stage mode using the button on the top right side of Pictoblox.

Note:  You have to upload the firmware into the device before interacting with it. Please refer to this doc: https://ai.thestempedia.com/docs/updating-quarky-firmaware-with-pictoblox/

In Python Coding Environment, use the following object declaration to use Python functions in Stage Mode:

quarky = Quarky()

Upload Mode

Upload mode is one of the two modes you can write your programs in Pictoblox. This mode allows you to write scripts and upload them to the board so that you can use them even when it is not connected to your computer, for example, you need to upload a script for making moving robots.

In this case, Quarky will run offline according to the program and it can not interact with the stage.

In Python Coding Environment, use the following object declaration to use Python functions in Upload Mode:

from quarky import *

Python Coding Examples

All articles loaded
No more articles to load

Conclusion

In this lesson, we have learned about how to control the motion of Quarky Robot using PictoBlox both in Stage Mode and Upload Mode. We have also learned about the various blocks and functions available for controlling the robot in Python Coding Environment. With the help of these blocks and functions, we can make Quarky move in the specified direction and also make it perform line following and other complex functions.

Table of Contents