Skip to content

Commit

Permalink
Merge pull request #3 from westonrobot/feature-v1.3.0
Browse files Browse the repository at this point in the history
sample: update to wrp_sdk v1.3.0
  • Loading branch information
hanskw-weston authored May 3, 2024
2 parents 2fc99dd + e5cb193 commit 1a11561
Show file tree
Hide file tree
Showing 6 changed files with 118 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
- "**"

env:
VERSION: "1.2.*"
VERSION: "1.3.*"

jobs:
build:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- 'main'

env:
TAG_VERSION: "1.2.x"
TAG_VERSION: "1.3.x"

jobs:
tag-release:
Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
Expand Down
9 changes: 6 additions & 3 deletions sample/mobile_base/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
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)
104 changes: 104 additions & 0 deletions sample/mobile_base/robooterx_wheelchair_demo.cpp
Original file line number Diff line number Diff line change
@@ -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 <unistd.h>

#include <iomanip>
#include <sstream>
#include <iostream>

#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 <interface>"
<< 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<int>(system_state.operational_state) << std::endl;
std::cout << " Control State: "
<< static_cast<int>(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<westonrobot::MotionMode>(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;
}
8 changes: 4 additions & 4 deletions sample/peripheral/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
target_link_libraries(sample_power_regulator_demo westonrobot::wrp_sdk_peripheral westonrobot::wrp_sdk_canopen)

0 comments on commit 1a11561

Please sign in to comment.