将alphadog的ros包拷贝到当前工作空间目录下,本机默认为robot_ws目录(副节点),在工作空间使用catkin_make编译,编译成功后执行如下操作:
1、ROS从节点连接机器狗主节点
在从节点的工作空间robot_ws目录执行客户端程序执行如下命令:
$ . ./devel/setup.bash //设置环境
$ export ROS_MASTER_URI=http://10.10.10.10:11311 //机器狗主节点ip地址及接口
$ //export ROS_HOSTNAME=10.10.10.2 #自己电脑的ip地,
$ export ROS_IP=10.10.10.2 //推荐使用客户端ROS_IP 本机为:10.10.10.2
执行完毕后,即可在当前客户端窗口中执行 rostopic list 查看主题是否正常展示
2、控制指令发送
方式一:./devel/lib/ros_alphadog/do_action 0 #通过执行程序的方式调用主节点动作
方式二:rosrun ros_alphadog do_action 0 #通过ros运行节点程序
注:具体参数详见4动作列表整理
3、动作获得及速度设置
./devel/lib/ros_alphadog/get_actions #得到可执行动作
./devel/lib/ros_alphadog/set_velocity -0.2 0 0 #设置运动速度,参数分别为x,y,z的速度分解
4、动作列表整理
action [0] EStop #紧急停止
action [1] Wake # 唤醒
action [2] Get down #卧下
action [3] Recovery stand #恢复站立
action [4] Move
action [257] Jump
action [258] Jump round
action [259] Jump forward
action [273] Sway
action [516] Kick
action [513] Pee
action [514] Shake hand
action [515] Knock
action [545] Coax
action [274] Adjust center of mass
5、参数设置
# 运动控制参数配置
gen.add("controller_type", int_t, 1001, "Controller type.", 1, 0, 4)
//控制类型默认SBUS,SBUS=1;ROS/WIFI=2;LEASH=3(狗绳)
gen.add("user_mode", int_t, 1002, "User mode.", 2, 0, 4)
//用户模式默认2 ;EXTREME=1(极限模式);KIDS=2(儿童);NORMAL=3(普通模式);DANCE=4(舞蹈模式);QUIET=5(比较安静模式);MUTE=6(静音模式);LONG_ENDURANCE=7(长续航模式)
gen.add("gait", int_t, 1003, "Gait.", 3, 0, 11) //步态3;
//TROTTING=0(对角步态,稳定性好);TROTRUNNING=1(对角奔跑步态,速度快);TROTWALKING=2(缓慢的对角步态,速度慢);FREETROTTING=3(自由对角步态,自动根据速度调节,包括平衡站立,稳定与速度兼备);
//STANDING=4(平衡站立);BOUNDING=5(跳跑步态);PACING=6(踱步步态);PRONKING=7(跳跃步态);WALKING=8(行走步态,按照常规四足动物行走时的摆腿顺序);
//GALLOPING=9(疾驰步态,类似于马奔跑的摆腿顺序);BRISKTROTWALKING=10(比TROTWALKING稍快的对角步态);STATICWALKING=11(准静态缓慢行走);BRISKWALKING=12(准静态竞走)
//FASTWALKING=13(准静态快速行走);FREEWALKING=14(自由准静态行走步态,会根据速度指令自动调节步态);FREESTATIC=15(自由静态步态,移动中保持静态稳定,会根据速度调节摆腿周期);
gen.add("swing_traj_type", int_t, 1004, "Swing leg trajectory type.", 1, 0, 2) //摆腿轨迹类型 1
//Efficient=0(高效、省电);General=1(通用模式,适用大多数场景);Avoid obstacle=2(更适合跨越障碍和楼梯的摆腿轨迹);Elegant=3(优雅的摆腿轨迹);Compliant=4(避免髋关节转动的摆腿轨迹);
gen.add("ground_model", int_t, 1005, "Ground model to control body and legs.", 4, 0, 4) //地面模型 4
//HORIZEN=0(保持身体水平);OBSTACLE=1(身体姿态自适应地形坡度);STAIRS=2(上下楼梯);SLOPE=3(斜坡地形);COMMON=4(通用地形);
gen.add("vx", double_t, 1012, "Forward/backward translation speed in m/s.", 0, -2.0, 3.0)
gen.add("vy", double_t, 1012, "Left/right translation speed in m/s.", 0, -2.0, 2.0)
gen.add("wz", double_t, 1012, "Spin speed in rad/s.", 0, -8.0, 8.0)
gen.add("roll", double_t, 1010, "Roll angle in rad.", 0, -0.52, 0.52)
gen.add("pitch", double_t, 1010, "Pitch angle in rad.", 0, -0.52, 0.52)
gen.add("yaw", double_t, 1010, "Yaw angle in rad.", 0, -1.04, 1.04)
gen.add("body_tilt_x", double_t, 1008, "Forward/backward tilt.", 0.0, -0.08, 0.08) //前后偏移
gen.add("body_tilt_y", double_t, 1008, "Left/right tilt.", 0.0, -0.05, 0.05) //左右偏移
gen.add("body_height", double_t, 1008, "Body height in meters.", 0.285, 0.16, 0.36)
gen.add("foot_height", double_t, 1007, "Foot swing height in meters.", 0.06, 0.001, 0.24)
gen.add("swing_duration", double_t, 1006, "Foot swing duration in seconds.", 0.16, 0.1, 5.0) //腿摆动周期
gen.add("friction", double_t, 1013, "Ground friction coefficient.", 0.45, 0.1, 1.0)
gen.add("scale_x", double_t, 1009, "Supporting plane scale ratio in x-axis.", 1.0, 0.3, 1.8)
gen.add("scale_y", double_t, 1009, "Supporting plane scale ratio in y-axis.", 1.0, 0.3, 1.8)
gen.add("free_leg", int_t, 1014, "Free leg ID when recoding custom action.", 1, 1, 4)
gen.add("swaying_duration", double_t, 1015, "Body swaying duration in seconds.", 2.0, 1.0, 10.0) //左右摆动周期
gen.add("jump_distance", double_t, 1016, "Jump forward distance in meters.", 0.5, 0.0, 1.0)
gen.add("jump_angle", double_t, 1017, "Jump round angle in rad.", 0.0, -3.14, 3.14)
gen.add("decelerate_time", double_t, 1018, "Time in seconds to start decelerate after the last velocity command from ROS controller.", 1.0, 0.0, 86400.0)
gen.add("decelerate_duration", double_t, 1018, "Duration in seconds while decreasing velocity command from ROS controller to 0m/s.", 1.0, 0.0, 86400.0)
gen.add("velocity_decay", double_t, 1019, "Decay ratio of velocity.", 0.5, 0.0, 1.0) //速度指令衰减比例
rc_sets = gen.add_group("remote_controller_config")
rc_sets.add("action_0", int_t, 1020, "Action 0 on remote controller.", 514, 16, 65535) # SHAKE HAND 挥手
rc_sets.add("action_1", int_t, 1020, "Action 1 on remote controller.", 273, 16, 65535) # SWAYING 身体左右摇摆
rc_sets.add("action_2", int_t, 1020, "Action 2 on remote controller.", 258, 16, 65535) # JUMP_ROUND 跳跃旋转
rc_sets.add("action_3", int_t, 1020, "Action 3 on remote controller.", 18, 16, 65535) # STAND_ON_TWO_LEGS 两腿站立
6、主题关联
官方附带的一张图
后续,将数理几个关键的参数设置以及主要的主题数据,例如/body_status,/dog_ctrl_state,/dog_ctrl_config,/joint_states,/robot_system_info,/robot_ctrl_status等关键主题与控制算法和状态估计之间的关系。为后期的自主导航提供基础。