Welcome to Muto S2 Robot repository
9.Action group performance
9.Action group performance
9.Action group performance1. Experimental goals2. Experiment preparation3. Experiment procedure4. Experiment summary
1. Experimental goals
This course mainly learns how to control the functions of the robot action group performance.
2. Experiment preparation
The functions of the Muto hexapod robot Python library involved in this course are as follows:
action(action_id):Action group performance function, the robot has eight built-in action groups, and you can directly call the function to open the robot's action group performance function.
The value range of parameter action_id is [1, 8],it represents eight actions. The action names are:1.Stretch,2. Greeting,3.Retreat,4.Warm_up,5Turn_around,6.Say_no,7.Crouching,8.Stride.
If you need to end the action early during the performance, please call the stop() or reset() function to end the action early.
3. Experiment procedure
Open the jupyterLab client and find the code path:
muto/Samples/Control/6.action.ipynb
By default g_ENABLE_CHINESE=False, if you need to display Chinese, please set g_ENABLE_CHINESE=True.
x# 中文开关,默认为英文 Chinese switch. The default value is Englishg_ENABLE_CHINESE = FalseName_widgets = {'Stretch': ("Stretch", "伸懒腰"),'Greeting': ("Greeting", "打招呼"),'Retreat': ("Retreat", "害怕退缩"),'Warm_up': ("Warm_up", "热身蹲起"),'Turn_around': ("Turn_around", "原地转圈"),'Say_no': ("Say_no", "挥手说不"),'Crouching': ("Crouching", "寄居蜷起"),'Stride': ("Stride", "大步向前"),'End': ("End", "结束")}
Click to run all cells, and then scroll to the bottom to see the generated controls.

Click different buttons to correspond to different functions.

Every time a button is clicked, the corresponding function will be executed. Key event processing:
xxxxxxxxxx# 按键按下事件处理 Key press event processingdef on_button_clicked(b):with output:print("Button clicked:", b.description)if b.description == Name_widgets['Stretch'][g_ENABLE_CHINESE]:g_bot.action(1)elif b.description == Name_widgets['Greeting'][g_ENABLE_CHINESE]:g_bot.action(2)elif b.description == Name_widgets['Retreat'][g_ENABLE_CHINESE]:g_bot.action(3)elif b.description == Name_widgets['Warm_up'][g_ENABLE_CHINESE]:g_bot.action(4)elif b.description == Name_widgets['Turn_around'][g_ENABLE_CHINESE]:g_bot.action(5)elif b.description == Name_widgets['Say_no'][g_ENABLE_CHINESE]:g_bot.action(6)elif b.description == Name_widgets['Crouching'][g_ENABLE_CHINESE]:g_bot.action(7)elif b.description == Name_widgets['Stride'][g_ENABLE_CHINESE]:g_bot.action(8)
4. Experiment summary
This time, JupyterLab control is used to control the six-legged robot to perform built-in action groups. Currently, there are eight built-in action groups: 1. Stretch, 2. Greeting, 3. Retreat, 4. Warm_up, 5.Turn_around, 6. Say_no, 7. Crouching , 8 Stride. Before each set of actions is completed, if you click on other actions, it will not take effect. Only after the action is completed, clicking on the next set of actions will take effect.

To exit the program, press the End button to exit the program.