From 52619d43c9086d5e9123ea6975b8fe57cb4dad98 Mon Sep 17 00:00:00 2001 From: davood-dorostkar Date: Tue, 17 Oct 2023 07:52:09 +0330 Subject: [PATCH 1/2] fix: cmake issues with google test repo download, qt5 path finding --- common/CMakeLists.txt | 78 ++++++++++++++-------------- common/DownloadProject.cmake | 2 +- scripts/find_qt_path.sh | 4 +- scripts/lcm-log2smat/find_qt_path.sh | 6 +++ sim/CMakeLists.txt | 38 +++++++------- 5 files changed, 66 insertions(+), 62 deletions(-) create mode 100755 scripts/lcm-log2smat/find_qt_path.sh diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 18dc8762f..dacfa53c0 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -1,55 +1,55 @@ # Source/Include files include_directories(".") -include_directories("include/" ) # common includes -include_directories("/usr/local/include/lcm/") # lcm includes +include_directories("include/") # common includes +include_directories("/usr/local/include/lcm/") # lcm includes include_directories("../lcm-types/cpp/") -include_directories("../third-party/inih") # inih includes -include_directories("../third-party/osqp/include") # osqp includes +include_directories("../third-party/inih") # inih includes +include_directories("../third-party/osqp/include") # osqp includes include_directories("../third-party/ParamHandler") -include_directories("/usr/local/include/eigen3") # lcm includes +include_directories("/usr/local/include/eigen3") # lcm includes include_directories("FootstepPlanner") include_directories(${CMAKE_BINARY_DIR}) include_directories(${PROJECT_SOURCE_DIR}) -file(GLOB_RECURSE sources "src/*.cpp") # common library cpp files +file(GLOB_RECURSE sources "src/*.cpp") # common library cpp files # Library -add_library(biomimetics SHARED ${sources}) # produce a library used by sim/robot +add_library(biomimetics SHARED ${sources}) # produce a library used by sim/robot target_link_libraries(biomimetics inih dynacore_param_handler JCQP osqp) if(CMAKE_SYSTEM_NAME MATCHES Linux) -# Pull in Google Test -include(CTest) -if (CMAKE_VERSION VERSION_LESS 3.2) - set(UPDATE_DISCONNECTED_IF_AVAILABLE "") -else() - set(UPDATE_DISCONNECTED_IF_AVAILABLE "UPDATE_DISCONNECTED 1") -endif() -include(DownloadProject.cmake) -download_project(PROJ googletest - GIT_REPOSITORY https://github.com/google/googletest.git - GIT_TAG master - ${UPDATE_DISCONNECTED_IF_AVAILABLE} - QUIET -) -set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) -add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR}) -if (CMAKE_VERSION VERSION_LESS 2.8.11) - include_directories("${gtest_SOURCE_DIR}/include" - "${gmock_SOURCE_DIR}/include") -endif() - -# Test -file(GLOB_RECURSE test_sources "test/test_*.cpp") # test cpp files -add_executable(test-common ${test_sources}) -target_link_libraries(test-common gtest gmock_main lcm rt inih osqp dynacore_param_handler pthread biomimetics) -target_link_libraries(test-common Goldfarb_Optimizer) -target_link_libraries(test-common JCQP) - - -add_test(NAME example_test COMMAND test-common) - + # Pull in Google Test + include(CTest) + + if(CMAKE_VERSION VERSION_LESS 3.2) + set(UPDATE_DISCONNECTED_IF_AVAILABLE "") + else() + set(UPDATE_DISCONNECTED_IF_AVAILABLE "UPDATE_DISCONNECTED 1") + endif() + + include(DownloadProject.cmake) + download_project(PROJ googletest + GIT_REPOSITORY https://github.com/google/googletest.git + GIT_TAG main + ${UPDATE_DISCONNECTED_IF_AVAILABLE} + QUIET + ) + set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) + add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR}) + + if(CMAKE_VERSION VERSION_LESS 2.8.11) + include_directories("${gtest_SOURCE_DIR}/include" + "${gmock_SOURCE_DIR}/include") + endif() + + # Test + file(GLOB_RECURSE test_sources "test/test_*.cpp") # test cpp files + add_executable(test-common ${test_sources}) + target_link_libraries(test-common gtest gmock_main lcm rt inih osqp dynacore_param_handler pthread biomimetics) + target_link_libraries(test-common Goldfarb_Optimizer) + target_link_libraries(test-common JCQP) + + add_test(NAME example_test COMMAND test-common) endif(CMAKE_SYSTEM_NAME MATCHES Linux) # Our libraries add_subdirectory(FootstepPlanner) - diff --git a/common/DownloadProject.cmake b/common/DownloadProject.cmake index e300f4265..5e38ce92a 100644 --- a/common/DownloadProject.cmake +++ b/common/DownloadProject.cmake @@ -79,7 +79,7 @@ # include(DownloadProject) # download_project(PROJ googletest # GIT_REPOSITORY https://github.com/google/googletest.git -# GIT_TAG master +# GIT_TAG main # UPDATE_DISCONNECTED 1 # QUIET # ) diff --git a/scripts/find_qt_path.sh b/scripts/find_qt_path.sh index ab60620db..5d6790227 100755 --- a/scripts/find_qt_path.sh +++ b/scripts/find_qt_path.sh @@ -1,6 +1,6 @@ #/bin/bash -QT_VER="$(ls ~/Qt/ | grep 5 -m1)" +QT_VER="$(ls ~/Qt* | grep 5 -m1)" -printf "${HOME}/Qt/${QT_VER}/gcc_64/" +printf "${HOME}/Qt${QT_VER}/${QT_VER}/gcc_64/" diff --git a/scripts/lcm-log2smat/find_qt_path.sh b/scripts/lcm-log2smat/find_qt_path.sh new file mode 100755 index 000000000..5d6790227 --- /dev/null +++ b/scripts/lcm-log2smat/find_qt_path.sh @@ -0,0 +1,6 @@ +#/bin/bash + +QT_VER="$(ls ~/Qt* | grep 5 -m1)" + +printf "${HOME}/Qt${QT_VER}/${QT_VER}/gcc_64/" + diff --git a/sim/CMakeLists.txt b/sim/CMakeLists.txt index a7f6ad59b..95c6777e0 100644 --- a/sim/CMakeLists.txt +++ b/sim/CMakeLists.txt @@ -3,17 +3,17 @@ project(sim) SET(CMAKE_INCLUDE_CURRENT_DIR ON) - execute_process(COMMAND ${CMAKE_SOURCE_DIR}/scripts/find_qt_path.sh OUTPUT_VARIABLE CMAKE_PREFIX_PATH_1) SET(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH_1}) -# message("CMAKE_PREFIX_PATH: ${CMAKE_PREFIX_PATH}") +# message("CMAKE_PREFIX_PATH: ${CMAKE_PREFIX_PATH}") if(POLICY CMP0071) cmake_policy(SET CMP0071 OLD) endif() # Instruct CMake to run moc automatically when needed set(CMAKE_AUTOMOC ON) + # Create code from a list of Qt designer ui files set(CMAKE_AUTOUIC ON) find_package(Qt5Core CONFIG REQUIRED) @@ -23,20 +23,20 @@ message(STATUS ${QtCore_location}) find_package(Qt5Gui CONFIG REQUIRED) set(QOBJECT_HEADERS - include/Graphics3D.h - include/GameController.h - include/SimControlPanel.h - include/JoystickTest.h) -# include/main_window.h -# include/gamepad_monitor.h -# include/spi_debug.h) - + include/Graphics3D.h + include/GameController.h + include/SimControlPanel.h + include/JoystickTest.h) + +# include/main_window.h +# include/gamepad_monitor.h +# include/spi_debug.h) QT5_WRAP_CPP(tst_hdr_moc ${QOBJECT_HEADERS}) include_directories("include/") include_directories("../common/include/") include_directories("../lcm-types/cpp") -include_directories("/usr/local/include/lcm/") # lcm includes +include_directories("/usr/local/include/lcm/") # lcm includes include_directories("../third-party/ParamHandler") include_directories(${CMAKE_BINARY_DIR}) file(GLOB sources "src/*.cpp") @@ -50,16 +50,14 @@ find_package(OpenGL REQUIRED) include_directories(${OPENGL_INCLUDE_DIR}) add_executable(sim ${sources} ${tst_hdr_moc}) -target_link_libraries(sim biomimetics pthread lcm inih dynacore_param_handler - Qt5::Widgets Qt5::Core Qt5::Gui Qt5::Gamepad ${QT_LIBRARIES} ${OPENGL_LIBRARIES}) +target_link_libraries(sim biomimetics pthread lcm inih dynacore_param_handler + Qt5::Widgets Qt5::Core Qt5::Gui Qt5::Gamepad ${QT_LIBRARIES} ${OPENGL_LIBRARIES}) -if (CMAKE_SYSTEM_NAME MATCHES Linux) +if(CMAKE_SYSTEM_NAME MATCHES Linux) target_link_libraries(sim rt ${GLUT_glut_LIBRARIES}) - include (CheckIncludeFileCXX) -endif (CMAKE_SYSTEM_NAME MATCHES Linux) + include(CheckIncludeFileCXX) +endif(CMAKE_SYSTEM_NAME MATCHES Linux) -if (APPLE) +if(APPLE) target_link_libraries(sim "-framework GLUT") -endif (APPLE) - - +endif(APPLE) From a7148fad9138fdef50592d4913be1507ddb3840b Mon Sep 17 00:00:00 2001 From: davood-dorostkar Date: Wed, 18 Oct 2023 23:29:48 +0330 Subject: [PATCH 2/2] fix: eigen3 path in cmake --- common/CMakeLists.txt | 2 +- file_list.txt | 1 + scripts/network_config.py | 78 ------------------------------ scripts/setup_network_mc.py | 38 --------------- user/MIT_Controller/CMakeLists.txt | 12 ++--- 5 files changed, 8 insertions(+), 123 deletions(-) create mode 100644 file_list.txt delete mode 100755 scripts/network_config.py delete mode 100644 scripts/setup_network_mc.py diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index dacfa53c0..7c3b72dee 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -6,7 +6,7 @@ include_directories("../lcm-types/cpp/") include_directories("../third-party/inih") # inih includes include_directories("../third-party/osqp/include") # osqp includes include_directories("../third-party/ParamHandler") -include_directories("/usr/local/include/eigen3") # lcm includes +include_directories("/usr/include/eigen3") # lcm includes include_directories("FootstepPlanner") include_directories(${CMAKE_BINARY_DIR}) include_directories(${PROJECT_SOURCE_DIR}) diff --git a/file_list.txt b/file_list.txt new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/file_list.txt @@ -0,0 +1 @@ + diff --git a/scripts/network_config.py b/scripts/network_config.py deleted file mode 100755 index dd48a7f50..000000000 --- a/scripts/network_config.py +++ /dev/null @@ -1,78 +0,0 @@ -#!/usr/bin/env python3 - -from os.path import expanduser -import netifaces -import sys -import subprocess - - -def get_saved_interface_name(): - home = expanduser("~") - name = "" - try: - with open(home + "/.cheetah_network.txt"): - name = f.read().split()[0] - except: - name = "" - return name - - -def get_likely_iface(): - ifs = netifaces.interfaces() - print("Found {} interfaces:".format(len(ifs))) - - if_to_addrs = {} - - for i in ifs: - if_to_addrs[i] = [] - if netifaces.AF_INET in netifaces.ifaddresses(i).keys(): - for ad in netifaces.ifaddresses(i)[netifaces.AF_INET]: - if_to_addrs[i].append(ad['addr']) - - - for i in range(len(ifs)): - print(" [{}] : {} : {}".format(i, ifs[i], if_to_addrs[ifs[i]])) - - found_10_ip = 0 - selected_if = "" - - - for i in ifs: - match_string = "10.0.0." - if len(if_to_addrs[i]) > 0 and if_to_addrs[i][0][:len(match_string)] == match_string: - found_10_ip = found_10_ip + 1 - selected_if = i - - if found_10_ip == 0: - print("None of the network adapters look correct. Make sure you have set a 10.0.0.x static ip!") - return "" - - elif found_10_ip == 1: - print("The adapter {} seems correct".format(selected_if)) - return selected_if - - else: - print("Found {} possible adapters, giving up".format(found_10_ip)) - return "" - - - -def main(): - name = get_saved_interface_name() - if not name: - print("Didn't find saved interface, searching...") - name = get_likely_iface() - if not name: - sys.exit("Failed to find network adapter name") - else: - print("found saved interface {}".format(name)) - - print("setup for interface {}".format(name)) - subprocess.call(['sudo', 'ifconfig', name, 'multicast']) - subprocess.call(['sudo', 'route', 'add', '-net', '224.0.0.0', 'netmask', '240.0.0.0', 'dev', name]) - - - return 0 - - -main() diff --git a/scripts/setup_network_mc.py b/scripts/setup_network_mc.py deleted file mode 100644 index c5b5be2a0..000000000 --- a/scripts/setup_network_mc.py +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env python -import subprocess -import sys - -# first, determine which mini-cheetah we are - -mc_id = -1 - -try: - with open('/home/user/mc_id') as f: - mc_id = int(f.read().split()[0]) -except: - sys.exit("Mini cheetah number is not set.") - -print("Setup for mini cheetah {}".format(mc_id)) - -# next, array of network adapters -adapter_names = { 0 : "enxa0cec8ca8e52", - 1 : "enxa0cec8ca8e63", - 2 : "enxa0cec8ca8ec2", - 3 : "enxa0cec8ca8e6f", - 4 : "enxa0cec8ca8e6e", - 5 : "enxa0cec8ca8e87", - 6 : "enxa0cec8ca8eed", - 7 : "enxa0cec8ca8e88", - 8 : "enxa0cec8ca8f20", - 9 : "enxa0cec8ca8e71"} - - -if mc_id in adapter_names.keys(): - adapter_name = adapter_names[mc_id] - print("adapter is {}".format(adapter_name)) - subprocess.call(['sudo', 'ifconfig', adapter_name, 'multicast']) - subprocess.call(['sudo', 'route', 'add', '-net', '224.0.0.0', 'netmask', '240.0.0.0', 'dev', adapter_name]) -else: - print("No adpater for this mini cheetah ID, add it in setup_network_mc.py") - - diff --git a/user/MIT_Controller/CMakeLists.txt b/user/MIT_Controller/CMakeLists.txt index 5bcde5c45..62454c89c 100644 --- a/user/MIT_Controller/CMakeLists.txt +++ b/user/MIT_Controller/CMakeLists.txt @@ -8,16 +8,16 @@ include_directories(SYSTEM "../../third-party/qpOASES/include") include_directories("../../third-party/ParamHandler") include_directories("../../lcm-types/cpp") -include_directories("/usr/local/include/lcm/") # lcm includes -include_directories("/usr/local/include/eigen3") # lcm includes +include_directories("/usr/local/include/lcm/") # lcm includes +include_directories("/usr/include/eigen3") # lcm includes include_directories(${CMAKE_BINARY_DIR}) include_directories(${PROJECT_SOURCE_DIR}) file(GLOB_RECURSE sources -"./*.cpp" -"FSM_States/*.cpp" -"Controllers/BalanceController/*.cpp" -"Controllers/convexMPC/*.cpp") + "./*.cpp" + "FSM_States/*.cpp" + "Controllers/BalanceController/*.cpp" + "Controllers/convexMPC/*.cpp") add_subdirectory(Controllers/WBC) add_subdirectory(Controllers/WBC_Ctrl)