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 returns its sprite’s current costume number or name.
Syntax: costume(result_type = “number”)
The function reports the data stored from the last RFID scan.
Syntax: readscanneddata()
The function reports the selected field data from the last read request from ThingSpeak.
Syntax: ts.getdatafromfield(field = 1)
The function reports the time passed from the reset for the oscillator.
Syntax: oscillationtimer()
This function sets the angle of the Gripper Robot’s gripper servo motor to a particular value when it is in the open position.
Syntax: setopenangle(angle = 90)
This function takes a single parameter as input and returns the current position of the end effector along a specified axis.
Syntax: roboticArm.getcurrentposition(AXIS = “x”)
The function allows the user to add a particular face to the database from the stage. 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: addclassfromstage(label_number = 1, label_name = “Jarvis”)
The function changes the Rotation Style of the sprite in-project. Regardless of the style, the variable direction will still change.
Syntax: setrotationstyle(rotation_style = “left-right”)
The function writes the message to the RFID tag. It will wait for the specified time to scan an RFID tag and write the value on it. The function also reports whether the operation is completed or not. If the write is complete the block returns 1, else it returns 0.
Syntax: writetorfid(data = “Hello!”, duration = 5)
The block makes the specified type of HTTP request (GET, POST, or DELETE) on the specified URL. The request can have a body or not.
Syntax: makeapirequest(request = “GET”, url = “url”, bodytype = “with”)
This function allows the Gripper Robot to close its gripper.
Syntax: closearm()
The function deletes all the stored databases of the images for face recognition. 
Syntax: deleteallclass()
The function returns the sprite’s X position.
Syntax: x()
The function returns the sprite’s Y position.
Syntax: y()
The function returns its sprite’s current backdrop number or name.
Syntax: backdrop(result_type = “number”)
The function sets the last scanned RFID tag to the master RFID tag. This can be used for authentication.
Syntax: setmaster()
The function defines the value of the body.
Syntax: setbody(body = “{“value”:”5″}”)
This function allows the Gripper Robot to open its gripper.
Syntax: openarm()
This function is used to match the input image from the camera with the stored classes previously stored in the database. 
Syntax: recognisefromcamera()
The function returns the sprite’s direction in angle.
Syntax: direction()
The function returns its sprite’s size.
Syntax: size()
The function reports if the last RFID tag scanned is a master tag or not. If it is the master RFID tag, then it returns 1, else 0.
Syntax: ismaster()
The function sets the body content type to the specified value.
Syntax: setcontenttype(type = “application/x-www-form-urlencoded”)
This function is used to match the input image from the stage with the stored classes previously stored in the database. 
Syntax: recognisefromstage()
The function reports the master RFID tag ID.
Syntax: getmastertag()
The function reports the request-response code received.
Syntax: requestapicode()
This function is used to check if the input image belongs to one of the classes previously defined. The class to be checked with can be set using the argument as label_number.
Syntax: isclassdetected(label_number = 1)
The function reports the last scanned RFID tag ID.
Syntax: gettag()
The function reports the body or error value from the HTTP request.
Syntax: getresponse(type = “body”)
This function is used to get the class of the input face detected from the analysis. The identifying number of the face being analyzed can be set using the argument.
Syntax: getclassname(face = 1)
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 returns its sprite’s current costume number or name.
Syntax: costume(result_type = “number”)
The function reports the data stored from the last RFID scan.
Syntax: readscanneddata()
The function reports the selected field data from the last read request from ThingSpeak.
Syntax: ts.getdatafromfield(field = 1)
The function reports the time passed from the reset for the oscillator.
Syntax: oscillationtimer()
This function sets the angle of the Gripper Robot’s gripper servo motor to a particular value when it is in the open position.
Syntax: setopenangle(angle = 90)
This function takes a single parameter as input and returns the current position of the end effector along a specified axis.
Syntax: roboticArm.getcurrentposition(AXIS = “x”)
The function allows the user to add a particular face to the database from the stage. 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: addclassfromstage(label_number = 1, label_name = “Jarvis”)
The function changes the Rotation Style of the sprite in-project. Regardless of the style, the variable direction will still change.
Syntax: setrotationstyle(rotation_style = “left-right”)
The function writes the message to the RFID tag. It will wait for the specified time to scan an RFID tag and write the value on it. The function also reports whether the operation is completed or not. If the write is complete the block returns 1, else it returns 0.
Syntax: writetorfid(data = “Hello!”, duration = 5)
The block makes the specified type of HTTP request (GET, POST, or DELETE) on the specified URL. The request can have a body or not.
Syntax: makeapirequest(request = “GET”, url = “url”, bodytype = “with”)
This function allows the Gripper Robot to close its gripper.
Syntax: closearm()
The function deletes all the stored databases of the images for face recognition. 
Syntax: deleteallclass()
The function returns the sprite’s X position.
Syntax: x()
The function returns the sprite’s Y position.
Syntax: y()
The function returns its sprite’s current backdrop number or name.
Syntax: backdrop(result_type = “number”)
The function sets the last scanned RFID tag to the master RFID tag. This can be used for authentication.
Syntax: setmaster()
The function defines the value of the body.
Syntax: setbody(body = “{“value”:”5″}”)
This function allows the Gripper Robot to open its gripper.
Syntax: openarm()
This function is used to match the input image from the camera with the stored classes previously stored in the database. 
Syntax: recognisefromcamera()
The function returns the sprite’s direction in angle.
Syntax: direction()
The function returns its sprite’s size.
Syntax: size()
The function reports if the last RFID tag scanned is a master tag or not. If it is the master RFID tag, then it returns 1, else 0.
Syntax: ismaster()
The function sets the body content type to the specified value.
Syntax: setcontenttype(type = “application/x-www-form-urlencoded”)
This function is used to match the input image from the stage with the stored classes previously stored in the database. 
Syntax: recognisefromstage()
The function reports the master RFID tag ID.
Syntax: getmastertag()
The function reports the request-response code received.
Syntax: requestapicode()
This function is used to check if the input image belongs to one of the classes previously defined. The class to be checked with can be set using the argument as label_number.
Syntax: isclassdetected(label_number = 1)
The function reports the last scanned RFID tag ID.
Syntax: gettag()
The function reports the body or error value from the HTTP request.
Syntax: getresponse(type = “body”)
This function is used to get the class of the input face detected from the analysis. The identifying number of the face being analyzed can be set using the argument.
Syntax: getclassname(face = 1)
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