Skip to content

动作播放模块

This content is not available in your language yet.

动作播放模块(Motion Player,MP) 是 A2 机器人上用于管理动作播放的模块。它提供了一个 rpc 接口,能够接受动作播放相关的请求,如开始播放、暂停、停止、循环等命令。

本模块在基础款和旗舰款都位于 x86 开发板上,http 后端监听的端口为 56444。

此模块通过 RPC 协议实现对动作播放的控制,支持发送包括动作播放、停止、暂停、循环等命令。下面是 motion_player 模块的协议说明:

SendMotionCommandmotion_player 模块的核心 RPC 命令,用于控制机器人的动作播放。

  • 动作播放:根据给定的动作名称(motion_id),开始播放特定的动作。
  • 暂停和复位:通过 cmd_pause 标志来暂停正在执行的动作,cmd_reset 标志允许将动作恢复到初始姿态。
  • 循环播放:通过 cmd_repeat 标志设置动作为循环播放,直到外部命令停止。
  • 自动结束:根据 cmd_end 设置,动作可以在播放结束后自动复位或停留在最后一帧。
接口名接口描述请求消息类型答复消息类型备注通信后端
pb:/aimdk.protocol.MotionCommandService/SendMotionCommand动作播放命令aimdk::protocol::MotionCommandRequestaimdk::protocol::CommonResponsehttp
pb:/aimdk.protocol.MotionCommandService/GetMotionStatus动作信息查询aimdk::protocol::CommonRequestaimdk::protocol::MotionCommandResponsehttp
pb:/aimdk.protocol.MotionCommandService/EnableMotionPlayer开启动作播放aimdk::protocol::CommonRequestaimdk::protocol::CommonResponse与发送 cmd_pause=true 效果相同,但是不会在运控模块切换 Action 之后被重置,可以视为 motion_player 等同于被 aima em stop-app motion_player 停止,在 JOINT_SERVO 相关模式下会立即复位http
pb:/aimdk.protocol.MotionCommandService/DisableMotionPlayer关闭动作播放aimdk::protocol::CommonRequestaimdk::protocol::CommonResponse恢复 motion_player 的动作控制,如果在 JOINT_SERVO 相关模式下会立即复位http
字段名称类型描述
headeraimdk::protocol::RequestHeader请求头,包含请求的元数据。包括请求的唯一标识符、时间戳、请求类型等。
motion_idstring动作名称,表示要执行的具体动作。动作名称为动作文件的绝对路径加动作名称。
duration_msint64设置动作最长运行时间,单位为毫秒。
cmd_pausebool动作暂停标志,true表示暂停,将暂停向机器人发送控制信号。
cmd_resetbool复位标志,true表示复位,false表示不复位。复位操作会将当前动作的状态重置至初始状态。
cmd_repeatbool该标志已弃用,为保持兼容性未做删除,请勿使用。
cmd_endbool是否在动作执行后自动恢复到初始姿态,true表示自动复位,false表示不自动复位。
字段名称类型描述
headeraimdk::protocol::RequestHeader请求头,包含请求的元数据。包括请求的唯一标识符、时间戳、请求类型等。
time_to_end_msint64当前正在播放的动作的剩余播放时间。
statusaimdk::protocol::MotionCommandStatus当前的工作状态(分为空闲、开始、运行中和暂停)。
is_neck_enablebool指示当前是否使用 motion_player 控制头部运动。
motion_idstring上一次触发播放的动作名称。
NameNumberDescription
MotionCommandStatus_IDLE0空闲
MotionCommandStatus_START1开始执行
MotionCommandStatus_OPERATING2运行中
MotionCommandStatus_PAUSE3暂停
MotionCommandStatus_STOP4停止

下面是一个使用 SendMotionCommand 接口进行简单二次开发后发送动作命令的 bash 脚本示例,运行时在脚本的参数中指定动作名称。用户可以根据自己的需要使用任何其他类似的方式编写自定义的逻辑实现定制化的动作播放功能。

Terminal window
# 调用示例
./send_motion_id.sh /agibot/data/resources/default/motion/motion_player/default/演讲10s/演讲10s

注意以上动作位于 x86 上,如需使用其他动作请查看 x86 上动作文件夹下的所有动作文件,自定义动作请放置在 /agibot/data/var/rc/custom 目录中(需使用遥操作相关功能才可以录制自定义动作)。

