From 33c618b88e90bf382ce0f58a139eeab5a95dbd6b Mon Sep 17 00:00:00 2001 From: fan-ziqi Date: Fri, 29 Mar 2024 22:29:28 +0800 Subject: [PATCH] fix something --- README_CN.md | 14 ++++++++++++-- .../library/cyberdog_motor_sdk/CMakeLists.txt | 6 +++--- src/rl_sar/scripts/init_cyberdog.sh | 7 +++++++ src/rl_sar/scripts/kill_cyberdog.sh | 6 ++++++ src/rl_sar/src/rl_real_cyberdog.cpp | 12 ++++++------ 5 files changed, 34 insertions(+), 11 deletions(-) create mode 100644 src/rl_sar/scripts/init_cyberdog.sh create mode 100644 src/rl_sar/scripts/kill_cyberdog.sh diff --git a/README_CN.md b/README_CN.md index 868d010..49f1172 100644 --- a/README_CN.md +++ b/README_CN.md @@ -104,9 +104,8 @@ rosrun rl_sar rl_real ping 192.168.55.100 #本地PC被分配的ip ssh mi@192.168.55.1 #登录nx应用板 ,密码123 athena_version -v #核对当前版本>=1.0.0.94 - ssh root@192.168.55.233 #登录运动控制板 ``` - + 2. 进入电机控制模式 修改配置开关,激活用户控制模式,运行用户自己的控制器: @@ -138,6 +137,17 @@ rosrun rl_sar rl_real ``` 按下键盘上的**0**键让机器人切换到默认站起姿态,按下**P**键切换到RL控制模式,任意状态按下**1**键切换到最初的趴下姿态。WS控制x,AD控制yaw,JL控制y。 +4. 重启 + + ```bash + # 重启运控程序: + ssh root@192.168.55.233 "ps | grep -E 'Example_MotorCtrl' | grep -v grep | awk '{print \$1}' | xargs kill -9" #需先于主进程暂停,避免急停 + ssh root@192.168.55.233 "ps | grep -E 'manager|ctrl|imu_online' | grep -v grep | awk '{print \$1}' | xargs kill -9" + ssh root@192.168.55.233 "export LD_LIBRARY_PATH=/mnt/UDISK/robot-software/build;/mnt/UDISK/manager /mnt/UDISK/ >> /mnt/UDISK/manager_log/manager.log 2>&1 &" + # 重启运控板系统: + ssh root@192.168.55.233 "reboot" + ``` + 注:lcm通信若不成功,无法正常激活电机控制模式,log提示:Motor control mode has not been activated successfully diff --git a/src/rl_sar/library/cyberdog_motor_sdk/CMakeLists.txt b/src/rl_sar/library/cyberdog_motor_sdk/CMakeLists.txt index c2a90b3..5c6dba3 100644 --- a/src/rl_sar/library/cyberdog_motor_sdk/CMakeLists.txt +++ b/src/rl_sar/library/cyberdog_motor_sdk/CMakeLists.txt @@ -19,6 +19,6 @@ target_link_libraries(cyberdog_motor_sdk lcm ) -## compile use code -#add_executable(Example_MotorCtrl src/Example_MotorCtrl.cpp) -#target_link_libraries(Example_MotorCtrl cyberdog_motor_sdk) \ No newline at end of file +# compile use code +add_executable(Example_MotorCtrl src/Example_MotorCtrl.cpp) +target_link_libraries(Example_MotorCtrl cyberdog_motor_sdk) \ No newline at end of file diff --git a/src/rl_sar/scripts/init_cyberdog.sh b/src/rl_sar/scripts/init_cyberdog.sh new file mode 100644 index 0000000..99080d2 --- /dev/null +++ b/src/rl_sar/scripts/init_cyberdog.sh @@ -0,0 +1,7 @@ +#!/bin/bash +set -e +set -u + +ifconfig | grep -B 1 192.168.55.100 | grep "flags"| cut -d ':' -f1 #获取该ip对应网络设备,一般为usb0 +sudo ifconfig usb0 multicast #usb0替换为上文获取的168.55.100对应网络设备,并配为多播 +sudo route add -net 224.0.0.0 netmask 240.0.0.0 dev usb0 #添加路由表,usb0对应替换 \ No newline at end of file diff --git a/src/rl_sar/scripts/kill_cyberdog.sh b/src/rl_sar/scripts/kill_cyberdog.sh new file mode 100644 index 0000000..bafe51c --- /dev/null +++ b/src/rl_sar/scripts/kill_cyberdog.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -e +set -u + +ssh root@192.168.55.233 "ps | grep -E 'manager|ctrl|imu_online' | grep -v grep | awk '{print \$1}' | xargs kill -9" +ssh root@192.168.55.233 "export LD_LIBRARY_PATH=/mnt/UDISK/robot-software/build;/mnt/UDISK/manager /mnt/UDISK/ >> /mnt/UDISK/manager_log/manager.log 2>&1 &" \ No newline at end of file diff --git a/src/rl_sar/src/rl_real_cyberdog.cpp b/src/rl_sar/src/rl_real_cyberdog.cpp index eed7300..8cadd43 100644 --- a/src/rl_sar/src/rl_real_cyberdog.cpp +++ b/src/rl_sar/src/rl_real_cyberdog.cpp @@ -20,8 +20,8 @@ RL_Real::RL_Real() : CustomInterface(500) this->params.num_observations = 45; this->params.clip_obs = 100.0; this->params.clip_actions = 100.0; - this->params.damping = 0.5; - this->params.stiffness = 20; + this->params.damping = 2.0; + this->params.stiffness = 50; this->params.d_gains = torch::ones(12) * this->params.damping; this->params.p_gains = torch::ones(12) * this->params.stiffness; this->params.action_scale = 0.25; @@ -110,8 +110,8 @@ void RL_Real::RobotControl() { cyberdogCmd.q_des[i] = (1 - getup_percent) * now_pos[i] + getup_percent * params.default_dof_pos[0][dof_mapping[i]].item(); cyberdogCmd.qd_des[i] = 0; - cyberdogCmd.kp_des[i] = 50; - cyberdogCmd.kd_des[i] = 3; + cyberdogCmd.kp_des[i] = 200; + cyberdogCmd.kd_des[i] = 10; cyberdogCmd.tau_des[i] = 0; } printf("getting up %.3f%%\r", getup_percent*100.0); @@ -178,8 +178,8 @@ void RL_Real::RobotControl() { cyberdogCmd.q_des[i] = (1 - getdown_percent) * now_pos[i] + getdown_percent * start_pos[i]; cyberdogCmd.qd_des[i] = 0; - cyberdogCmd.kp_des[i] = 50; - cyberdogCmd.kd_des[i] = 3; + cyberdogCmd.kp_des[i] = 200; + cyberdogCmd.kd_des[i] = 10; cyberdogCmd.tau_des[i] = 0; } printf("getting down %.3f%%\r", getdown_percent*100.0);