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 sends the specified data to the selected feed as a string.
Syntax: adaio.createdata(feedname = “feed name”, data = “0”)
The function makes the servo motors connected to the wheels orient towards the right. This orientation is used for making the robot turn right in a circle.
Syntax: setrightturnangle(Angle = 40)
The function sets the motors of a device to a specified speed. It uses a scale of -100 to 100, where -100 is the motor running in reverse at full speed, 100 is the motor running in the forward direction at full speed, and 0 is when the wheel is stopped.
Syntax: runallmotors(FL speed = 50, BL speed = 50, BR speed = 50, FR speed = 50)
The function sets the specified motor of the Quarky Expansion board to the specified direction (“FORWARD” or “BACKWARD”) and specified speed.
Syntax: runmotor(motor port = 1, direction = “FORWARD”, speed = 100)
The function is used to compute the arc tangent of the given angle in radians.
Syntax: math.atan(x)
This function takes four input parameters, the X, Y, and Z coordinates of the desired end position, and the amount of time to reach that position. It then divides the motion into smaller line segments, allowing the robotic arm to accurately and efficiently reach the specified location. The function then moves the robot arm from its current position to the specified end position within the given time frame.
Syntax: roboticArm.movexyzinline(XPOS = 0, YPOS = 150, ZPOS = 70, TIME = 1000)
Select the left and right IR sensors for line following, choosing between onboard Quarky IR sensors or external sensors connected to analog pins.
Syntax: setlinefollowerparameter(set_sensor = ‘left’, set_pin = ‘A1’)
This function is used to analyze the image received as input from the stage, for faces.
Syntax: analysestage()
The function sets its sprite’s X and Y position to the specified value. This block has no animation in its movement — it is the simplest way to move a sprite around the screen without displaying any animation (i.e. gliding).
Syntax: gotoxy(x = 100, y = 100)
The function changes the backdrop to the next in the list of backdrops, but if the current backdrop is the last in the list, the block will loop to the first.
Syntax: nextbackdrop()
The function clears any sound effects currently in place. However, it does not stop the sound currently being played.
Syntax: clearsoundeffects()
The function reports the mouse pointer’s current X position on the stage.
Syntax: mousex()
The function changes the specified value by the number input.
Syntax: changecolor(parameter = “color”, value = 10)
The function sets the RGB LED display matrix to display the animation specified: “happy”, “nerdy”, “thinking”, “angry”, “contempt”, “blink”, “fear”, “surprise”, “wink”, “wave”, and “crying”.
Syntax: showanimation(animation = “happy”)
The function initializes the ultrasonic sensor with specified echo and trig pins. 
Syntax: setultrasonicpins(sensor_number = 1, trig_pin = “D1”, echo_pin = “D2”)
The function sets the orientation of the robot to align the left and right movement of the robot in horizontal robot position and vertical robot position.
Syntax: setorientation(orientation = “HORIZONTAL”)
This function is used to analyze the image received as input from the specified URL of the image, for the feature.
Syntax: analyseURL(url = “https://ai.thestempedia.com/wp-content/uploads/2022/02/Robert-and-Chris.jpg”)
This function is used to analyze the image received as input from the image URL specified, for the handwritten and printed text.
Syntax: analyseURL(url = “https://ai.thestempedia.com/wp-content/uploads/2022/07/Hello-World.png”)
The function moves the servo motors of the pick and place robot to the place angle specified by the user.
Syntax: place()
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 motor number = 1, angle = 90, time = 1000)
The function reports the state of the LDR (Light) 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: ldrstatus(pin = “A1”)
The function returns the last data value of the specified feed as a string.
Syntax: adaio.getdata(feedname = “feed name”)
The function sets the servo motors of the Mars Rover to the specified angles.
Syntax: setwheelsangle(Front Left = 90, Front Right = 90, Back Left = 90, Back Right = 90)
The function sets the servo motors of the humanoid hip and leg to the specified angles at the specified speed.
Syntax: moveleg(time = 1000, servo angles = [90,90,90,90])
The function controls the speed of a selected motor, allowing it to run at a specified speed.
Syntax: runmotor(motor = “fl”, speed = 100)
The function stops the specified motor of the Quarky Expansion Board.
Syntax: stopmotor(motor port = 1)
The function takes two arguments – y-coordinate and x-coordinate – and produces an angle in radians from -(pi) to +(pi).
Syntax: math.atan2(y, x)
This function is used to move a robotic arm from its current position to a specific X, Y, and Z coordinate position over a specified period of time. It takes in multiple parameters, such as the current position of the arm, the coordinates to move to, and the interval in which to move. The function then determines how many steps must be taken in each axis to reach the destination point, and moves in the X axis first, then the Y axis, and lastly the Z axis before returning the successful result.
Syntax: roboticArm.movexyzonebyone(XPOS = 0, YPOS = 150, ZPOS = 70, TIME = 1000)
This function sets the IR threshold for either the default sensor or one connected to an analog pin.
Syntax: setirthreshold(set_sensor = ‘left’, set_value = 750)
This function displays the total number of faces detected in the camera feed or the stage.
Syntax: count()
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 sends the specified data to the selected feed as a string.
Syntax: adaio.createdata(feedname = “feed name”, data = “0”)
The function makes the servo motors connected to the wheels orient towards the right. This orientation is used for making the robot turn right in a circle.
Syntax: setrightturnangle(Angle = 40)
The function sets the motors of a device to a specified speed. It uses a scale of -100 to 100, where -100 is the motor running in reverse at full speed, 100 is the motor running in the forward direction at full speed, and 0 is when the wheel is stopped.
Syntax: runallmotors(FL speed = 50, BL speed = 50, BR speed = 50, FR speed = 50)
The function sets the specified motor of the Quarky Expansion board to the specified direction (“FORWARD” or “BACKWARD”) and specified speed.
Syntax: runmotor(motor port = 1, direction = “FORWARD”, speed = 100)
The function is used to compute the arc tangent of the given angle in radians.
Syntax: math.atan(x)
This function takes four input parameters, the X, Y, and Z coordinates of the desired end position, and the amount of time to reach that position. It then divides the motion into smaller line segments, allowing the robotic arm to accurately and efficiently reach the specified location. The function then moves the robot arm from its current position to the specified end position within the given time frame.
Syntax: roboticArm.movexyzinline(XPOS = 0, YPOS = 150, ZPOS = 70, TIME = 1000)
Select the left and right IR sensors for line following, choosing between onboard Quarky IR sensors or external sensors connected to analog pins.
Syntax: setlinefollowerparameter(set_sensor = ‘left’, set_pin = ‘A1’)
This function is used to analyze the image received as input from the stage, for faces.
Syntax: analysestage()
The function sets its sprite’s X and Y position to the specified value. This block has no animation in its movement — it is the simplest way to move a sprite around the screen without displaying any animation (i.e. gliding).
Syntax: gotoxy(x = 100, y = 100)
The function changes the backdrop to the next in the list of backdrops, but if the current backdrop is the last in the list, the block will loop to the first.
Syntax: nextbackdrop()
The function clears any sound effects currently in place. However, it does not stop the sound currently being played.
Syntax: clearsoundeffects()
The function reports the mouse pointer’s current X position on the stage.
Syntax: mousex()
The function changes the specified value by the number input.
Syntax: changecolor(parameter = “color”, value = 10)
The function sets the RGB LED display matrix to display the animation specified: “happy”, “nerdy”, “thinking”, “angry”, “contempt”, “blink”, “fear”, “surprise”, “wink”, “wave”, and “crying”.
Syntax: showanimation(animation = “happy”)
The function initializes the ultrasonic sensor with specified echo and trig pins. 
Syntax: setultrasonicpins(sensor_number = 1, trig_pin = “D1”, echo_pin = “D2”)
The function sets the orientation of the robot to align the left and right movement of the robot in horizontal robot position and vertical robot position.
Syntax: setorientation(orientation = “HORIZONTAL”)
This function is used to analyze the image received as input from the specified URL of the image, for the feature.
Syntax: analyseURL(url = “https://ai.thestempedia.com/wp-content/uploads/2022/02/Robert-and-Chris.jpg”)
This function is used to analyze the image received as input from the image URL specified, for the handwritten and printed text.
Syntax: analyseURL(url = “https://ai.thestempedia.com/wp-content/uploads/2022/07/Hello-World.png”)
The function moves the servo motors of the pick and place robot to the place angle specified by the user.
Syntax: place()
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 motor number = 1, angle = 90, time = 1000)
The function reports the state of the LDR (Light) 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: ldrstatus(pin = “A1”)
The function returns the last data value of the specified feed as a string.
Syntax: adaio.getdata(feedname = “feed name”)
The function sets the servo motors of the Mars Rover to the specified angles.
Syntax: setwheelsangle(Front Left = 90, Front Right = 90, Back Left = 90, Back Right = 90)
The function sets the servo motors of the humanoid hip and leg to the specified angles at the specified speed.
Syntax: moveleg(time = 1000, servo angles = [90,90,90,90])
The function controls the speed of a selected motor, allowing it to run at a specified speed.
Syntax: runmotor(motor = “fl”, speed = 100)
The function stops the specified motor of the Quarky Expansion Board.
Syntax: stopmotor(motor port = 1)
The function takes two arguments – y-coordinate and x-coordinate – and produces an angle in radians from -(pi) to +(pi).
Syntax: math.atan2(y, x)
This function is used to move a robotic arm from its current position to a specific X, Y, and Z coordinate position over a specified period of time. It takes in multiple parameters, such as the current position of the arm, the coordinates to move to, and the interval in which to move. The function then determines how many steps must be taken in each axis to reach the destination point, and moves in the X axis first, then the Y axis, and lastly the Z axis before returning the successful result.
Syntax: roboticArm.movexyzonebyone(XPOS = 0, YPOS = 150, ZPOS = 70, TIME = 1000)
This function sets the IR threshold for either the default sensor or one connected to an analog pin.
Syntax: setirthreshold(set_sensor = ‘left’, set_value = 750)
This function displays the total number of faces detected in the camera feed or the stage.
Syntax: count()
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