#!/bin/bash
if [ $# -eq 0 ]; then
echo "arg error, need motion_id, ./send_motion_id.sh motion_id, example: "
echo ./send_motion_id.sh /agibot/data/resources/default/motion/motion_player/default/演讲10s/演讲10s
exit 0
fi
MC_ID="$1"
if [ "$MC_ID" == "停止动作" ]; then
# 如果是“停止动作”,则 motion_id 为空,cmd_reset 设为 true
DATA='{
"motion_id": "",
"duration_ms": 10000,
"cmd_end": true,
"cmd_pause": false,
"cmd_reset": true
}'
elif [ "$MC_ID" == "暂停播放器" ]; then
# 如果是“暂停播放器”,则 motion_id 保持不变,cmd_pause 设为 true
DATA='{
"motion_id": "",
"duration_ms": 10000,
"cmd_end": true,
"cmd_pause": true,
"cmd_reset": false
}'
elif [ "$MC_ID" == "下一个动作" ]; then
# 如果是“下一个动作”,则 播放 list 中的下一个动作
DATA='{
"motion_id": "next_motion",
"duration_ms": 10000,
"cmd_end": true,
"cmd_pause": false,
"cmd_reset": false
}'
else
# 如果不是“停止动作”或“暂停播放器”,保持原有逻辑
DATA='{
"motion_id": "'"$MC_ID"'",
"duration_ms": 10000,
"cmd_end": true,
"cmd_pause": false,
"cmd_reset": false
}'
fi
# 使用 curl 发送 POST 请求
curl -i \
-H 'content-type:application/json' \
-H 'timeout: 1000' \
-X POST http://192.168.100.100:56444/rpc/aimdk.protocol.MotionCommandService/SendMotionCommand \
-d "$DATA"
# 打印发送的数据
echo "$DATA"

下面是使用 GetMotionStatus 接口进行动作状态查询的示例脚本。

Terminal window
# 调用示例
./get_motion_status.sh
#!/bin/bash
curl -i \
-H 'content-type:application/json' \
-H 'timeout: 1000' \
-X POST http://192.168.100.100:56444/rpc/aimdk.protocol.MotionCommandService/GetMotionStatus \
-d '{}'

关于开启和关闭动作播放的示例:

Terminal window
# 开启动作播放
curl -i \
-H 'content-type:application/json' \
-H 'timeout: 1000' \
-X POST http://192.168.100.100:56444/rpc/aimdk.protocol.MotionCommandService/EnableMotionPlayer \
-d '{}'
# 关闭动作播放
curl -i \
-H 'content-type:application/json' \
-H 'timeout: 1000' \
-X POST http://192.168.100.100:56444/rpc/aimdk.protocol.MotionCommandService/DisableMotionPlayer \
-d '{}'

默认动作位于 /agibot/data/resources/default/motion/motion_player/default 目录下。

