In this activity, we will make the computer program that controls the Mecanum Robot. It’s like a remote-control car. You can press different keys on the keyboard to make the Mecanum move forward, backward, left, and right.
The Quarky Mecanum Wheel Robot is a type of robot that uses a special type of wheel to move. The wheel is made of four rollers mounted at 45- degree angles to the wheel‘s hub. Each roller has its own motor and can spin in either direction. This allows the wheel to move in any direction, making it an ideal choice for navigating around obstacles and tight spaces. The Mecanum wheel robot can also turn on the spot, allowing it to make sharp turns without having to reverse direction.
Coding Steps
Follow the steps:
- Open a new project in PictoBlox.
- Connect Quarky to PictoBlox.
- Click on the Add Extension button and add the Quarky Mecanum extension.
- Now we will first initialize the Mecanum robots and the servos before starting the main code.
- The main code will consist of nested if-else conditions that will check specific conditions on which key is pressed and will react accordingly. We will use the arrow keys for basic movements (Forward, Backward, Left Right) and the keys “a” for lateral left movement and “d” for lateral right movement.
Code
sprite=Sprite('Tobi')
import time
quarky = Quarky()
robot = Mecanum(1, 2, 7, 8)
while True:
if sprite.iskeypressed("up arrow"):
robot.runtimedrobot("forward",100,2)
if sprite.iskeypressed("down arrow"):
robot.runtimedrobot("backward",100,1)
if sprite.iskeypressed("right arrow"):
robot.runtimedrobot("circular right",70,1)
if sprite.iskeypressed("left arrow"):
robot.runtimedrobot("circular left",70,1)
if sprite.iskeypressed("a"):
robot.runtimedrobot("lateral left",100,1)
if sprite.iskeypressed("d"):
robot.runtimedrobot("lateral right",100,1)
Output
Forward-Backward Motion:
Lateral Right-Left Motion:
Circular Right-Left Motion: