TigerJython4Kids
 robotics
Beatle
Deutsch   English   

14. GRIPPER ARM WITH SERVOMOTOR (Mechanic beatle)

 

 

YOU LEARN HERE...

 

connect a gripper arm (Maqueen Mechanic Beatle) to your mbRobot and control it with a servo motor. The gripper arm can grab and transport light objects.


 

 

ASSEMBLE GRIPPER ARM

 

You can order the gripper arm with a servo motor individually (Maqueen Mechanics Beatle) or in a kit (Maqueen Mechanics Roboter-Kit). The servo motor is connected to port S1 or S2 of the Maqueens 4 or to ports S1 or S2 of the Maqueens Plus.

 

 

 

On the Maqueen Plus V2, the servomotor is connected to port P1 or P2. These are located at the rear right of the chassis. In your programme, you must call up the servo ports in the setServo() command with P1 or P2 (instead of S1 or S2).

The Beatle is assembled according to the following instructions: Building plan Beatle

 

 

 

 

EXAMPLES

 

Example 1: Test gripper arm

The servomotor moves both arms of the gripper arm simultaneously. With the command
setServo("S1", 60)
to the open position, with
setServo("S1", 95)
the robot can grab objects. You may still need to adjust the angles.

 



from mbrobot import *
#from mbrobot_plus import *

setServo("S1", 95)
delay(1000)             
setServo("S1", 60)
delay(1000) 
setServo("S1", 95)
Copy to clipboard

 

Example 2: Grasping an object

The robot moves to the object located a short distance in front of it, grabs it with its gripper arm, moves back a short distance, turns to the left and places the object in the new location (similar to the video above).

 

from mbrobot import *
#from mbrobot_plus import *

setServo("S1", 95)
delay(1000)
setServo("S1", 60)
forward()
delay(1000)
stop()
setServo("S1", 95)
backward()
delay(500)
left()
delay(700)
stop()
setServo("S1", 60)
Copy to clipboard

 

Example 3: Positioning the gripper arm with an ultrasonic sensor

In example 2, the robot always starts at the same distance from the object and the length of the forward movement is determined by a time specification (delay(1000)). With the help of an ultrasonic sensor, the robot can recognise the correct position itself. The robot moves forwards until its distance to the object or to a wall behind it is less than 20 cm. It then grabs the object with its gripper arm and transports it away (similar to the video below).

 

from mbrobot import *
#from mbrobot_plus import *

setServo("S1", 60)
forward()
repeat:
    d = getDistance()
    print(d)
    if d < 20: 
        stop()
        delay(500)
        setServo("S1", 95)
        delay(500)             
        backward()
        delay(2500)
        left()
        delay(700)      
        stop()
        setServo("S1", 60)
    delay(100) 
  
Copy to clipboard

The distance to the wall is scanned every 100 milliseconds in an ‘endless’ repeat loop. If it is less than 20 cm, the robot stops and grabs the object with its gripper arm.

 

Example 4: Turn ultrasonic sensor with servomotor

The ultrasonic sensor is attached to a second servomotor in accordance with the assembly instructions above. This is connected to port S2. You can use the rotating ultrasonic sensor to search for objects (Exercise 3) or to have the robot follow a wall at a certain distance (Exercise 4).


from mbrobot import *
#from mbrobot_plus import *

setServo("S2", 90)
delay(2000)
setServo("S2", 0)
delay(2000)
setServo("S2", 90)
delay(2000)

angle = 90
while angle >= 0:
    setServo("S2", angle)
    delay(500)
    angle = angle - 10
    
angle = 0
while angle <= 90:
    setServo("S2", angle)
    delay(500)
    angle = angle + 10 
Copy to clipboard

The programme shows how to turn the ultrasonic sensor with a second servomotor from the frontal position to a position that is parallel to the direction of travel. First in one step and then in small steps.

 

 

REMEMBER...

 

The servomotor is rotated by the desired angle using the setServo(Port, Angle) command, whereby you can select a number between 0 and 180 for the first parameter S1 or S2 and the angle. The servo motor moves both arms simultaneously.

You can connect a second servo motor to port S2 to rotate the ultrasonic sensor.

 

 

TO SOLVE YOURSELF

 

 


1.


Robot with a gripper arm moves forwards for 2000 milliseconds and loads an object. It then turns 180° to the left, moves forwards for 2000 milliseconds and puts the object down. It then turns 180° to the right and picks up the next object.

 
 
2.

Supplement the situation from task 1 with two walls so that the robot completes the forward movements with the help of an ultrasonic sensor and repeats the loading and unloading process several times.

 


3.

The ultrasonic sensor rotates in small steps with the help of the servomotor until it recognises an object. It then triggers an alarm. You can limit the search by only searching for objects at a distance of between 30 and 70 cm.

4.
With the help of a servomotor, the ultrasonic sensor turns to a position parallel to the direction of travel so that it can measure the distance sideways. The robot then moves forwards at a distance of approximately 15 cm along a straight wall.