中文名称英文名称
右手比心Finger heart_right hand
左手握手_长Handshake_left hand_Long
通用讲解动作_29sGeneral explanation actions_29s
右手碰拳_长Bump fists_right hand_Long
右手加油Come on_right hand
左转头Turn head to the left
左手握手Handshake_left hand
右手点赞Like_right hand
右手比耶Yeah_right hand
点点头Nod head
通用讲解动作_11sGeneral explanation actions_11s
通用讲解动作_8sGeneral explanation actions_8s
打太极拳Tai Chi
通用讲解动作_22sGeneral explanation actions_22s
通用讲解动作_25sGeneral explanation actions_25s
右手碰拳Bump fists_right hand
生活化敬礼Life-like salute
右手握手Handshake_right hand
左手比耶Yeah_left hand
左手点赞Like_left hand
左手挥手Wave hand_left hand
右手挥手Wave hand_right hand
右转头Turn head to the right
右手握手_长Handshake_right hand_Long
左手碰拳_长Bump fists_left hand_Long
方向_向右欢迎 Welcome to the right_10s
方向_向左欢迎Welcome to the left_8s
左手碰拳Bump fists_left hand
双手点赞Like_both hands
右手点赞_长Like_right hand_Long
左手点赞_长Like_left hand_Long
双手挥手Wave hand_both hands
左手加油Come on_left hand
双手加油Come on_both hands
双手比耶Yeah_both hands
双手向下比心Finger heart_both hands
双手擦眼泪Wipe the tears
击掌_长High-five_right hand_Long
右手NONO_right hand
右手OKOK_right hand
跳舞Dance
摆拍_右手胸前比耶Pose_“V” sign in front of right chest
摆拍_左手胸前比耶Pose_Both hands “V” sign
摆拍_右手胸前点赞Pose_Thum-up in front of right chest
摆拍_抬起右手Pose_Raise the right hand
摆拍_双手咏春Pose_Wing Chun with both hands
摆拍_我是大力士Posed_I’m a strongman
摆拍_右手Pose_01Pose_Right hand_01
摆拍_右手Pose_02Pose_Right hand_02
摆拍_右手Pose_03Pose_Right hand_03
摆拍_右手Pose_04Pose_Right hand_04
摆拍_右手Pose_05Pose_Right hand_05
数字手势“1”Number gesture”1”
数字手势“2”Number gesture”2”
数字手势“3”Number gesture”3”
数字手势“4”Number gesture”4”
数字手势“5”Number gesture”5”
数字手势“6”Number gesture”6”
数字手势“7”Number gesture”7”
数字手势“8”Number gesture”8”
数字手势“9”Number gesture”9”
数字手势“10”Number gesture”10”
方向_向右上方指引Direction_upper right
方向_向右下方指引Direction_lower right
方向_向左上方指引Direction_upper left
方向_向左下方指引Direction_lower left
方向_右手指前方Direction_point to forward_right hand
方向_左手指前方Direction_point to forward_left hand
方向_右手指后方Direction_point to back_right hand
方向_左手指后方Direction_point to back_left hand
方向_指向当前位置Direction _ points to current position
方向_指向右边Direction_point to the right
方向_指向左边Direction_point to the left
方向_右边示意Direction_Indicated on the right
方向_左边示意Direction_Indicated on the left
开篇打招呼_12sGreeting at the beginning _12s
个人介绍_7sPersonal Introduction _7s
强调2大要点_12sHighlight 2 key points - 12S
强调3大要点_11sHighlight 3 key points - 11s
强调4大要点_16sHighlight 4 key points - 16S
快速强调5大要点_8sQuickly highlight 5 key points - 8S
对1个要点展开阐述_14sElaborate 1 key point _14s
对2个要点展开阐述_18sElaborate 2 key points: 18S
对3个要点展开阐述_15sElaborate 3 key points _15s
简述6个要点_12sBriefly describe 6 key points _12s
做“自上而下”的示意_10s”Top-down” gesture_10s
用手指强调信息_09sEmphasize the key point with fingers_09s
用握拳强调2组信息_12sMake a fist and emphasize 2 key points _12s
双手强调“全局”_08sBoth hands emphasize “the whole” _08s
右手强调“核心”_10sRight hand emphasize the “core”_10s
讲解结束总结_9sSummary after the lecture_9s
结尾致谢_7sAcknowledgements at the end _7s
语音对话专属动作_01Exclusive actions in voice chat _01
语音对话专属动作_02Exclusive actions in voice chat _02
语音对话专属动作_03Exclusive actions in voice chat _03
语音对话专属动作_04Exclusive actions in voice chat _04
语音对话专属动作_05Exclusive actions in voice chat _05
语音对话专属动作_06Exclusive actions in voice chat _06
语音对话专属动作_07Exclusive actions in voice chat _07
语音对话专属动作_08Exclusive actions in voice chat _08
语音对话专属动作_09Exclusive actions in voice chat _09
语音对话专属动作_10Exclusive actions in voice chat _10
语音对话专属动作_11Exclusive actions in voice chat _11
语音对话专属动作_12Exclusive actions in voice chat _12
语音对话专属动作_13Exclusive actions in voice chat _13
语音对话专属动作_14Exclusive actions in voice chat _14
语音对话专属动作_15Exclusive actions in voice chat _15
语音对话专属动作_16Exclusive actions in voice chat _16
语音对话专属动作_17Exclusive actions in voice chat _17
语音对话专属动作_18Exclusive actions in voice chat _18
语音对话专属动作_19Exclusive actions in voice chat _19
右手握手收回Withdraw the right hand handshake.