Deprecated: Required parameter $query follows optional parameter $post in /var/www/html/wp-content/plugins/elementor-extras/modules/breadcrumbs/widgets/breadcrumbs.php on line 1215
Program Quarky Mecanum Robot with PictoBlox and Python
[Mecanum]

Programming the Quarky Mecanum with Python in PictoBlox

Description
In this lesson, learn how to program the Quarky Mecanum robot with PictoBlox and Python in both Stage and Upload modes. Understand the functions provided in the Quarky Mecanum library, and see how to control the robot’s motors, pick-and-place robot, and gripper robot.

PictoBlox also provides the ability to program the Quarky Mecanum using Python in Desktop / Laptop versions. Let’s see how you can do it in this lesson.

PictoBlox

With PictoBlox, you can program the Quarky Mecanum!

If you haven’t installed PictoBlox, please follow the instructions:


Warning: Undefined array key "pp_wrapper_link" in /var/www/html/wp-content/plugins/powerpack-elements/extensions/wrapper-link.php on line 194

Warning: Undefined array key "pp_wrapper_link_enable" in /var/www/html/wp-content/plugins/powerpack-elements/extensions/wrapper-link.php on line 196

Warning: Undefined array key "pp_custom_cursor_icon" in /var/www/html/wp-content/plugins/powerpack-elements/extensions/custom-cursor.php on line 350

Warning: Undefined array key "pp_custom_cursor_text" in /var/www/html/wp-content/plugins/powerpack-elements/extensions/custom-cursor.php on line 351

Warning: Undefined array key "pp_custom_cursor_target" in /var/www/html/wp-content/plugins/powerpack-elements/extensions/custom-cursor.php on line 352

Warning: Undefined array key "pp_custom_cursor_css_selector" in /var/www/html/wp-content/plugins/powerpack-elements/extensions/custom-cursor.php on line 353

Warning: Undefined array key "pp_custom_cursor_enable" in /var/www/html/wp-content/plugins/powerpack-elements/extensions/custom-cursor.php on line 355
If the sprite is showing, it will hide the sprite. If the sprite is already hidden, nothing happens.
Syntax: hide()
The function set the steering orientation to the left for the Steering Robot.
Syntax: left()
The block resets the timer running for the oscillator to 0.
Syntax: resetoscillationtimer()
The function reports the moisture reading from the sensor. The value varies from 0 to 100%.
Syntax: readmoisture()
The function sends the data to the ThingSpeak channel. The data is added to field 1 of the channel.
Syntax: ts.senddatatocloud(data = 100)
The function executes the oscillator according to stored parameters for the servo motor and the current time.
Syntax: executeoscillator()
The function sets the port of the servo motor for the gripper robot in the code, making it easier to control.
Syntax: initialisegripper(servo port = 4)
This function takes two parameters – a value for the angle at which the gripper should open and a value for the angle at which the gripper should close – and sets the angles for the gripper on a robotic arm.
Syntax: roboticArm.setgripperangle(OPEN = 0, CLOSE = 50)
The function returns the x position of the specified landmark point of the specified face with respect to the stage.
Syntax: landmarksx(face = 1, landmark = 1)
The function moves its sprite’s Y position by the specified amount.
Syntax: changey(delta_y = 10)
The function will place a sprite in front of all other sprites. It does this by changing the sprite’s layer value.
Syntax: gotolayer(postition = “front”, layer_number = 1)
The function set the steering orientation to the right for the Steering Robot.
Syntax: right()
The function reports the time passed from the reset for the oscillator.
Syntax: oscillationtimer()
The function initializes the RFID sensor. The function is important to run at the start to use other functions of the RFID sensors.
Syntax: initialiserfid()
The function sends multiple data to the ThingSpeak channel. The data is mapped to the 8 fields of the ThingSpeak channel.
Syntax: ts.sendmultipledatatocloud(field_data_1 = 100, field_data_2 = 100, field_data_3 = 100, field_data_4 = 100, field_data_5 = 100, field_data_6 = 100, field_data_7 = 100, field_data_8 = 100)
The function executes the oscillator according to stored parameters for the servo motor and the current angle specified in the functions.
Syntax: executesscillatorat(angle = 90)
The function executes the oscillator for the specified cycles.
Syntax: oscillateforcycles(cycles = 1)
The function sets the angle of a robot’s gripper servo motor to a specified value.
Syntax: setgripperangle(angle = 90)
This function used to control the opening and closing of the robotic arm gripper.
Syntax: roboticArm.gripperaction(STATE = “open”)
The function returns the y position of the specified landmark point of the specified face with respect to the stage.
Syntax: landmarksy(face = 1, landmark = 1)
The function sets its sprite’s Y (up and down) position to the specified amount.
Syntax: sety(y = 27)
The function changes its sprite’s layer value by the specified amount. This function is rather unusual compared to other functions. It moves the layer value back, and not forward. To move it forward instead, a negative number can be used.
Syntax: changelayer(postition = “forward”, layer_number = 1)
The function set the steering orientation to straight for the Steering Robot.
Syntax: straight()
The function activates the RFID sensor to read any nearby RFID tags for the specified time. Once identified, the value of the reading is stored in the local system which can be used from the other functions. The function also reports whether the operation is completed or not. If any RFID tag is scanned the block returns 1, else it returns 0.
Syntax: readrfid(duration = 5)
The function gets the data from the ThingSpeak channel and stores the 8 field values in PictoBlox or Quarky.
Syntax: ts.getdatafromthingspeak()
The function resets the timer running for the oscillator to 0.
Syntax: resetoscillationtimer()
This function sets the angle of the Gripper Robot’s gripper servo motor to a particular value when it is in the closed position.
Syntax: setcloseangle(angle = 40)
This function takes the servo motor as the input parameter, and it returns the corresponding angle of the servo as an output.
Syntax: roboticArm.getcurrentservoangle(SERVO = “link1”)
The function allows the user to add a particular face into the database from the camera feed. The user can specify the name of the face with the argument as well. This addition of the face in the database is also stored inside the PictoBlox file while saving.
Syntax: addclassfromcamera(label_number = 1, label_name = “Jarvis”)
The function checks to see if its sprite is touching the edge of the screen with the move steps block — and if it is, the sprite will point in a direction that mirrors the direction from which it is coming. It uses a line perpendicular to the edge to determine the reflection angle.
Syntax: bounceonedge()
All articles loaded
No more articles to load

