Welcome to DOFBOT-Ultra repository
8. DOFBOT Memory Actions
DOFBOT Memory Actions
1. API Introduction
- API for entering/exiting learning mode:
Arm_Button_Mode(enable)
Function: Sets whether the robotic arm enters learning mode.
Parameter Description:
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 arm will automatically disable torque, allowing you to freely move the arm angles. Each press of the K1 button on the expansion board will switch the breathing light to a different color, indicating the current arm angle has been recorded. Up to 20 action groups can be recorded. When the number of recorded action groups exceeds 20, pressing K1 will no longer record actions, and the breathing light will turn red. After exiting learning mode, the arm will automatically enable torque and turn off the RGB light.
Return value: None.
- API for reading the current number of action groups:
Arm_Read_Action_Num()
Function: Reads the number of currently recorded action groups.
Parameter Description:
Return value: Returns the number of currently recorded action groups.
- API for running action groups:
Arm_Action_Mode(mode)
Function: Runs the recorded action groups.
Parameter Description:
mode: mode=0: stop running action groups, mode=1: run action group once, mode=2: loop run action group.
Return value: None.
- API for clearing action groups:
Arm_Clear_Action()
Function: Clears the recorded action groups. Cannot be recovered after clearing.
Parameter Description:
Return value: None.
- API for learning actions in learning mode:
Arm_Action_Study()
Function: In learning mode, sends a command to tell the expansion board to record the current arm posture as an action group. When learning is successful, the breathing light effect changes color.
Parameter Description:
Return value: None.
2. Code
Code path:
~/dofbot_ctrl/scripts/08.study_mode.ipynb
The following code must be executed step by step, not all at once.
xxxxxxxxxx#!/usr/bin/env python3#coding=utf-8import timefrom Arm_Lib import Arm_Devicex
# Create robotic arm objectArm = Arm_Device()time.sleep(.1)x
# 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)x
# 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()x
# Close learning mode. Turn off breathing lightArm.Arm_Button_Mode(0)x
# Read the current number of action groupsnum = Arm.Arm_Read_Action_Num()print(num)x
# Single run of action groupsArm.Arm_Action_Mode(1)x
# Cyclically run action groupsArm.Arm_Action_Mode(2)x
# Stop action groupsArm.Arm_Action_Mode(0)x
# 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()x
del 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 entering learning mode, you can move the arm to a desired posture, then run Arm.Arm_Action_Study() or press the K1 button on the expansion board to record the current arm posture. Repeat this operation several times, then close the learning mode. Next, you can run the learned action groups to see the effect. The specific operations are explained in the comments in the code above.