Mars Rover Control Program Using PictoBlox

Example Description
Learn how to control the Mars Rover using PictoBlox with motors and servo motors. Make the Mars Rover move forward, backward, turn left, and turn right.

In this activity, we will make the computer program that controls the Mars Rover. It’s like a remote-control car. You can press different keys on the keyboard to make the Mars Rover move forward, backward, turn left and turn right.

Motor and Servo Motor

In our Mars rover, there are a total of 6 motors and 5 servo motors. 

The motors provide rotation to the wheels which helps the rover to attain motion in both forward and backward directions. All the left side motors (3 motors) are connected to the left motor port of Quarky and all the right side motors (3 motors) are connected to the right motor port of Quarky using a 3 port wire. This means that to control the Mars rover we have to control only 2 motors – Left and Right.

Also, there are 2 parameters to control – Direction (Forward or Backward) and Speed. With this control, the Mars rover can do all the desired motions.

The servo motors help in providing rotation to the complete wheel assembly so that the rover can change its wheel alignments and its path. These play a major role in turning cases of the Mars Rover.

We will need to turn the servo motors to the Inside Servo Position to make Mars Rover turn left and right.

Coding Steps

Follow the steps:

  1. Open a new project in PictoBlox.
  2. Connect Quarky to PictoBlox.
  3. Click on the Add Extension button and add the Quarky Mars Rover extension.
  4. For optimizing the Mars Rover motion, we will use the servo motors attached to the Rocker Bogie mechanism. This will work in the following way:
    1. Straight Servo Position the Mars Rover to move in a forward or backward motion.
    2. Inside Servo Position the Mars Rover to turn left and right.To control this position, you have set () to () block in the Mars Rover extension. Using this block, we can achieve this orientation.
  5. We will use the go () at () % speed block from the Robot palette to control the motion of the Mars Rover. And stop motor from the Robot palette to stop the Mars Rover.
  6. Create the following code. The code defines the Robot orientation with Robot Straight and Robot Turn custom blocks. In the loop, the code checks if any of the arrow keys are pressed and performs the corresponding action. If no arrow keys are pressed, the robot stops.
  7. Click on the green flag to run the robot with keys.

Output

Forward-Backward Motions

Normal Right-Left Motions

Conclusion

Our mission is accomplished! With the coding steps above, we were able to successfully control the Mars Rover using the Quarky extension when connected to PictoBlox. We set the motors and servo motors of the Mars Rover and used the set () to () and go () at () % speed blocks. Additionally, we created custom blocks for robot straight and robot turn orientation to get the desired forward and backward movements and right and left turns. This control will help the Mars Rover to achieve its desired tasks!

Table of Contents