Connecting Quarky with PictoBlox

Let’s begin by first connecting Quarky to PictoBlox. Follow the steps below for connecting Quarky to PictoBlox:

    1. First, connect Quarky to your laptop using a USB cable.
    2. Next, open PictoBlox on your desktop.
    3. After that, select Python Coding as your coding environment.
    4. Then, click the Board button in the toolbar and select Board as Quarky.
    5. 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.
      COM Port
    6. Click on the Upload Firmware button. This will upload the latest firmware in Quarky.
      Note: If your device already has the latest firmware, then PictoBlox will show the message – Firmware is already updated. For learning more you can refer to this tutorial: https://ai.thestempedia.com/docs/quarky/quarky-toubleshooting/updating-quarky-firmaware-with-pictoblox/
    7. Once the firmware is uploaded, Quarky starts the Getting Started program. This runs only for the first time. Run through it.

And voila! Quarky is now connected to PictoBlox.

Quarky Mecanum Python Library for 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.

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

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

meca = Mecanum(1, 2, 7, 8)

Quarky Mecanum Python Library for Upload Mode

Upload 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 cannot interact with the stage.

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

from quarky import *
from expansion_addon import Mecanum
meca = Mecanum(1, 2, 7, 8)

Python Functions

The following functions are available for use in the Quarky Mecanum library:


Warning: Undefined array key "pp_wrapper_link" in /var/www/html/wp-content/plugins/powerpack-elements/extensions/wrapper-link.php on line 194

Warning: Undefined array key "pp_wrapper_link_enable" in /var/www/html/wp-content/plugins/powerpack-elements/extensions/wrapper-link.php on line 196

Warning: Undefined array key "pp_custom_cursor_icon" in /var/www/html/wp-content/plugins/powerpack-elements/extensions/custom-cursor.php on line 350

Warning: Undefined array key "pp_custom_cursor_text" in /var/www/html/wp-content/plugins/powerpack-elements/extensions/custom-cursor.php on line 351

Warning: Undefined array key "pp_custom_cursor_target" in /var/www/html/wp-content/plugins/powerpack-elements/extensions/custom-cursor.php on line 352

Warning: Undefined array key "pp_custom_cursor_css_selector" in /var/www/html/wp-content/plugins/powerpack-elements/extensions/custom-cursor.php on line 353

