Welcome to DOFBOT Pro repository
8. DOFBOT Memory Actions
DOFBOT Memory Actions
1. API Introduction
The API corresponding to 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 effect, and the robotic arm will automatically disable torque. You can freely move the robotic arm's angle. 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 API corresponding to 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 API corresponding to 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: cyclically run action groups.
Return value: None.
The API corresponding to clearing action groups is:
Arm_Clear_Action()
Function: Clear recorded action groups. Cannot be recovered after clearing.
Parameter explanation:
Return value: None.
In learning mode, the API corresponding to 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 breathing light effect will change color.
Parameter explanation:
Return value: None.
2. Code Content
Code path:
~/dofbot_pro/dofbot_ctrl/scripts/08.study_mode.ipynb
The following code content needs to be executed step by step, not 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# Open learning mode, the RGB light on the expansion board shows breathing light effect, and all servos of the robotic arm 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, it records the current action and saves it to the expansion board, while the RGB light on the expansion board changes 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 button on the expansion board; both have the same function.Arm.Arm_Action_Study()xxxxxxxxxx# Close learning mode. Turn off breathing lightArm.Arm_Button_Mode(0)xxxxxxxxxx# Read the current number of action groupsnum = Arm.Arm_Read_Action_Num()print(num)xxxxxxxxxx# Single run of action groupsArm.Arm_Action_Mode(1)xxxxxxxxxx# Cyclically run action groupsArm.Arm_Action_Mode(2)xxxxxxxxxx# Stop action groupsArm.Arm_Action_Mode(0)xxxxxxxxxx# Clear action groups, the RGB light on the expansion board will turn green after clearing is complete.# Note: Once recorded action groups are cleared, they cannot be recovered.Arm.Arm_Clear_Action()xxxxxxxxxxdel Arm # Release the Arm objectOpen the program in jupyter lab and click the "Run cell" button on the toolbar to run the program step by step.

After opening learning mode, you can move the robotic arm's posture, then run Arm.Arm_Action_Study() or press the K1 button 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 code above.