diff --git a/.github/workflows/default.yml b/.github/workflows/default.yml index 3cb6e3e..485ce16 100644 --- a/.github/workflows/default.yml +++ b/.github/workflows/default.yml @@ -10,7 +10,7 @@ on: - "**" env: - VERSION: "1.2.*" + VERSION: "1.3.*" jobs: build: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f17e119..754c942 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,7 +6,7 @@ on: - 'main' env: - TAG_VERSION: "1.2.x" + TAG_VERSION: "1.3.x" jobs: tag-release: diff --git a/CMakeLists.txt b/CMakeLists.txt index 32f94eb..5a999b1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8.3) +cmake_minimum_required(VERSION 3.10.2) project(wrp_sdk_sample) ## Set compiler to use c++ 14 features @@ -18,7 +18,7 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR} set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}) ## Find wrp_sdk and its dependent package wrp_zbus -find_package(wrp_sdk REQUIRED) +find_package(wrp_sdk 1.3.0...<1.4.0 REQUIRED) find_package(PkgConfig REQUIRED) pkg_check_modules(LelyIO QUIET IMPORTED_TARGET liblely-io2) diff --git a/sample/mobile_base/CMakeLists.txt b/sample/mobile_base/CMakeLists.txt index 68c99a0..72f9c5a 100644 --- a/sample/mobile_base/CMakeLists.txt +++ b/sample/mobile_base/CMakeLists.txt @@ -1,8 +1,11 @@ add_executable(sample_handshake_demo handshake_demo.cpp) -target_link_libraries(sample_handshake_demo westonrobot::wrp_sdk) +target_link_libraries(sample_handshake_demo westonrobot::wrp_sdk_robot) add_executable(sample_mobilebase_demo mobilebase_demo.cpp) -target_link_libraries(sample_mobilebase_demo westonrobot::wrp_sdk) +target_link_libraries(sample_mobilebase_demo westonrobot::wrp_sdk_robot) add_executable(sample_agilex_v2_robot_demo agilex_v2_robot_demo.cpp) -target_link_libraries(sample_agilex_v2_robot_demo westonrobot::wrp_sdk) \ No newline at end of file +target_link_libraries(sample_agilex_v2_robot_demo westonrobot::wrp_sdk_robot) + +add_executable(sample_robooterx_wheelchair_demo robooterx_wheelchair_demo.cpp) +target_link_libraries(sample_robooterx_wheelchair_demo westonrobot::wrp_sdk_robot) \ No newline at end of file diff --git a/sample/mobile_base/robooterx_wheelchair_demo.cpp b/sample/mobile_base/robooterx_wheelchair_demo.cpp new file mode 100644 index 0000000..2338c25 --- /dev/null +++ b/sample/mobile_base/robooterx_wheelchair_demo.cpp @@ -0,0 +1,104 @@ +/** + * @file robooterx_wheelchair_demo.cpp + * @brief Robooterx Wheelchair API usage demo + * @date 03-05-2024 + * + * Demo showing the Robooterx Wheelchair running Robooterx's protocol API. + * + * @copyright Copyright (c) 2024 Weston Robot Pte. Ltd. + */ + +#include + +#include +#include +#include + +#include "wrp_sdk/mobile_base/bangbang/robooterx_base_adapter.hpp" + +int main(int argc, char const *argv[]) { + std::string device_name; + + if (argc == 2) { + device_name = {argv[1]}; + std::cout << "Specified CAN: " << device_name << std::endl; + } else { + std::cout << "Usage: sample_robooterx_wheelchair_demo " + << std::endl + << "Example 1: ./sample_robooterx_wheelchair_demo can0" + << std::endl; + return -1; + } + + westonrobot::RobooterXBaseAdapter base; + base.Connect(device_name); + + if (base.RequestControl(500) != + westonrobot::HandshakeReturnCode::kControlAcquired) { + std::cout << "Failed to gain control" << std::endl; + return -1; + } + + while (true) { + std::cout << "Checking robot base status..." << std::endl; + if (base.IsRobotBaseAlive()) { + std::cout << "Robot base is alive." << std::endl; + } else { + std::cout << "Robot base is not alive." << std::endl; + } + + if (base.SdkHasControlToken()) { + std::cout << "Control is acquired." << std::endl; + } else { + std::cout << "Control is not acquired." << std::endl; + } + + westonrobot::RcState rc_state = base.GetRcState(); + std::cout << "RC channel state: " << std::endl; + std::cout << " Axis 1 (Horizontal): " << rc_state.axes[0] << std::endl; + std::cout << " Axis 2 (Vertical):" << rc_state.axes[1] << std::endl; + std::cout << " Button 1 (Newbie mode): " << rc_state.buttons[0] + << std::endl; + + westonrobot::MotionState motion_state = base.GetMotionState(); + std::cout << "Beginner mode enabled: " << motion_state.assisted_mode_enabled + << std::endl; + + westonrobot::Odometry odom = base.GetOdometry(); + std::cout << "Odometry: " << std::endl; + std::cout << " Linear X: " << odom.linear.x << " m/s" << std::endl; + std::cout << " Angular Z: " << odom.angular.z << " rad/s" << std::endl; + + westonrobot::SystemState system_state = base.GetSystemState(); + std::cout << "Base state: " << std::endl; + std::cout << " Operational State: " + << static_cast(system_state.operational_state) << std::endl; + std::cout << " Control State: " + << static_cast(system_state.control_state) << std::endl; + + westonrobot::BatteryState bms_data = base.GetBatteryState(); + std::cout << "BMS: " << std::endl; + std::cout << " SOC: " << bms_data.percentage << "%" << std::endl; + + std::cout << "Controlling robot base..." << std::endl; + + static int mode = 1; + base.SetMotionMode(static_cast(mode++)); + if (mode > 5) { + mode = 1; + } + + westonrobot::MotionCommand cmd; + cmd.linear.x = 0.5; + cmd.angular.z = 0.0; + // base.SetMotionCommand(cmd); + + std::cout << "=========================================" << std::endl; + + usleep(100000); + } + + base.RenounceControl(500); + + return 0; +} diff --git a/sample/peripheral/CMakeLists.txt b/sample/peripheral/CMakeLists.txt index d07a05f..be06bb9 100644 --- a/sample/peripheral/CMakeLists.txt +++ b/sample/peripheral/CMakeLists.txt @@ -1,11 +1,11 @@ add_executable(sample_gps_receiver_demo gps_receiver_demo.cpp) -target_link_libraries(sample_gps_receiver_demo westonrobot::wrp_sdk) +target_link_libraries(sample_gps_receiver_demo westonrobot::wrp_sdk_peripheral) add_executable(sample_imu_sensor_demo imu_sensor_demo.cpp) -target_link_libraries(sample_imu_sensor_demo westonrobot::wrp_sdk) +target_link_libraries(sample_imu_sensor_demo westonrobot::wrp_sdk_peripheral westonrobot::wrp_sdk_canopen) add_executable(sample_ultrasonic_sensor_demo ultrasonic_sensor_demo.cpp) -target_link_libraries(sample_ultrasonic_sensor_demo westonrobot::wrp_sdk) +target_link_libraries(sample_ultrasonic_sensor_demo westonrobot::wrp_sdk_peripheral) add_executable(sample_power_regulator_demo power_regulator_demo.cpp) -target_link_libraries(sample_power_regulator_demo westonrobot::wrp_sdk) \ No newline at end of file +target_link_libraries(sample_power_regulator_demo westonrobot::wrp_sdk_peripheral westonrobot::wrp_sdk_canopen) \ No newline at end of file