Warning: Undefined array key "pp_custom_cursor_enable" in /var/www/html/wp-content/plugins/powerpack-elements/extensions/custom-cursor.php on line 355
If the sprite is showing, it will hide the sprite. If the sprite is already hidden, nothing happens.
Syntax: hide()
The function set the steering orientation to the left for the Steering Robot.
Syntax: left()
The block resets the timer running for the oscillator to 0.
Syntax: resetoscillationtimer()
The function reports the moisture reading from the sensor. The value varies from 0 to 100%.
Syntax: readmoisture()
The function sends the data to the ThingSpeak channel. The data is added to field 1 of the channel.
Syntax: ts.senddatatocloud(data = 100)
The function executes the oscillator according to stored parameters for the servo motor and the current time.
Syntax: executeoscillator()
The function sets the port of the servo motor for the gripper robot in the code, making it easier to control.
Syntax: initialisegripper(servo port = 4)
This function takes two parameters – a value for the angle at which the gripper should open and a value for the angle at which the gripper should close – and sets the angles for the gripper on a robotic arm.
Syntax: roboticArm.setgripperangle(OPEN = 0, CLOSE = 50)
The function returns the x position of the specified landmark point of the specified face with respect to the stage.
Syntax: landmarksx(face = 1, landmark = 1)
The function moves its sprite’s Y position by the specified amount.
Syntax: changey(delta_y = 10)
The function will place a sprite in front of all other sprites. It does this by changing the sprite’s layer value.
Syntax: gotolayer(postition = “front”, layer_number = 1)
The function set the steering orientation to the right for the Steering Robot.
Syntax: right()
The function reports the time passed from the reset for the oscillator.
Syntax: oscillationtimer()
The function initializes the RFID sensor. The function is important to run at the start to use other functions of the RFID sensors.
Syntax: initialiserfid()
The function sends multiple data to the ThingSpeak channel. The data is mapped to the 8 fields of the ThingSpeak channel.
Syntax: ts.sendmultipledatatocloud(field_data_1 = 100, field_data_2 = 100, field_data_3 = 100, field_data_4 = 100, field_data_5 = 100, field_data_6 = 100, field_data_7 = 100, field_data_8 = 100)
The function executes the oscillator according to stored parameters for the servo motor and the current angle specified in the functions.
Syntax: executesscillatorat(angle = 90)
The function executes the oscillator for the specified cycles.
Syntax: oscillateforcycles(cycles = 1)
The function sets the angle of a robot’s gripper servo motor to a specified value.
Syntax: setgripperangle(angle = 90)
This function used to control the opening and closing of the robotic arm gripper.
Syntax: roboticArm.gripperaction(STATE = “open”)
The function returns the y position of the specified landmark point of the specified face with respect to the stage.
Syntax: landmarksy(face = 1, landmark = 1)
The function sets its sprite’s Y (up and down) position to the specified amount.
Syntax: sety(y = 27)
The function changes its sprite’s layer value by the specified amount. This function is rather unusual compared to other functions. It moves the layer value back, and not forward. To move it forward instead, a negative number can be used.
Syntax: changelayer(postition = “forward”, layer_number = 1)
The function set the steering orientation to straight for the Steering Robot.
Syntax: straight()
The function activates the RFID sensor to read any nearby RFID tags for the specified time. Once identified, the value of the reading is stored in the local system which can be used from the other functions. The function also reports whether the operation is completed or not. If any RFID tag is scanned the block returns 1, else it returns 0.
Syntax: readrfid(duration = 5)
The function gets the data from the ThingSpeak channel and stores the 8 field values in PictoBlox or Quarky.
Syntax: ts.getdatafromthingspeak()
The function resets the timer running for the oscillator to 0.
Syntax: resetoscillationtimer()
This function sets the angle of the Gripper Robot’s gripper servo motor to a particular value when it is in the closed position.
Syntax: setcloseangle(angle = 40)
This function takes the servo motor as the input parameter, and it returns the corresponding angle of the servo as an output.
Syntax: roboticArm.getcurrentservoangle(SERVO = “link1”)
The function allows the user to add a particular face into the database from the camera feed. The user can specify the name of the face with the argument as well. This addition of the face in the database is also stored inside the PictoBlox file while saving.
Syntax: addclassfromcamera(label_number = 1, label_name = “Jarvis”)
The function checks to see if its sprite is touching the edge of the screen with the move steps block — and if it is, the sprite will point in a direction that mirrors the direction from which it is coming. It uses a line perpendicular to the edge to determine the reflection angle.
Syntax: bounceonedge()
All articles loaded
No more articles to load

Conclusion

In conclusion, PictoBlox is a powerful coding environment that allows you to program the Quarky Mecanum Robot with Python in both Stage and Upload modes. The Quarky Mecanum library provides several functions that can be used to control the robots motors, pickandplace robot, and gripper robot. With the help of PictoBlox, you can easily program and control the Quarky Mecanum robot!

Table of Contents