The function sets the Quarky Gripper Robot’s gripper servo motor angle for an open position to the specified value.
Learn to control Mecanum using Dabble App on your device with customized functions for specialized motions using the Python Interface of the Pictoblox Software.
Introduction
In this activity, we will control the Mecanum Gripper according to our needs using the Dabble application on our own Devices.
We will first understand how to operate Dabble and how to modify our code according to the requirements. The following image is the front page of the Dabble Application.
Select the Gamepad option from the Home Screen and we will then use the same gamepad to control our Mecanum Gripper.
Code
The following blocks represent the different functions that are created to control the Mecanum Gripper for different types of motions. We will use the arrow buttons to control the basic movements.( Forward, Backward, Lateral Left, Lateral Right ). We will use custom functions to control the gripper actions. We will use the Triangle button to close the gripper arms and the Circle button to open the gripper arms. We will use the Cross button to rotate to the right direction and we will use the Square button to rotate to the left direction. We can use the Select button to stop the Mecanum whenever possible.
Note: You can always customize each and every function and button, and make your own activities easily. You will have to add the extensions of Mecanum and also of Dabble to access the functions. To access the basic extensions required, make sure to select the Board as Quarky first. Select the Python Coding Environment and on the top right click on the Upload Mode only for the code to work properly.
from quarky import *
# imported modules
from expansion_addon import Mecanum
import dabble
# User Defined Functions
def Initialization():
meca.initialisegripper(5)
meca.setcloseangle(90)
meca.stoprobot()
meca=Mecanum(1,2,7,8)
gp=dabble.Gamepad()
Initialization()
while True:
gp.processinput()
if gp.ispressed("up"):
meca.runrobot("forward",100)
else:
pass
if gp.ispressed("down"):
meca.runrobot("backward",100)
else:
pass
if gp.ispressed("right"):
meca.runrobot("lateral right",100)
else:
pass
if gp.ispressed("left"):
meca.runrobot("lateral left",100)
else:
pass
if gp.ispressed("triangle"):
meca.closearm()
else:
pass
if gp.ispressed("circle"):
meca.openarm()
else:
pass
if gp.ispressed("cross"):
meca.runrobot("circular right",100,1)
else:
pass
if gp.ispressed("square"):
meca.runrobot("circular left",100,1)
else:
pass
if gp.ispressed("select"):
meca.stoprobot()
else:
pass
meca.stoprobot()
You will have to connect the Quarky with the Dabble Application on your device. Make sure Bluetooth is enabled on the device before connecting. Connect the Mecanum to the Dabble application after uploading the code. You will be able to connect by clicking on the plug option in the Dabble Application as seen below. Select that plug option and you will find your Quarky device. Connect by clicking on the respective Quarky.
Important Notes
- The code will only run by uploading the code by connecting the Mecanum with the help of a C-Type Cable to the Laptop.
- You will be able to upload the Python Code by selecting the Upload option beside the Stage option.
- There may be a case where you will have to upload the firmware first and then upload the code to the Mecanum. You will be able to upload the firmware in Quarky with the help of the following steps:
- Go to the Block Coding Environment and select the Quarky Palette from the Block Section.
- Select the Settings button on top of the palette.
- In the settings dialog box, scroll down, and select the Upload Firmware option. This will help you to reset the Quarky if any previous code was uploaded or not.
- After the Firmware is uploaded, you can shift to the Python Mode and upload the code you have written. The upload button can be seen to the right section of the terminal as shown below.
Output
Forward-Backward Motion:
Circular Right-Left Motion:
Lateral Right-Left Motion:
Gripper Mechanism:
Read More