Welcome to DOFBOT-JetsonNANO repository
8.DOFBOT memory action
Robotic Arm Memory Action
I. API Introduction
The corresponding API for entering/exiting learning mode is:
Arm_Button_Mode(enable)
Function: Set whether the robotic arm enters learning mode.
Parameter explanation:
enable: enable=0: exit learning mode, enable=1: enter learning mode.
After entering learning mode, the RGB light on the robotic arm expansion board will show a breathing light state, and the robotic arm will automatically disable torque. You can freely move the robotic arm's angles. Each time you press the K1 button on the expansion board, the breathing light will switch to another color, indicating that the current robotic arm angle has been recorded. A maximum of 20 action groups can be recorded. When the number of recorded action groups exceeds 20, pressing the K1 key will no longer record actions, and the breathing light will show a red state. After exiting learning mode, the robotic arm will automatically enable torque and turn off the RGB light.
Return value: None.
The corresponding API for reading the current number of action groups is:
Arm_Read_Action_Num()
Function: Read the number of currently recorded action groups.
Parameter explanation:
Return value: Returns the number of currently recorded action groups.
The corresponding API for running action groups is:
Arm_Action_Mode(mode)
Function: Run recorded action groups.
Parameter explanation:
mode: mode=0: stop running action groups, mode=1: single run of action groups, mode=2: loop run action groups.
Return value: None.
The corresponding API for clearing action groups is:
Arm_Clear_Action()
Function: Clear recorded action groups. Cannot be restored after clearing.
Parameter explanation:
Return value: None.
In learning mode, the corresponding API for learning actions is:
Arm_Action_Study()
Function: In learning mode, send command to tell the expansion board to record the current robotic arm posture as an action group. When learning is successful, the RGB light breathing effect will change color.
Parameter explanation:
Return value: None.
II. Start Docker
After entering the main board desktop, open a terminal and run the following command to start the corresponding Dofbot container:
./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/8.study_mode.ipynb
The following code content needs to be executed step by step according to each step, cannot run all at once.
xxxxxxxxxx#!/usr/bin/env python3#coding=utf-8import timefrom Arm_Lib import Arm_Devicexxxxxxxxxx# Create robotic arm objectArm = Arm_Device()time.sleep(.1)xxxxxxxxxx# Enable learning mode, the RGB light on the expansion board shows breathing light state, and all robotic arm servos enter torque-off state,# meaning they can be freely moved. You can move the robotic arm to the position you want to remember.Arm.Arm_Button_Mode(1)xxxxxxxxxx# In learning mode, each time this cell is run, the current action is recorded and saved to the expansion board, while the RGB light on the expansion board will change color.# If a red breathing light appears, it means the learned action groups are full (20 groups).# This command can also be replaced by pressing the K1 key on the expansion board; both functions are identical.Arm.Arm_Action_Study()xxxxxxxxxx# Disable learning mode. Turn off breathing lightArm.Arm_Button_Mode(0)xxxxxxxxxx# Read current number of action groupsnum = Arm.Arm_Read_Action_Num()print(num)xxxxxxxxxx# Single run action groupsArm.Arm_Action_Mode(1)xxxxxxxxxx# Loop run action groupsArm.Arm_Action_Mode(2)xxxxxxxxxx# Stop action groupsArm.Arm_Action_Mode(0)xxxxxxxxxx# Clear action groups, after clearing is complete, the RGB light on the expansion board will turn green.# Note: Once recorded action groups are cleared, they cannot be recovered.Arm.Arm_Clear_Action()xxxxxxxxxxdel Arm # Release the Arm objectxxxxxxxxxxOpen the program in jupyter lab, and click the run cell button on the toolbar to run the program step by step.

xxxxxxxxxxAfter opening learning mode, you can move the robotic arm's posture, then run Arm.Arm_Action_Study() or press the K1 key on the expansion board to record the current robotic arm posture. Run this operation several more times, then close learning mode. Next, you can run the just-learned action groups to see the effect. Specific operations are explained in the comments in the above code.