From 8bc209f33b87be3405c90ba52dada0d18371dfaa Mon Sep 17 00:00:00 2001 From: llexGe Date: Fri, 21 Oct 2022 14:28:23 +0800 Subject: [PATCH] fix udp bug Make it compatible with SDK 3.8.0 --- unitree_legged_real/CMakeLists.txt | 9 ++++----- unitree_legged_real/ipconfig.sh | 8 -------- unitree_legged_real/src/exe/ros_udp.cpp | 6 ++++-- unitree_legged_real/src/exe/twist_sub.cpp | 8 +++++--- 4 files changed, 13 insertions(+), 18 deletions(-) delete mode 100755 unitree_legged_real/ipconfig.sh diff --git a/unitree_legged_real/CMakeLists.txt b/unitree_legged_real/CMakeLists.txt index e01901f..d0f1fff 100755 --- a/unitree_legged_real/CMakeLists.txt +++ b/unitree_legged_real/CMakeLists.txt @@ -17,15 +17,13 @@ if("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "x86_64.*") else() set(ARCH arm64) endif() -set(LEGGED_SDK_NAME -pthread libunitree_legged_sdk_${ARCH}.so lcm) -set(EXTRA_LIBS ${LEGGED_SDK_NAME} lcm) +link_directories(${CMAKE_SOURCE_DIR}/unitree_legged_sdk/lib/cpp/${ARCH}) +set(EXTRA_LIBS -pthread libunitree_legged_sdk.so) set(CMAKE_CXX_FLAGS "-O3 -fPIC") - - include_directories( include ${catkin_INCLUDE_DIRS} @@ -34,7 +32,7 @@ include_directories( -link_directories(${CMAKE_SOURCE_DIR}/unitree_legged_sdk/lib) + @@ -62,3 +60,4 @@ add_dependencies(control_via_keyboard ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catk add_executable(twist_sub src/exe/twist_sub.cpp) target_link_libraries(twist_sub ${EXTRA_LIBS} ${catkin_LIBRARIES}) add_dependencies(twist_sub ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS}) + diff --git a/unitree_legged_real/ipconfig.sh b/unitree_legged_real/ipconfig.sh deleted file mode 100755 index 611374a..0000000 --- a/unitree_legged_real/ipconfig.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -sudo ifconfig lo multicast -sudo route add -net 224.0.0.0 netmask 240.0.0.0 dev lo - -sudo ifconfig enx000ec6612921 down -sudo ifconfig enx000ec6612921 up 192.168.123.162 netmask 255.255.255.0 - diff --git a/unitree_legged_real/src/exe/ros_udp.cpp b/unitree_legged_real/src/exe/ros_udp.cpp index 1a3daa9..f467aa1 100644 --- a/unitree_legged_real/src/exe/ros_udp.cpp +++ b/unitree_legged_real/src/exe/ros_udp.cpp @@ -24,8 +24,10 @@ public: public: Custom() - : low_udp(LOWLEVEL), - high_udp(8090, "192.168.123.161", 8082, sizeof(HighCmd), sizeof(HighState)) + : + // low_udp(LOWLEVEL), + low_udp(LOWLEVEL, 8091, "192.168.123.10", 8007), + high_udp(8090, "192.168.123.161", 8082, sizeof(HighCmd), sizeof(HighState)) { high_udp.InitCmdData(high_cmd); low_udp.InitCmdData(low_cmd); diff --git a/unitree_legged_real/src/exe/twist_sub.cpp b/unitree_legged_real/src/exe/twist_sub.cpp index 10c2689..7664a09 100644 --- a/unitree_legged_real/src/exe/twist_sub.cpp +++ b/unitree_legged_real/src/exe/twist_sub.cpp @@ -24,8 +24,10 @@ public: public: Custom() - : low_udp(LOWLEVEL), - high_udp(8090, "192.168.123.161", 8082, sizeof(HighCmd), sizeof(HighState)) + : + // low_udp(LOWLEVEL), + low_udp(LOWLEVEL, 8091, "192.168.123.10", 8007), + high_udp(8090, "192.168.123.161", 8082, sizeof(HighCmd), sizeof(HighState)) { high_udp.InitCmdData(high_cmd); low_udp.InitCmdData(low_cmd); @@ -107,4 +109,4 @@ int main(int argc, char **argv) ros::spin(); return 0; -} \ No newline at end of file +}