Welcome to DOFBOT-JetsonNANO repository
10.Porter
Nature Porter
I. Gameplay Introduction
The purpose of this experiment is to stack four different colored building blocks from bottom to top in the order of blue-green-red-yellow on the middle gray block, then run the code. The robotic arm will execute in the following order: grab the fourth layer block and place it in the yellow area, grab the third layer block and place it in the red area, grab the second layer block and place it in the green area, and grab the bottom layer block and place it in the blue area. The arrangement of building blocks is shown in the figure below:

After executing the code, the robotic arm will move the building blocks to corresponding positions. The final effect is shown in the figure below:

II. Start Docker
After entering the main board desktop, open a terminal and run the following command to start the corresponding Dofbot container:
xxxxxxxxxx./Docker_Ros.sh
Then enter the following command in the Docker terminal to start jupyter-lab,
xxxxxxxxxxcdjupyter-lab --allow-root
Then enter the main board's IP address followed by :9999 in the browser,
xxxxxxxxxxIP:9999 // Example: 192.168.1.11:9999
III. Code Content
Code path: /root/Dofbot/3.ctrl_Arm/10.move_block.ipynb
xxxxxxxxxx#!/usr/bin/env python3#coding=utf-8import timefrom Arm_Lib import Arm_Device# Create robotic arm objectArm = Arm_Device()time.sleep(.1)xxxxxxxxxx# Define block clamping function, enable=1: clamp, =0: releasedef arm_clamp_block(enable): if enable == 0: Arm.Arm_serial_servo_write(6, 60, 400) else: Arm.Arm_serial_servo_write(6, 130, 400) time.sleep(.5)# Define robotic arm movement function, simultaneously control servos 1-5 movement, p=[S1,S2,S3,S4,S5]def arm_move(p, s_time = 500): for i in range(5): id = i + 1 if id == 5: time.sleep(.1) Arm.Arm_serial_servo_write(id, p[i], int(s_time*1.2)) else : Arm.Arm_serial_servo_write(id, p[i], s_time) time.sleep(.01) time.sleep(s_time/1000)# Robotic arm moves upwarddef arm_move_up(): Arm.Arm_serial_servo_write(2, 90, 1500) Arm.Arm_serial_servo_write(3, 90, 1500) Arm.Arm_serial_servo_write(4, 90, 1500) time.sleep(.1)xxxxxxxxxx# Define variable parameters for different positionsp_mould = [90, 130, 0, 0, 90]p_top = [90, 80, 50, 50, 270]p_Yellow = [65, 22, 64, 56, 270]p_Red = [117, 19, 66, 56, 270]p_Green = [136, 66, 20, 29, 270]p_Blue = [44, 66, 20, 28, 270]p_layer_4 = [90, 72, 49, 13, 270]p_layer_3 = [90, 66, 43, 20, 270]p_layer_2 = [90, 63, 34, 30, 270]p_layer_1 = [90, 53, 33, 36, 270]xxxxxxxxxx# Move the robotic arm to a preparation position for grabbingarm_clamp_block(0)arm_move(p_mould, 1000)time.sleep(1)# Move the fourth layer building block to the yellow areaarm_move(p_top, 1000)arm_move(p_layer_4, 1000)arm_clamp_block(1)arm_move(p_top, 1000)arm_move(p_Yellow, 1000)arm_clamp_block(0)time.sleep(.1)arm_move_up()arm_move(p_mould, 1100) # time.sleep(1)xxxxxxxxxx# Move the third layer building block to the red areaarm_move(p_top, 1000)arm_move(p_layer_3, 1000)arm_clamp_block(1)arm_move(p_top, 1000)arm_move(p_Red, 1000)arm_clamp_block(0)time.sleep(.1)arm_move_up()arm_move(p_mould, 1100) # time.sleep(1)xxxxxxxxxx# Move the second layer building block to the green areaarm_move(p_top, 1000)arm_move(p_layer_2, 1000)arm_clamp_block(1)arm_move(p_top, 1000)arm_move(p_Green, 1000)arm_clamp_block(0)time.sleep(.1)arm_move_up()arm_move(p_mould, 1100) # time.sleep(1)xxxxxxxxxx# Move the first layer building block to the blue areaarm_move(p_top, 1000)arm_move(p_layer_1, 1000)arm_clamp_block(1)arm_move(p_top, 1000)arm_move(p_Blue, 1000)arm_clamp_block(0)time.sleep(.1)arm_move_up()arm_move(p_mould, 1100) # time.sleep(1)xxxxxxxxxxdel Arm # Release the Arm object