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
The function is used to draw a text string on any image.
Syntax: cv2.putText(image, text, org, font, fontScale = 2, color = (255, 0, 0), thickness, lineType = cv2.LINE_AA)
The block sets the oscillator parameters for the selected servo motor.
Syntax: setoscillationparameters(servo motor number = 1, amplitude = 30, offset = 90, time period = 1000, phase difference = 0)
The function sets the threshold for the LDR (Light) sensor connected to the selected pin. Threshold helps users decide whether the sensor is active or not. If the sensor value is greater than the threshold value, the sensor is active, or else it is inactive.
Syntax: setldrthreshold(threshold_value = 1500)
The function returns the red, green, or blue value of the color saved from the last data request.
Syntax: adaio.getRGB(color = “red”)
The function sets the servo motors of the humanoid hip, foot and hand to the specified angles at the specified speed.
Syntax: moveall(time = 1000, servo angles = [90,90,90,90,90,90])
The function sets the angles of the pick action of the pick and place robot to a specified value.
Syntax: setpickangle(angle = 40)
The function is used to return the ceiling value of a number, which means it is used to round a number up to the nearest integer that is greater than the number itself.
Syntax: math.ceil(x)
This function creates a anti-clockwise circle trajectory in the Y plane for a robotic arm, given the center position in the X and Z axes, and the radius of the circle.
Syntax: roboticArm.moveincircleanticlockcise(XPOS = 0, ZPOS = 80, RADIUS = 50, YPOS = 180, TIME = 4000)
This function’s parameters match the Quarky board’s regular line following settings, defining motor speeds: F for forward on white, and T1 and T2 for gentle turning along the black line.
Syntax: setlinefollowerparameter(F = 35, T1 = 40, T2 = 10)
This function is used to check whether the expression of the face number specified in the argument is equal to the specified expression. Like is the face 1 happy?
Syntax: isexpression(face = 1, expression = “happy”)
The function changes the specified effect on its sprite by the specified amount. There are seven different effects to choose from: colour, fisheye, whirl, pixelate, mosaic, brightness, and ghost.
Syntax: changeeffect(effect_name = “COLOR”, effect_value = 25)
The function holds a sprite’s or the Stage’s volume. This block can be displayed as a Stage monitor.
Syntax: setvolume()
The function reports how loud the noise that a microphone receives, on a scale of 0 to 100.
Syntax: loudness()
The function sets the RGB LED display matrix to display the specified character.
Syntax: showtext(character = “A”, color = [0, 0 , 0])
The function returns the analog reading of the sensor connected to the specified analog pin of the Quarky. The value varies between 0 to 4095.
Syntax: readanalogsensor(analog_pin = “A1”)
The function sets the servo motor connected to the specified servo pin to the specified angle.
Syntax: moveservo(servo_pin = “Servo 1”, angle = 90)
The function reports the landmark identified in the image on analysis.
Syntax: landmark()
The function sets the current Quarky Gripper Robot’s gripper servo motor angle to the specified value.
Syntax: setgripperangle(angle = 90)
The function resets the oscillator parameter for all the servo motors.
Syntax: resetoscillationparameters()
The function reports the state of the Gas sensor connected to the selected pin. The block returns 1 when the analog reading of the sensor is greater than the threshold value set by the user. Else it reports 0.
Syntax: gassensorstatus(pin = “A1”)
The function sets the selected servo motor angle to the specified angle in the specified time. This creates a smooth motion for the servo motor from the current angle to the specified angle.
Syntax: movelimb(servo name = “RHip”, angle = 90, time = 1000)
The function sets the angles of the place action of the pick and place robot to a specified value.
Syntax: setplaceangle(angle = 90)
This function is used to control an end–effector of the robotic arm to move in an arc.
Syntax: roboticArm.moveinarc(XPOS = 0, ZPOS = 80, RADIUS = 50, START = 90, END = 270, YPOS = 180, TIME = 4000)
This function enables the robot to follow a line continuously until it detects a checkpoint (both IR sensors on black); it stops only at the checkpoint or with a reset.
Syntax: dolinefollowinguntilcheckpointdetect(next_checkpoint = 1)
This function returns the x position of the face detected. You can specify the face for which the value is needed. The position is mapped with the stage coordinates.
Syntax: x(face = 1)
The function points its sprite in the specified direction; this rotates the sprite.
Syntax: setdirection(angle = 15)
The function sets the specified effect on its sprite to the specified amount. There are seven different effects to choose from: color, fisheye, whirl, pixelate, mosaic, brightness, and ghost.
Syntax: seteffect(effect_name = “COLOR”, effect_value = 25)
The function reports the time lapsed since the PictoBlox is launched and increases gradually; every second it will have increased by 1.
Syntax: timer()
The function runs the specified text message on the RGB LED of Quarky. You can also set the speed and the color of the text.
Syntax: showscrollingtext(message = “Hi I am Quarky”, speed = 1, color = [0, 0 , 0])
The function reports the image description identified in the image on analysis – a Human-readable sentence that describes the contents of the image.
Syntax: imagedescription()
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
The function is used to draw a text string on any image.
Syntax: cv2.putText(image, text, org, font, fontScale = 2, color = (255, 0, 0), thickness, lineType = cv2.LINE_AA)
The block sets the oscillator parameters for the selected servo motor.
Syntax: setoscillationparameters(servo motor number = 1, amplitude = 30, offset = 90, time period = 1000, phase difference = 0)
The function sets the threshold for the LDR (Light) sensor connected to the selected pin. Threshold helps users decide whether the sensor is active or not. If the sensor value is greater than the threshold value, the sensor is active, or else it is inactive.
Syntax: setldrthreshold(threshold_value = 1500)
The function returns the red, green, or blue value of the color saved from the last data request.
Syntax: adaio.getRGB(color = “red”)
The function sets the servo motors of the humanoid hip, foot and hand to the specified angles at the specified speed.
Syntax: moveall(time = 1000, servo angles = [90,90,90,90,90,90])
The function sets the angles of the pick action of the pick and place robot to a specified value.
Syntax: setpickangle(angle = 40)
The function is used to return the ceiling value of a number, which means it is used to round a number up to the nearest integer that is greater than the number itself.
Syntax: math.ceil(x)
This function creates a anti-clockwise circle trajectory in the Y plane for a robotic arm, given the center position in the X and Z axes, and the radius of the circle.
Syntax: roboticArm.moveincircleanticlockcise(XPOS = 0, ZPOS = 80, RADIUS = 50, YPOS = 180, TIME = 4000)
This function’s parameters match the Quarky board’s regular line following settings, defining motor speeds: F for forward on white, and T1 and T2 for gentle turning along the black line.
Syntax: setlinefollowerparameter(F = 35, T1 = 40, T2 = 10)
This function is used to check whether the expression of the face number specified in the argument is equal to the specified expression. Like is the face 1 happy?
Syntax: isexpression(face = 1, expression = “happy”)
The function changes the specified effect on its sprite by the specified amount. There are seven different effects to choose from: colour, fisheye, whirl, pixelate, mosaic, brightness, and ghost.
Syntax: changeeffect(effect_name = “COLOR”, effect_value = 25)
The function holds a sprite’s or the Stage’s volume. This block can be displayed as a Stage monitor.
Syntax: setvolume()
The function reports how loud the noise that a microphone receives, on a scale of 0 to 100.
Syntax: loudness()
The function sets the RGB LED display matrix to display the specified character.
Syntax: showtext(character = “A”, color = [0, 0 , 0])
The function returns the analog reading of the sensor connected to the specified analog pin of the Quarky. The value varies between 0 to 4095.
Syntax: readanalogsensor(analog_pin = “A1”)
The function sets the servo motor connected to the specified servo pin to the specified angle.
Syntax: moveservo(servo_pin = “Servo 1”, angle = 90)
The function reports the landmark identified in the image on analysis.
Syntax: landmark()
The function sets the current Quarky Gripper Robot’s gripper servo motor angle to the specified value.
Syntax: setgripperangle(angle = 90)
The function resets the oscillator parameter for all the servo motors.
Syntax: resetoscillationparameters()
The function reports the state of the Gas sensor connected to the selected pin. The block returns 1 when the analog reading of the sensor is greater than the threshold value set by the user. Else it reports 0.
Syntax: gassensorstatus(pin = “A1”)
The function sets the selected servo motor angle to the specified angle in the specified time. This creates a smooth motion for the servo motor from the current angle to the specified angle.
Syntax: movelimb(servo name = “RHip”, angle = 90, time = 1000)
The function sets the angles of the place action of the pick and place robot to a specified value.
Syntax: setplaceangle(angle = 90)
This function is used to control an end–effector of the robotic arm to move in an arc.
Syntax: roboticArm.moveinarc(XPOS = 0, ZPOS = 80, RADIUS = 50, START = 90, END = 270, YPOS = 180, TIME = 4000)
This function enables the robot to follow a line continuously until it detects a checkpoint (both IR sensors on black); it stops only at the checkpoint or with a reset.
Syntax: dolinefollowinguntilcheckpointdetect(next_checkpoint = 1)
This function returns the x position of the face detected. You can specify the face for which the value is needed. The position is mapped with the stage coordinates.
Syntax: x(face = 1)
The function points its sprite in the specified direction; this rotates the sprite.
Syntax: setdirection(angle = 15)
The function sets the specified effect on its sprite to the specified amount. There are seven different effects to choose from: color, fisheye, whirl, pixelate, mosaic, brightness, and ghost.
Syntax: seteffect(effect_name = “COLOR”, effect_value = 25)
The function reports the time lapsed since the PictoBlox is launched and increases gradually; every second it will have increased by 1.
Syntax: timer()
The function runs the specified text message on the RGB LED of Quarky. You can also set the speed and the color of the text.
Syntax: showscrollingtext(message = “Hi I am Quarky”, speed = 1, color = [0, 0 , 0])
The function reports the image description identified in the image on analysis – a Human-readable sentence that describes the contents of the image.
Syntax: imagedescription()
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