From d5b3da58daa6caf3b62b41437dc50944c7d9e852 Mon Sep 17 00:00:00 2001 From: Ruixiang Du Date: Mon, 1 Jun 2020 18:45:56 +0800 Subject: [PATCH] added catkin support --- CMakeLists.txt | 47 +++++++++++++++++++++++++++- package.xml | 24 ++++++++++++++ src/apps/hunter_demo/hunter_demo.cpp | 26 +++++++-------- 3 files changed, 83 insertions(+), 14 deletions(-) create mode 100644 package.xml diff --git a/CMakeLists.txt b/CMakeLists.txt index 5f05bf3..c932acf 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,9 @@ cmake_minimum_required(VERSION 3.1.0) project(wrp_sdk) +# Find catkin +find_package(catkin REQUIRED) + # generate symbols for IDE indexer set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/devel) @@ -51,4 +54,46 @@ add_subdirectory(src) if(BUILD_TESTS) add_subdirectory(unit_tests) -endif() \ No newline at end of file +endif() + +## Export catkin targets +set(EXPORTED_LIBS + asyncio + stopwatch + scout_protocol + scoutbase + hunter_protocol + hunterbase +) +set(INCLUDE_DIRS + src/common/async_io/asio + src/common/async_io/include + src/common/utilities/stopwatch/include + src/scout_sdk/scout_protocol/include + src/scout_sdk/scout_base/include + src/hunter_sdk/hunter_protocol/include + src/hunter_sdk/hunter_base/include +) +catkin_package( + LIBRARIES ${EXPORTED_LIBS} + INCLUDE_DIRS ${INCLUDE_DIRS} + # DEPENDS rt pthread +) + +## Add catkin install targets +# install(TARGETS ${EXPORTED_LIBS} +# RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} +# LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} +# ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}) + +# install(DIRECTORY include/${PROJECT_NAME}/ +# DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}) + +# install(DIRECTORY asio/asio +# DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}) + +# install(FILES asio/asio.hpp +# DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}) + +# install(DIRECTORY scripts +# DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}) \ No newline at end of file diff --git a/package.xml b/package.xml new file mode 100644 index 0000000..801975f --- /dev/null +++ b/package.xml @@ -0,0 +1,24 @@ + + + wrp_sdk + 0.3.3 + Weston Robot Platform SDK + + Ruixiang Du + Ruixiang Du + + BSD + + TODO + TODO + TODO + + catkin + roscpp + std_msgs + sensor_msgs + roscpp + std_msgs + sensor_msgs + + diff --git a/src/apps/hunter_demo/hunter_demo.cpp b/src/apps/hunter_demo/hunter_demo.cpp index be1520e..c22f8eb 100644 --- a/src/apps/hunter_demo/hunter_demo.cpp +++ b/src/apps/hunter_demo/hunter_demo.cpp @@ -23,13 +23,13 @@ int main(int argc, char **argv) } else { - std::cout << "Usage: app_scout_demo " << std::endl - << "Example 1: ./app_scout_demo can0" << std::endl; + std::cout << "Usage: app_hunter_demo " << std::endl + << "Example 1: ./app_hunter_demo can0" << std::endl; return -1; } - HunterBase scout; - scout.Connect(device_name); + HunterBase hunter; + hunter.Connect(device_name); int count = 0; while (true) @@ -38,45 +38,45 @@ int main(int argc, char **argv) if (count < 5) { std::cout << "Motor: 0.2, 0.0" << std::endl; - scout.SetMotionCommand(0.2, 0.0); + hunter.SetMotionCommand(0.2, 0.0); } else if (count < 10) { std::cout << "Motor: 0.8, 0.3" << std::endl; - scout.SetMotionCommand(0.8, 0.3); + hunter.SetMotionCommand(0.8, 0.3); } else if (count < 15) { std::cout << "Motor: 1.5, 0.5" << std::endl; - scout.SetMotionCommand(1.5, 0.5); + hunter.SetMotionCommand(1.5, 0.5); } else if (count < 20) { std::cout << "Motor: 1.0, 0.3" << std::endl; - scout.SetMotionCommand(1.0, 0.3); + hunter.SetMotionCommand(1.0, 0.3); } else if (count < 25) { std::cout << "Motor: 0.0, 0.0" << std::endl; - scout.SetMotionCommand(0.0, 0.0); + hunter.SetMotionCommand(0.0, 0.0); } else if (count < 30) { std::cout << "Motor: -0.5, -0.3" << std::endl; - scout.SetMotionCommand(-0.5, -0.3); + hunter.SetMotionCommand(-0.5, -0.3); } else if (count < 35) { std::cout << "Motor: -1.0, -0.5" << std::endl; - scout.SetMotionCommand(-1.0, -0.5); + hunter.SetMotionCommand(-1.0, -0.5); } else if (count < 40) { std::cout << "Motor: 0.0, 0.0," << std::endl; - scout.SetMotionCommand(0.0, 0.0); + hunter.SetMotionCommand(0.0, 0.0); } - auto state = scout.GetHunterState(); + auto state = hunter.GetHunterState(); std::cout << "-------------------------------" << std::endl; std::cout << "count: " << count << std::endl; std::cout << "control mode: " << static_cast(state.control_mode) << " , base state: " << static_cast(state.base_state) << std::endl;