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
This function is used to analyze the image received as input from the current backdrop, for the handwritten and printed text.
Syntax: analysebackdrop()
The function sets the current servo motors to the specified angle for the pick and place robot.
Syntax: setarmangle(angle = 90)
The function returns a tuple. The first element is a boolean and the second is the frame of the video.
Syntax: cap.read()
The function performs the selected action for the quadruped. The action runs for the specified times and at the specified speed.
Syntax: action(action = “dance1”, time period = 1000, cycle = 1)
The function reports the state of the IR sensor connected to the selected pin. The function returns 1 when it is HIGH (or 3.3V) or 0 when it is LOW (or 0V).
Syntax: irstatus(pin = “D3”)
The function deletes the feed with the specified name in the Adafruit IO account.
Syntax: adaio.deletefeed(feedname = “feed name”)
The function makes the servo motors connected to the wheels orient towards the left. This orientation is used for making the robot turn left in a circle.
Syntax: setleftturnangle(Angle = 40)
The function performs the selected motion for the humanoid. The motion runs for the specified times and at the specified speed.
Syntax: move(motion = “forward”, time period = 1000, cycle = 1)
The function allows the robot to cease all activity by stopping all its motors.
Syntax: stoprobot()
The function sets the analog state of the specified pin to the specified value between 0 to 255.
Syntax: setanalogoutput(servo port = 1, PWM = 50)
The function is a unary operation that calculates the inverse hyperbolic sine of a given value.
Syntax: math.asinh(x)
This function moves the end-effector of a robotic arm to a desired point in 3-dimensional space. The X, Y, and Z coordinates must be specified, as well as a parameter to set the time of movement. The function takes these inputs and sends commands to the robotic arm to move to the specified location in the desired time period.
Syntax: roboticArm.movetoxyz(XPOS = 0, YPOS = 150, ZPOS = 70, TIME = 1000)
This function sets the motor speed for the robot’s turns.
Syntax: setturingspeed(turn_speed = 50)
This function is used to analyze the image received as input from the camera, for faces.
Syntax: analysecamera()
The function sets its sprite’s X and Y position to that of the mouse-pointer or another sprite — in other words, it moves the sprite to a random position, the mouse-pointer, or another sprite.
Syntax: goto(moveto = “_random_”)
The function changes the Stage’s backdrop to the specified one.
Syntax: switchbackdrop(backdrop_name = “backdrop1”)
The function changes the specified sound effect to the value. The input is for selecting how much the sound will be changed. A positive number will make the sound effect have more effect, while a negative number will make it smaller.
Syntax: setsoundeffect(effect_name = “PITCH”, effect_value = 100)
The function returns the most recent text imputed with the input() function. When nothing has been inputted yet, the value will hold nothing.
Syntax: answer()
The function checks if the specified key is pressed. If the key is being pressed, the block returns “true”; if it is not, it returns “false”.
Syntax: iskeypressed(key = “space”)
The function sets the pen’s color to the given color – (R, G, B).
Syntax: setcolor(color = [0, 0 , 0])
The function sets the RGB LED display matrix to the emotion specified: “happy”, “angry”, “crying”, “super angry “, “surprise”, “basic”, “love”, “nerd”, “reject”, “wave”, “thinking”, “giggle”, and “disco”.
Syntax: showemotion(pattern = “happy”)
The function returns the state of the specified touch sensor of Quarky. If the touchpad is touched it will return True, else False.
Syntax: ispadtouched(touch_pin = 1)
The function performs the automatic line following logic with the parameters specified in the initializelinefollower() function.
Syntax: dolinefollowing()
This function is used to analyze the image received as input from the current costume, for the feature.
Syntax: analysecostume()
This function is used to analyze the image received as input from the current costume of the sprite, for the handwritten and printed text.
Syntax: analysecostume()
The function moves the servo motors of the pick and place robot to the pick angle specified by the user.
Syntax: pick()
The function flips a 2D array around vertical, horizontal, or both axes.
Syntax: cv2.flip(input_array, flip_code = 1)
Resizing an image means changing its dimensions of it, be it width alone, height alone, or changing both of them. Also, the aspect ratio of the original image could be preserved in the resized image. To resize an image, OpenCV provides cv2.resize() function.
Syntax: cv2.resize(image_array, dsize = (224,224))
The function sets the servo motors of the quadruped to the specified angles at the specified speed.
Syntax: moveall(servo angles = [90,90,90,90,90,90,90,90], time = 1000)
The function reports the temperature or humidity from the DHT sensor connected to the selected pin.
Syntax: dhtmeasure(parameter = “temperature”, pin = “D3”)
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
This function is used to analyze the image received as input from the current backdrop, for the handwritten and printed text.
Syntax: analysebackdrop()
The function sets the current servo motors to the specified angle for the pick and place robot.
Syntax: setarmangle(angle = 90)
The function returns a tuple. The first element is a boolean and the second is the frame of the video.
Syntax: cap.read()
The function performs the selected action for the quadruped. The action runs for the specified times and at the specified speed.
Syntax: action(action = “dance1”, time period = 1000, cycle = 1)
The function reports the state of the IR sensor connected to the selected pin. The function returns 1 when it is HIGH (or 3.3V) or 0 when it is LOW (or 0V).
Syntax: irstatus(pin = “D3”)
The function deletes the feed with the specified name in the Adafruit IO account.
Syntax: adaio.deletefeed(feedname = “feed name”)
The function makes the servo motors connected to the wheels orient towards the left. This orientation is used for making the robot turn left in a circle.
Syntax: setleftturnangle(Angle = 40)
The function performs the selected motion for the humanoid. The motion runs for the specified times and at the specified speed.
Syntax: move(motion = “forward”, time period = 1000, cycle = 1)
The function allows the robot to cease all activity by stopping all its motors.
Syntax: stoprobot()
The function sets the analog state of the specified pin to the specified value between 0 to 255.
Syntax: setanalogoutput(servo port = 1, PWM = 50)
The function is a unary operation that calculates the inverse hyperbolic sine of a given value.
Syntax: math.asinh(x)
This function moves the end-effector of a robotic arm to a desired point in 3-dimensional space. The X, Y, and Z coordinates must be specified, as well as a parameter to set the time of movement. The function takes these inputs and sends commands to the robotic arm to move to the specified location in the desired time period.
Syntax: roboticArm.movetoxyz(XPOS = 0, YPOS = 150, ZPOS = 70, TIME = 1000)
This function sets the motor speed for the robot’s turns.
Syntax: setturingspeed(turn_speed = 50)
This function is used to analyze the image received as input from the camera, for faces.
Syntax: analysecamera()
The function sets its sprite’s X and Y position to that of the mouse-pointer or another sprite — in other words, it moves the sprite to a random position, the mouse-pointer, or another sprite.
Syntax: goto(moveto = “_random_”)
The function changes the Stage’s backdrop to the specified one.
Syntax: switchbackdrop(backdrop_name = “backdrop1”)
The function changes the specified sound effect to the value. The input is for selecting how much the sound will be changed. A positive number will make the sound effect have more effect, while a negative number will make it smaller.
Syntax: setsoundeffect(effect_name = “PITCH”, effect_value = 100)
The function returns the most recent text imputed with the input() function. When nothing has been inputted yet, the value will hold nothing.
Syntax: answer()
The function checks if the specified key is pressed. If the key is being pressed, the block returns “true”; if it is not, it returns “false”.
Syntax: iskeypressed(key = “space”)
The function sets the pen’s color to the given color – (R, G, B).
Syntax: setcolor(color = [0, 0 , 0])
The function sets the RGB LED display matrix to the emotion specified: “happy”, “angry”, “crying”, “super angry “, “surprise”, “basic”, “love”, “nerd”, “reject”, “wave”, “thinking”, “giggle”, and “disco”.
Syntax: showemotion(pattern = “happy”)
The function returns the state of the specified touch sensor of Quarky. If the touchpad is touched it will return True, else False.
Syntax: ispadtouched(touch_pin = 1)
The function performs the automatic line following logic with the parameters specified in the initializelinefollower() function.
Syntax: dolinefollowing()
This function is used to analyze the image received as input from the current costume, for the feature.
Syntax: analysecostume()
This function is used to analyze the image received as input from the current costume of the sprite, for the handwritten and printed text.
Syntax: analysecostume()
The function moves the servo motors of the pick and place robot to the pick angle specified by the user.
Syntax: pick()
The function flips a 2D array around vertical, horizontal, or both axes.
Syntax: cv2.flip(input_array, flip_code = 1)
Resizing an image means changing its dimensions of it, be it width alone, height alone, or changing both of them. Also, the aspect ratio of the original image could be preserved in the resized image. To resize an image, OpenCV provides cv2.resize() function.
Syntax: cv2.resize(image_array, dsize = (224,224))
The function sets the servo motors of the quadruped to the specified angles at the specified speed.
Syntax: moveall(servo angles = [90,90,90,90,90,90,90,90], time = 1000)
The function reports the temperature or humidity from the DHT sensor connected to the selected pin.
Syntax: dhtmeasure(parameter = “temperature”, pin = “D3”)
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