From de0d98268e297cddbf07083a50c6f43431113d3a Mon Sep 17 00:00:00 2001 From: hanskw-weston Date: Fri, 17 May 2024 10:41:21 +0000 Subject: [PATCH] src: new structure to follow wrp_ros2 --- .github/workflows/default.yml | 2 +- .gitlab-ci.yml | 74 ------ CMakeLists.txt | 223 ------------------ launch/peripheral/gps_receiver.launch | 4 - launch/peripheral/imu_sensor.launch | 4 - launch/peripheral/power_regulator.launch | 4 - launch/peripheral/ultrasonic_sensor.launch | 4 - msg/RangeData.msg | 6 - msg/RangeDataType.msg | 3 - msg/RcState.msg | 6 - src/mobile_base/README.md | 48 ---- src/mobile_base/mobile_base_node.cpp | 26 -- wrp_sdk_msgs/CMakeLists.txt | 71 ++++++ .../action}/LiftControl.action | 0 {msg => wrp_sdk_msgs/msg}/ActuatorState.msg | 0 .../msg}/ActuatorStateArray.msg | 0 {msg => wrp_sdk_msgs/msg}/DriverState.msg | 0 .../msg/LiftState.msg | 1 + .../msg}/LightControlType.msg | 0 {msg => wrp_sdk_msgs/msg}/MotionCommand.msg | 0 {msg => wrp_sdk_msgs/msg}/MotionState.msg | 0 {msg => wrp_sdk_msgs/msg}/MotorState.msg | 0 .../msg}/PowerRegulatorChannelState.msg | 0 .../msg}/PowerRegulatorDeviceState.msg | 0 wrp_sdk_msgs/msg/RangeData.msg | 5 + wrp_sdk_msgs/msg/RangeDataArray.msg | 7 + wrp_sdk_msgs/msg/RcState.msg | 3 + {msg => wrp_sdk_msgs/msg}/SystemState.msg | 0 wrp_sdk_msgs/package.xml | 36 +++ {srv => wrp_sdk_msgs/srv}/AccessControl.srv | 0 .../srv}/AssistedModeControl.srv | 0 {srv => wrp_sdk_msgs/srv}/LiftQuery.srv | 0 {srv => wrp_sdk_msgs/srv}/LightControl.srv | 0 {srv => wrp_sdk_msgs/srv}/MotionReset.srv | 0 .../srv}/PowerRegulatorControl.srv | 0 wrp_sdk_periph/CMakeLists.txt | 83 +++++++ .../config}/gps_receiver_node_config.yaml | 0 .../config}/imu_sensor_node_config.yaml | 0 .../config}/power_regulator_node_config.yaml | 0 .../ultrasonic_sensor_node_config.yaml | 0 .../wrp_sdk_periph}/gps_receiver_node.hpp | 0 .../wrp_sdk_periph}/imu_sensor_node.hpp | 0 .../wrp_sdk_periph}/lift_controller_node.hpp | 19 +- .../wrp_sdk_periph}/power_regulator_node.hpp | 8 +- .../ultrasonic_sensor_node.hpp | 0 wrp_sdk_periph/launch/gps_receiver.launch | 4 + wrp_sdk_periph/launch/imu_sensor.launch | 4 + wrp_sdk_periph/launch/power_regulator.launch | 4 + .../launch/ultrasonic_sensor.launch | 4 + package.xml => wrp_sdk_periph/package.xml | 27 +-- .../src}/README.md | 12 +- .../src}/gps_receiver_node.cpp | 2 +- .../src}/imu_sensor_node.cpp | 2 +- .../src}/lift_controller_node.cpp | 37 +-- .../src}/power_regulator_node.cpp | 18 +- .../src}/ultrasonic_sensor_node.cpp | 2 +- wrp_sdk_robot/CMakeLists.txt | 52 ++++ .../wrp_sdk_robot/mobile_base_node.hpp | 52 ++-- .../description/scout_mini_description.launch | 2 +- .../description/scout_v2_description.launch | 2 +- .../launch}/mobile_base/scout.launch | 2 +- .../launch}/mobile_base/scout_mini.launch | 2 +- .../launch}/mobile_base/tracer.launch | 2 +- .../meshes}/scout_mini/mini_base_link.dae | 0 .../meshes}/scout_mini/mini_wheel.dae | 0 .../meshes}/scout_v2/base_link.dae | 0 .../meshes}/scout_v2/wheel_type1.dae | 0 .../meshes}/scout_v2/wheel_type2.dae | 0 wrp_sdk_robot/package.xml | 68 ++++++ .../src/mobile_base_node.cpp | 118 ++++----- .../urdf}/scout_mini/scout_mini.urdf | 0 .../urdf}/scout_mini/scout_mini.xacro | 4 +- .../urdf}/scout_mini/scout_mini_wheel.xacro | 2 +- .../urdf}/scout_v2/scout_v2.urdf | 10 +- .../urdf}/scout_v2/scout_v2.xacro | 6 +- .../urdf}/scout_v2/scout_wheel_type1.xacro | 2 +- .../urdf}/scout_v2/scout_wheel_type2.xacro | 2 +- 77 files changed, 514 insertions(+), 565 deletions(-) delete mode 100644 .gitlab-ci.yml delete mode 100644 CMakeLists.txt delete mode 100644 launch/peripheral/gps_receiver.launch delete mode 100644 launch/peripheral/imu_sensor.launch delete mode 100644 launch/peripheral/power_regulator.launch delete mode 100644 launch/peripheral/ultrasonic_sensor.launch delete mode 100644 msg/RangeData.msg delete mode 100644 msg/RangeDataType.msg delete mode 100644 msg/RcState.msg delete mode 100644 src/mobile_base/README.md delete mode 100644 src/mobile_base/mobile_base_node.cpp create mode 100644 wrp_sdk_msgs/CMakeLists.txt rename {action => wrp_sdk_msgs/action}/LiftControl.action (100%) rename {msg => wrp_sdk_msgs/msg}/ActuatorState.msg (100%) rename {msg => wrp_sdk_msgs/msg}/ActuatorStateArray.msg (100%) rename {msg => wrp_sdk_msgs/msg}/DriverState.msg (100%) rename msg/LiftStatus.msg => wrp_sdk_msgs/msg/LiftState.msg (98%) rename {msg => wrp_sdk_msgs/msg}/LightControlType.msg (100%) rename {msg => wrp_sdk_msgs/msg}/MotionCommand.msg (100%) rename {msg => wrp_sdk_msgs/msg}/MotionState.msg (100%) rename {msg => wrp_sdk_msgs/msg}/MotorState.msg (100%) rename {msg => wrp_sdk_msgs/msg}/PowerRegulatorChannelState.msg (100%) rename {msg => wrp_sdk_msgs/msg}/PowerRegulatorDeviceState.msg (100%) create mode 100644 wrp_sdk_msgs/msg/RangeData.msg create mode 100644 wrp_sdk_msgs/msg/RangeDataArray.msg create mode 100644 wrp_sdk_msgs/msg/RcState.msg rename {msg => wrp_sdk_msgs/msg}/SystemState.msg (100%) create mode 100644 wrp_sdk_msgs/package.xml rename {srv => wrp_sdk_msgs/srv}/AccessControl.srv (100%) rename {srv => wrp_sdk_msgs/srv}/AssistedModeControl.srv (100%) rename {srv => wrp_sdk_msgs/srv}/LiftQuery.srv (100%) rename {srv => wrp_sdk_msgs/srv}/LightControl.srv (100%) rename {srv => wrp_sdk_msgs/srv}/MotionReset.srv (100%) rename {srv => wrp_sdk_msgs/srv}/PowerRegulatorControl.srv (100%) create mode 100644 wrp_sdk_periph/CMakeLists.txt rename {config/peripheral => wrp_sdk_periph/config}/gps_receiver_node_config.yaml (100%) rename {config/peripheral => wrp_sdk_periph/config}/imu_sensor_node_config.yaml (100%) rename {config/peripheral => wrp_sdk_periph/config}/power_regulator_node_config.yaml (100%) rename {config/peripheral => wrp_sdk_periph/config}/ultrasonic_sensor_node_config.yaml (100%) rename {include/wrp_ros/peripheral => wrp_sdk_periph/include/wrp_sdk_periph}/gps_receiver_node.hpp (100%) rename {include/wrp_ros/peripheral => wrp_sdk_periph/include/wrp_sdk_periph}/imu_sensor_node.hpp (100%) rename {include/wrp_ros/peripheral => wrp_sdk_periph/include/wrp_sdk_periph}/lift_controller_node.hpp (65%) rename {include/wrp_ros/peripheral => wrp_sdk_periph/include/wrp_sdk_periph}/power_regulator_node.hpp (75%) rename {include/wrp_ros/peripheral => wrp_sdk_periph/include/wrp_sdk_periph}/ultrasonic_sensor_node.hpp (100%) create mode 100644 wrp_sdk_periph/launch/gps_receiver.launch create mode 100644 wrp_sdk_periph/launch/imu_sensor.launch create mode 100644 wrp_sdk_periph/launch/power_regulator.launch create mode 100644 wrp_sdk_periph/launch/ultrasonic_sensor.launch rename package.xml => wrp_sdk_periph/package.xml (74%) rename {src/peripheral => wrp_sdk_periph/src}/README.md (89%) rename {src/peripheral => wrp_sdk_periph/src}/gps_receiver_node.cpp (97%) rename {src/peripheral => wrp_sdk_periph/src}/imu_sensor_node.cpp (98%) rename {src/peripheral => wrp_sdk_periph/src}/lift_controller_node.cpp (76%) rename {src/peripheral => wrp_sdk_periph/src}/power_regulator_node.cpp (85%) rename {src/peripheral => wrp_sdk_periph/src}/ultrasonic_sensor_node.cpp (97%) create mode 100644 wrp_sdk_robot/CMakeLists.txt rename include/wrp_ros/mobile_base/mobile_base_ros.hpp => wrp_sdk_robot/include/wrp_sdk_robot/mobile_base_node.hpp (61%) rename {launch => wrp_sdk_robot/launch}/description/scout_mini_description.launch (75%) rename {launch => wrp_sdk_robot/launch}/description/scout_v2_description.launch (76%) rename {launch => wrp_sdk_robot/launch}/mobile_base/scout.launch (91%) rename {launch => wrp_sdk_robot/launch}/mobile_base/scout_mini.launch (91%) rename {launch => wrp_sdk_robot/launch}/mobile_base/tracer.launch (91%) rename {meshes => wrp_sdk_robot/meshes}/scout_mini/mini_base_link.dae (100%) rename {meshes => wrp_sdk_robot/meshes}/scout_mini/mini_wheel.dae (100%) rename {meshes => wrp_sdk_robot/meshes}/scout_v2/base_link.dae (100%) rename {meshes => wrp_sdk_robot/meshes}/scout_v2/wheel_type1.dae (100%) rename {meshes => wrp_sdk_robot/meshes}/scout_v2/wheel_type2.dae (100%) create mode 100644 wrp_sdk_robot/package.xml rename src/mobile_base/mobile_base_ros.cpp => wrp_sdk_robot/src/mobile_base_node.cpp (76%) rename {urdf => wrp_sdk_robot/urdf}/scout_mini/scout_mini.urdf (100%) rename {urdf => wrp_sdk_robot/urdf}/scout_mini/scout_mini.xacro (93%) rename {urdf => wrp_sdk_robot/urdf}/scout_mini/scout_mini_wheel.xacro (96%) rename {urdf => wrp_sdk_robot/urdf}/scout_v2/scout_v2.urdf (90%) rename {urdf => wrp_sdk_robot/urdf}/scout_v2/scout_v2.xacro (91%) rename {urdf => wrp_sdk_robot/urdf}/scout_v2/scout_wheel_type1.xacro (96%) rename {urdf => wrp_sdk_robot/urdf}/scout_v2/scout_wheel_type2.xacro (96%) diff --git a/.github/workflows/default.yml b/.github/workflows/default.yml index 3c482f6..7a5ec82 100644 --- a/.github/workflows/default.yml +++ b/.github/workflows/default.yml @@ -33,7 +33,7 @@ jobs: run: | mkdir -p ${GITHUB_WORKSPACE}/catkin_ws/src - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v3 with: submodules: recursive path: "catkin_ws/src/" diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index 7e7499f..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,74 +0,0 @@ -## Build and test as catkin package -# kinetic-catkin-build: -# stage: build -# image: rduweston/ubuntu-ci:kinetic -# before_script: -# - apt update && apt -y install ros-$ROS_DISTRO-teleop-twist-keyboard -# script: -# - mkdir -p /catkin_ws/src && cd /catkin_ws/src && /bin/bash -c "source /opt/ros/${ROS_DISTRO}/setup.bash; catkin_init_workspace" -# - cd /catkin_ws/src && git clone -b master --recursive https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com/westonrobot/public/ugv_sdk.git -# - cp -r /builds/$CI_PROJECT_PATH /catkin_ws/src/wrp_ros -# - cd /catkin_ws && /bin/bash -c "source /opt/ros/${ROS_DISTRO}/setup.bash; catkin_make" - -# kinetic-catkin-isolated-build: -# stage: build -# image: rduweston/ubuntu-ci:kinetic -# before_script: -# - apt update && apt -y install ros-$ROS_DISTRO-teleop-twist-keyboard -# script: -# - mkdir -p /catkin_ws/src && cd /catkin_ws/src && /bin/bash -c "source /opt/ros/${ROS_DISTRO}/setup.bash; catkin_init_workspace" -# - cd /catkin_ws/src && git clone -b master --recursive https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com/westonrobot/public/ugv_sdk.git -# - cp -r /builds/$CI_PROJECT_PATH /catkin_ws/src/wrp_ros -# - cd /catkin_ws && /bin/bash -c "source /opt/ros/${ROS_DISTRO}/setup.bash; catkin_make_isolated --install" - -melodic-catkin-build: - stage: build - image: rduweston/ubuntu-ci:melodic - before_script: - - apt-get update && apt-get install -y ca-certificates curl - - echo "deb https://westonrobot.jfrog.io/artifactory/wrtoolbox-release bionic main" | tee /etc/apt/sources.list.d/weston-robot.list - - echo "deb https://westonrobot.jfrog.io/artifactory/wrtoolbox-release bionic next" >> /etc/apt/sources.list.d/weston-robot.list - - curl -sSL 'https://westonrobot.jfrog.io/artifactory/api/security/keypair/wr-deb/public' | apt-key add - - - apt-get update && apt-get -y install wrp_sdk - script: - - mkdir -p /catkin_ws/src && cd /catkin_ws/src && /bin/bash -c "source /opt/ros/${ROS_DISTRO}/setup.bash; catkin_init_workspace" - - cp -r /builds/$CI_PROJECT_PATH /catkin_ws/src/wrp_ros - - cd /catkin_ws && /bin/bash -c "source /opt/ros/${ROS_DISTRO}/setup.bash; catkin_make" - -# melodic-catkin-isolated-build: -# stage: build -# image: rduweston/ubuntu-ci:melodic -# before_script: -# - apt update && apt -y install curl ros-$ROS_DISTRO-teleop-twist-keyboard ros-$ROS_DISTRO-std-msgs -# - echo "deb https://westonrobot.jfrog.io/artifactory/wrtoolbox-release bionic main" | tee /etc/apt/sources.list.d/weston-robot.list -# - curl -sSL 'https://westonrobot.jfrog.io/artifactory/api/security/keypair/wr-deb/public' | apt-key add - -# - apt-get update && apt-get -y install wrp_sdk -# script: -# - mkdir -p /catkin_ws/src && cd /catkin_ws/src && /bin/bash -c "source /opt/ros/${ROS_DISTRO}/setup.bash; catkin_init_workspace" -# - cp -r /builds/$CI_PROJECT_PATH /catkin_ws/src/wrp_ros -# - cd /catkin_ws && /bin/bash -c "source /opt/ros/${ROS_DISTRO}/setup.bash; catkin_make_isolated --install" - -noetic-catkin-build: - stage: build - image: rduweston/ubuntu-ci:noetic - before_script: - - apt-get update && apt-get install -y ca-certificates curl - - echo "deb https://westonrobot.jfrog.io/artifactory/wrtoolbox-release bionic main" | tee /etc/apt/sources.list.d/weston-robot.list - - echo "deb https://westonrobot.jfrog.io/artifactory/wrtoolbox-release bionic next" >> /etc/apt/sources.list.d/weston-robot.list - - curl -sSL 'https://westonrobot.jfrog.io/artifactory/api/security/keypair/wr-deb/public' | apt-key add - - - apt-get update && apt-get -y install wrp_sdk - script: - - mkdir -p /catkin_ws/src && cd /catkin_ws/src && /bin/bash -c "source /opt/ros/${ROS_DISTRO}/setup.bash; catkin_init_workspace" - - cp -r /builds/$CI_PROJECT_PATH /catkin_ws/src/wrp_ros - - cd /catkin_ws && /bin/bash -c "source /opt/ros/${ROS_DISTRO}/setup.bash; catkin_make" - -# noetic-catkin-isolated-build: -# stage: build -# image: rduweston/ubuntu-ci:noetic -# before_script: -# - apt update && apt -y install ros-$ROS_DISTRO-teleop-twist-keyboard -# script: -# - mkdir -p /catkin_ws/src && cd /catkin_ws/src && /bin/bash -c "source /opt/ros/${ROS_DISTRO}/setup.bash; catkin_init_workspace" -# - cd /catkin_ws/src && git clone -b master --recursive https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com/westonrobot/public/ugv_sdk.git -# - cp -r /builds/$CI_PROJECT_PATH /catkin_ws/src/wrp_ros -# - cd /catkin_ws && /bin/bash -c "source /opt/ros/${ROS_DISTRO}/setup.bash; catkin_make_isolated --install" \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index 9784867..0000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,223 +0,0 @@ -cmake_minimum_required(VERSION 3.0.2) -project(wrp_ros) - -## Compile as C++11, supported in ROS Kinetic and newer -add_compile_options(-std=c++11) - -string(REPLACE ":" ";" CMAKE_PREFIX_PATH "$ENV{CMAKE_PREFIX_PATH}") -list(APPEND CMAKE_PREFIX_PATH "/opt/weston_robot/lib/cmake") - -## Find catkin macros and libraries -## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz) -## is used, also find other catkin packages -find_package(catkin REQUIRED COMPONENTS - message_generation - roscpp - sensor_msgs - geometry_msgs - std_msgs - tf2 - tf2_ros - actionlib - actionlib_msgs -) - -## System dependencies are found with CMake's conventions -# find_package(Boost REQUIRED COMPONENTS system) -find_package(wrp_sdk 1.0.0 REQUIRED) - -find_package(PkgConfig REQUIRED) -pkg_check_modules(LelyIO QUIET IMPORTED_TARGET liblely-io2) -pkg_check_modules(LelyCOAPP QUIET IMPORTED_TARGET liblely-coapp) - -set(BUILD_PERIPH_MODULE OFF) -if(LelyIO_FOUND AND LelyCOAPP_FOUND) - message(STATUS "Lely-core libraries found, peripheral module will be included") - set(BUILD_PERIPH_MODULE ON) -else() - message(WARNING "CANopen-related dependencies are not found, ROS nodes for peripherals will not be built. Run the following commands to install the missing libraries: - $ sudo apt-get install -y software-properties-common - $ sudo add-apt-repository ppa:lely/ppa && sudo apt-get update - $ sudo apt-get install -y pkg-config liblely-coapp-dev liblely-co-tools") -endif() - -## Uncomment this if the package has a setup.py. This macro ensures -## modules and global scripts declared therein get installed -## See http://ros.org/doc/api/catkin/html/user_guide/setup_dot_py.html -# catkin_python_setup() - -################################################ -## Declare ROS messages, services and actions ## -################################################ - -## Generate messages in the 'msg' folder -add_message_files( - FILES - ActuatorState.msg - ActuatorStateArray.msg - DriverState.msg - LiftStatus.msg - LightControlType.msg - MotionCommand.msg - MotionState.msg - MotorState.msg - RangeData.msg - RangeDataType.msg - RcState.msg - SystemState.msg - PowerRegulatorChannelState.msg - PowerRegulatorDeviceState.msg -) - -## Generate services in the 'srv' folder -add_service_files( - FILES - AccessControl.srv - AssistedModeControl.srv - LiftQuery.srv - LightControl.srv - MotionReset.srv - PowerRegulatorControl.srv -) - -# Generate actions in the 'action' folder -add_action_files( - FILES - LiftControl.action -) - -## Generate added messages and services with any dependencies listed here -generate_messages( - DEPENDENCIES - actionlib_msgs - std_msgs - geometry_msgs -) - -catkin_package(CATKIN_DEPENDS std_msgs message_runtime) - -################################################ -## Declare ROS dynamic reconfigure parameters ## -################################################ - -## To declare and build dynamic reconfigure parameters within this -## package, follow these steps: -## * In the file package.xml: -## * add a build_depend and a exec_depend tag for "dynamic_reconfigure" -## * In this file (CMakeLists.txt): -## * add "dynamic_reconfigure" to -## find_package(catkin REQUIRED COMPONENTS ...) -## * uncomment the "generate_dynamic_reconfigure_options" section below -## and list every .cfg file to be processed - -## Generate dynamic reconfigure parameters in the 'cfg' folder -# generate_dynamic_reconfigure_options( -# cfg/DynReconf1.cfg -# cfg/DynReconf2.cfg -# ) - -################################### -## catkin specific configuration ## -################################### - -catkin_package( - INCLUDE_DIRS include - LIBRARIES wrp_ros - CATKIN_DEPENDS message_generation roscpp sensor_msgs std_msgs actionlib actionlib_msgs - DEPENDS wrp_sdk -) - -########### -## Build ## -########### - -include_directories( - include - ${catkin_INCLUDE_DIRS} -) - -add_library(wrp_sdk_ros STATIC src/mobile_base/mobile_base_ros.cpp) -target_link_libraries(wrp_sdk_ros ${catkin_LIBRARIES} westonrobot::wrp_sdk_robot) -add_dependencies(wrp_sdk_ros ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS}) - -add_executable(mobile_base_node src/mobile_base/mobile_base_node.cpp) -target_link_libraries(mobile_base_node wrp_sdk_ros ${catkin_LIBRARIES}) - -add_executable(lift_controller_node src/peripheral/lift_controller_node.cpp) -target_link_libraries(lift_controller_node westonrobot::wrp_sdk ${catkin_LIBRARIES}) -add_dependencies(lift_controller_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS}) - - -# peripheral device support -if(BUILD_PERIPH_MODULE) - add_executable(gps_receiver_node src/peripheral/gps_receiver_node.cpp) - target_link_libraries(gps_receiver_node westonrobot::wrp_sdk ${catkin_LIBRARIES}) - add_dependencies(gps_receiver_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS}) - - add_executable(imu_sensor_node src/peripheral/imu_sensor_node.cpp) - target_link_libraries(imu_sensor_node westonrobot::wrp_sdk ${catkin_LIBRARIES}) - add_dependencies(imu_sensor_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS}) - - add_executable(ultrasonic_sensor_node src/peripheral/ultrasonic_sensor_node.cpp) - target_link_libraries(ultrasonic_sensor_node westonrobot::wrp_sdk ${catkin_LIBRARIES}) - add_dependencies(ultrasonic_sensor_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS}) - - add_executable(power_regulator_node src/peripheral/power_regulator_node.cpp) - target_link_libraries(power_regulator_node westonrobot::wrp_sdk ${catkin_LIBRARIES}) - add_dependencies(power_regulator_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS}) -endif() - -############# -## Install ## -############# - -# all install targets should use catkin DESTINATION variables -# See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html - -## Mark executable scripts (Python etc.) for installation -## in contrast to setup.py, you can choose the destination -# catkin_install_python(PROGRAMS -# scripts/my_python_script -# DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} -# ) - -## Mark executables for installation -## See http://docs.ros.org/melodic/api/catkin/html/howto/format1/building_executables.html -# install(TARGETS ${PROJECT_NAME}_node -# RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} -# ) - -## Mark libraries for installation -## See http://docs.ros.org/melodic/api/catkin/html/howto/format1/building_libraries.html -install(TARGETS wrp_sdk_ros - ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} - LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} - RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION} -) - -## Mark cpp header files for installation -install(DIRECTORY include/${PROJECT_NAME}/ - DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION} - FILES_MATCHING PATTERN "*.h" - PATTERN ".svn" EXCLUDE -) - -## Mark other files for installation (e.g. launch and bag files, etc.) -# install(FILES -# # myfile1 -# # myfile2 -# DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION} -# ) - -############# -## Testing ## -############# - -## Add gtest based cpp test target and link libraries -# catkin_add_gtest(${PROJECT_NAME}-test test/test_wrp_ros.cpp) -# if(TARGET ${PROJECT_NAME}-test) -# target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME}) -# endif() - -## Add folders to be run by python nosetests -# catkin_add_nosetests(test) diff --git a/launch/peripheral/gps_receiver.launch b/launch/peripheral/gps_receiver.launch deleted file mode 100644 index 80f7ff7..0000000 --- a/launch/peripheral/gps_receiver.launch +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/launch/peripheral/imu_sensor.launch b/launch/peripheral/imu_sensor.launch deleted file mode 100644 index d00151e..0000000 --- a/launch/peripheral/imu_sensor.launch +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/launch/peripheral/power_regulator.launch b/launch/peripheral/power_regulator.launch deleted file mode 100644 index 61c5be4..0000000 --- a/launch/peripheral/power_regulator.launch +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/launch/peripheral/ultrasonic_sensor.launch b/launch/peripheral/ultrasonic_sensor.launch deleted file mode 100644 index 08c4ff9..0000000 --- a/launch/peripheral/ultrasonic_sensor.launch +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/msg/RangeData.msg b/msg/RangeData.msg deleted file mode 100644 index 800f644..0000000 --- a/msg/RangeData.msg +++ /dev/null @@ -1,6 +0,0 @@ -uint8 RANGE_SENSOR_TYPE_TOF = 0 -uint8 RANGE_SENSOR_TYPE_ULTRASONIC = 1 -uint8 RANGE_SENSOR_TYPE_BUMPER = 2 - -uint8 type -RangeDataType[8] data \ No newline at end of file diff --git a/msg/RangeDataType.msg b/msg/RangeDataType.msg deleted file mode 100644 index 94448f8..0000000 --- a/msg/RangeDataType.msg +++ /dev/null @@ -1,3 +0,0 @@ -uint32 id -float32 threshold -float32 range \ No newline at end of file diff --git a/msg/RcState.msg b/msg/RcState.msg deleted file mode 100644 index 4e9437e..0000000 --- a/msg/RcState.msg +++ /dev/null @@ -1,6 +0,0 @@ -uint8 RC_SW_UP = 0 -uint8 RC_SW_MIDDLE = 1 -uint8 RC_SW_DOWN = 2 - -float32[8] axes -int32[8] buttons \ No newline at end of file diff --git a/src/mobile_base/README.md b/src/mobile_base/README.md deleted file mode 100644 index f0407f4..0000000 --- a/src/mobile_base/README.md +++ /dev/null @@ -1,48 +0,0 @@ -# wrp_ros mobile base - -## About - -ROS wrappers around wrp_sdk mobile base interface. - -## Support - -### Robot platforms -| Robot Platform | Robot Base Type | CAN Bitrate | Support | -| -------------- | --------------- | ----------- | ------------------- | -| Scout | "weston" | 1000000 | Supported | -| Scout Mini | "agilex" | 500000 | Supported | -| Hunter | "agilex" | 500000 | Not fully supported | -| Tracer | "agilex" | 500000 | Supported | -| Bunker | "agilex" | 500000 | Not fully supported | -| Ranger Mini | "agilex" | 500000 | Not fully supported | - -## Nodes - -### mobile_base_node -| Published Topic | Type | Description | -| ----------------- | --------------------------- | ------------------------------- | -| `/system_state` | wrp_ros::SystemState | Outputs robot's system state | -| `/motion_state` | wrp_ros::MotionState | Outputs robot's motion state | -| `/actuator_state` | wrp_ros::ActuatorStateArray | Outputs robot's actuator states | -| `/odom` | nav_msgs::msg::Odometry | Outputs robot's wheel odometry | -| `/battery_state` | sensor_msgs::BatteryState | Outputs robot's battery state | - -| Subscribed Topic | Type | Description | -| ---------------- | ------------------------- | ------------------------ | -| `/cmd_vel` | geometry_msgs::msg::Twist | Control robot's movement | - -| Service | Type | Description | -| ------------------------ | ---------------------------- | --------------------------------------- | -| `/access_control` | wrp_ros::AccessControl | (Re)Gain or Renounce control token | -| `/assisted_mode_control` | wrp_ros::AssistedModeControl | (En/Dis)able Assisted mode | -| `/light_control` | wrp_ros::LightControl | Control robot's lights | -| `/motion_reset` | wrp_ros::MotionReset | Reset wheel position or odometry values | - -| Parameter | Type | Description | -| ----------------- | ---- | --------------------------------------------------------------------------------------------------- | -| `robot_base_type` | str | Robot base type.
Default: "weston"
Supported: "weston", "agilex" | -| `can_device` | str | Robot's CAN port.
Default: "can0" | -| `base_frame` | str | Base frame id.
Default: "base_link"
| -| `odom_frame` | str | Odometry frame id.
Default: "odom" | -| `auto_reconnect` | bool | Automatically attempt to gain control token.
Default: true | -| `motion_type` | str | Robot's motion type.
Default: "skid_steer"
Supported: "skid_steer", "omni", "differential" | diff --git a/src/mobile_base/mobile_base_node.cpp b/src/mobile_base/mobile_base_node.cpp deleted file mode 100644 index b1301d8..0000000 --- a/src/mobile_base/mobile_base_node.cpp +++ /dev/null @@ -1,26 +0,0 @@ -/* - * mobile_base_node.cpp - * - * Created on: Dec 17, 2021 09:59 - * Description: - * - * Copyright (c) 2021 Weston Robot Pte. Ltd. - */ - -#include - -#include "wrp_ros/mobile_base/mobile_base_ros.hpp" - -using namespace westonrobot; - -int main(int argc, char **argv) { - // setup ROS node - ros::init(argc, argv, "mobile_base_node"); - ros::NodeHandle node("~"); - - MobileBaseRos base(&node); - - base.Run(50); - - return 0; -} \ No newline at end of file diff --git a/wrp_sdk_msgs/CMakeLists.txt b/wrp_sdk_msgs/CMakeLists.txt new file mode 100644 index 0000000..f8c1077 --- /dev/null +++ b/wrp_sdk_msgs/CMakeLists.txt @@ -0,0 +1,71 @@ +cmake_minimum_required(VERSION 3.0.2) +project(wrp_sdk_msgs) + +# # Compile as C++11, supported in ROS Kinetic and newer +add_compile_options(-std=c++11) + +# # Find catkin macros and libraries +# # if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz) +# # is used, also find other catkin packages +find_package(catkin REQUIRED COMPONENTS + message_generation + roscpp + geometry_msgs + std_msgs + actionlib_msgs +) + +add_message_files( + FILES + + # mobile base + "ActuatorState.msg" + "ActuatorStateArray.msg" + "DriverState.msg" + "LightControlType.msg" + "MotionCommand.msg" + "MotionState.msg" + "MotorState.msg" + "RangeData.msg" + "RangeDataArray.msg" + "RcState.msg" + "SystemState.msg" + + # peripheral + "PowerRegulatorChannelState.msg" + "PowerRegulatorDeviceState.msg" + "LiftState.msg" +) + +# # Generate services in the 'srv' folder +add_service_files( + FILES + + # mobile base + "AccessControl.srv" + "AssistedModeControl.srv" + "LightControl.srv" + "MotionReset.srv" + + # peripheral + "PowerRegulatorControl.srv" + "LiftQuery.srv" +) + +# Generate actions in the 'action' folder +add_action_files( + FILES + + # peripheral + "LiftControl.action" +) + +# # Generate added messages and services with any dependencies listed here +generate_messages( + DEPENDENCIES + actionlib_msgs + std_msgs + geometry_msgs +) + +catkin_package(CATKIN_DEPENDS std_msgs actionlib_msgs geometry_msgs message_runtime) diff --git a/action/LiftControl.action b/wrp_sdk_msgs/action/LiftControl.action similarity index 100% rename from action/LiftControl.action rename to wrp_sdk_msgs/action/LiftControl.action diff --git a/msg/ActuatorState.msg b/wrp_sdk_msgs/msg/ActuatorState.msg similarity index 100% rename from msg/ActuatorState.msg rename to wrp_sdk_msgs/msg/ActuatorState.msg diff --git a/msg/ActuatorStateArray.msg b/wrp_sdk_msgs/msg/ActuatorStateArray.msg similarity index 100% rename from msg/ActuatorStateArray.msg rename to wrp_sdk_msgs/msg/ActuatorStateArray.msg diff --git a/msg/DriverState.msg b/wrp_sdk_msgs/msg/DriverState.msg similarity index 100% rename from msg/DriverState.msg rename to wrp_sdk_msgs/msg/DriverState.msg diff --git a/msg/LiftStatus.msg b/wrp_sdk_msgs/msg/LiftState.msg similarity index 98% rename from msg/LiftStatus.msg rename to wrp_sdk_msgs/msg/LiftState.msg index 0ffdc38..d963434 100644 --- a/msg/LiftStatus.msg +++ b/wrp_sdk_msgs/msg/LiftState.msg @@ -1,4 +1,5 @@ uint8 LIFT_HORIZONTAL=0 uint8 LIFT_VERTICAL=1 + uint8 id uint32 position diff --git a/msg/LightControlType.msg b/wrp_sdk_msgs/msg/LightControlType.msg similarity index 100% rename from msg/LightControlType.msg rename to wrp_sdk_msgs/msg/LightControlType.msg diff --git a/msg/MotionCommand.msg b/wrp_sdk_msgs/msg/MotionCommand.msg similarity index 100% rename from msg/MotionCommand.msg rename to wrp_sdk_msgs/msg/MotionCommand.msg diff --git a/msg/MotionState.msg b/wrp_sdk_msgs/msg/MotionState.msg similarity index 100% rename from msg/MotionState.msg rename to wrp_sdk_msgs/msg/MotionState.msg diff --git a/msg/MotorState.msg b/wrp_sdk_msgs/msg/MotorState.msg similarity index 100% rename from msg/MotorState.msg rename to wrp_sdk_msgs/msg/MotorState.msg diff --git a/msg/PowerRegulatorChannelState.msg b/wrp_sdk_msgs/msg/PowerRegulatorChannelState.msg similarity index 100% rename from msg/PowerRegulatorChannelState.msg rename to wrp_sdk_msgs/msg/PowerRegulatorChannelState.msg diff --git a/msg/PowerRegulatorDeviceState.msg b/wrp_sdk_msgs/msg/PowerRegulatorDeviceState.msg similarity index 100% rename from msg/PowerRegulatorDeviceState.msg rename to wrp_sdk_msgs/msg/PowerRegulatorDeviceState.msg diff --git a/wrp_sdk_msgs/msg/RangeData.msg b/wrp_sdk_msgs/msg/RangeData.msg new file mode 100644 index 0000000..fb648b8 --- /dev/null +++ b/wrp_sdk_msgs/msg/RangeData.msg @@ -0,0 +1,5 @@ +uint32 id +float32 field_of_view +float32 min_range +float32 max_range +float32 range \ No newline at end of file diff --git a/wrp_sdk_msgs/msg/RangeDataArray.msg b/wrp_sdk_msgs/msg/RangeDataArray.msg new file mode 100644 index 0000000..addd873 --- /dev/null +++ b/wrp_sdk_msgs/msg/RangeDataArray.msg @@ -0,0 +1,7 @@ +uint8 RANGE_SENSOR_TYPE_ULTRASONIC = 1 +uint8 RANGE_SENSOR_TYPE_INFRARED = 1 +uint8 RANGE_SENSOR_TYPE_TOF = 2 +uint8 RANGE_SENSOR_TYPE_BUMPER = 3 + +uint8 type +RangeData[] data \ No newline at end of file diff --git a/wrp_sdk_msgs/msg/RcState.msg b/wrp_sdk_msgs/msg/RcState.msg new file mode 100644 index 0000000..22cdb90 --- /dev/null +++ b/wrp_sdk_msgs/msg/RcState.msg @@ -0,0 +1,3 @@ +std_msgs/Header header +float32[8] axes +int32[8] buttons \ No newline at end of file diff --git a/msg/SystemState.msg b/wrp_sdk_msgs/msg/SystemState.msg similarity index 100% rename from msg/SystemState.msg rename to wrp_sdk_msgs/msg/SystemState.msg diff --git a/wrp_sdk_msgs/package.xml b/wrp_sdk_msgs/package.xml new file mode 100644 index 0000000..c91ff67 --- /dev/null +++ b/wrp_sdk_msgs/package.xml @@ -0,0 +1,36 @@ + + + wrp_sdk_msgs + 0.0.0 + The wrp_sdk_msgs package + + hans.kurnia + + TODO + + catkin + + roscpp + geometry_msgs + std_msgs + actionlib_msgs + message_generation + + roscpp + geometry_msgs + std_msgs + actionlib_msgs + + roscpp + geometry_msgs + std_msgs + actionlib_msgs + + message_runtime + + + + + + + diff --git a/srv/AccessControl.srv b/wrp_sdk_msgs/srv/AccessControl.srv similarity index 100% rename from srv/AccessControl.srv rename to wrp_sdk_msgs/srv/AccessControl.srv diff --git a/srv/AssistedModeControl.srv b/wrp_sdk_msgs/srv/AssistedModeControl.srv similarity index 100% rename from srv/AssistedModeControl.srv rename to wrp_sdk_msgs/srv/AssistedModeControl.srv diff --git a/srv/LiftQuery.srv b/wrp_sdk_msgs/srv/LiftQuery.srv similarity index 100% rename from srv/LiftQuery.srv rename to wrp_sdk_msgs/srv/LiftQuery.srv diff --git a/srv/LightControl.srv b/wrp_sdk_msgs/srv/LightControl.srv similarity index 100% rename from srv/LightControl.srv rename to wrp_sdk_msgs/srv/LightControl.srv diff --git a/srv/MotionReset.srv b/wrp_sdk_msgs/srv/MotionReset.srv similarity index 100% rename from srv/MotionReset.srv rename to wrp_sdk_msgs/srv/MotionReset.srv diff --git a/srv/PowerRegulatorControl.srv b/wrp_sdk_msgs/srv/PowerRegulatorControl.srv similarity index 100% rename from srv/PowerRegulatorControl.srv rename to wrp_sdk_msgs/srv/PowerRegulatorControl.srv diff --git a/wrp_sdk_periph/CMakeLists.txt b/wrp_sdk_periph/CMakeLists.txt new file mode 100644 index 0000000..96325bd --- /dev/null +++ b/wrp_sdk_periph/CMakeLists.txt @@ -0,0 +1,83 @@ +cmake_minimum_required(VERSION 3.0.2) +project(wrp_sdk_periph) + +# # Compile as C++11, supported in ROS Kinetic and newer +add_compile_options(-std=c++11) + +string(REPLACE ":" ";" CMAKE_PREFIX_PATH "$ENV{CMAKE_PREFIX_PATH}") +list(APPEND CMAKE_PREFIX_PATH "/opt/weston_robot/lib/cmake") + +find_package(PkgConfig REQUIRED) +pkg_check_modules(LelyIO QUIET IMPORTED_TARGET liblely-io2) +pkg_check_modules(LelyCOAPP QUIET IMPORTED_TARGET liblely-coapp) + +set(BUILD_CANOPEN_SUPPORT OFF) + +if(LelyIO_FOUND AND LelyCOAPP_FOUND) + message(STATUS "Lely-core libraries found, peripheral module will be included") + set(BUILD_CANOPEN_SUPPORT ON) +else() + message(WARNING "CANopen-related dependencies are not found, ROS nodes for peripherals will not be built. Run the following commands to install the missing libraries: + $ sudo apt-get install -y software-properties-common + $ sudo add-apt-repository ppa:lely/ppa && sudo apt-get update + $ sudo apt-get install -y pkg-config liblely-coapp-dev liblely-co-tools") +endif() + +# # Find catkin macros and libraries +# # if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz) +# # is used, also find other catkin packages +find_package(catkin REQUIRED COMPONENTS + roscpp + wrp_sdk_msgs + actionlib +) + +find_package(wrp_sdk 1.3 REQUIRED) + +# ################################## +# # catkin specific configuration ## +# ################################## +catkin_package( + INCLUDE_DIRS include + LIBRARIES ${PROJECT_NAME} + CATKIN_DEPENDS roscpp wrp_sdk_msgs actionlib + DEPENDS wrp_sdk +) + +# ########## +# # Build ## +# ########## +include_directories( + include + ${catkin_INCLUDE_DIRS} +) + +add_executable(lift_controller_node src/lift_controller_node.cpp) +target_link_libraries(lift_controller_node westonrobot::wrp_sdk_peripheral ${catkin_LIBRARIES}) +add_dependencies(lift_controller_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS}) + +add_executable(ultrasonic_sensor_node src/ultrasonic_sensor_node.cpp) +target_link_libraries(ultrasonic_sensor_node westonrobot::wrp_sdk_peripheral ${catkin_LIBRARIES}) +add_dependencies(ultrasonic_sensor_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS}) + +# canopen device support +if(BUILD_CANOPEN_SUPPORT) + add_executable(gps_receiver_node src/gps_receiver_node.cpp) + target_link_libraries(gps_receiver_node westonrobot::wrp_sdk ${catkin_LIBRARIES}) + add_dependencies(gps_receiver_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS}) + + add_executable(imu_sensor_node src/imu_sensor_node.cpp) + target_link_libraries(imu_sensor_node westonrobot::wrp_sdk ${catkin_LIBRARIES}) + add_dependencies(imu_sensor_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS}) + + add_executable(power_regulator_node src/power_regulator_node.cpp) + target_link_libraries(power_regulator_node westonrobot::wrp_sdk ${catkin_LIBRARIES}) + add_dependencies(power_regulator_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS}) +endif() + +## Mark cpp header files for installation +install(DIRECTORY include/${PROJECT_NAME}/ + DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION} + FILES_MATCHING PATTERN "*.h" + PATTERN ".svn" EXCLUDE +) \ No newline at end of file diff --git a/config/peripheral/gps_receiver_node_config.yaml b/wrp_sdk_periph/config/gps_receiver_node_config.yaml similarity index 100% rename from config/peripheral/gps_receiver_node_config.yaml rename to wrp_sdk_periph/config/gps_receiver_node_config.yaml diff --git a/config/peripheral/imu_sensor_node_config.yaml b/wrp_sdk_periph/config/imu_sensor_node_config.yaml similarity index 100% rename from config/peripheral/imu_sensor_node_config.yaml rename to wrp_sdk_periph/config/imu_sensor_node_config.yaml diff --git a/config/peripheral/power_regulator_node_config.yaml b/wrp_sdk_periph/config/power_regulator_node_config.yaml similarity index 100% rename from config/peripheral/power_regulator_node_config.yaml rename to wrp_sdk_periph/config/power_regulator_node_config.yaml diff --git a/config/peripheral/ultrasonic_sensor_node_config.yaml b/wrp_sdk_periph/config/ultrasonic_sensor_node_config.yaml similarity index 100% rename from config/peripheral/ultrasonic_sensor_node_config.yaml rename to wrp_sdk_periph/config/ultrasonic_sensor_node_config.yaml diff --git a/include/wrp_ros/peripheral/gps_receiver_node.hpp b/wrp_sdk_periph/include/wrp_sdk_periph/gps_receiver_node.hpp similarity index 100% rename from include/wrp_ros/peripheral/gps_receiver_node.hpp rename to wrp_sdk_periph/include/wrp_sdk_periph/gps_receiver_node.hpp diff --git a/include/wrp_ros/peripheral/imu_sensor_node.hpp b/wrp_sdk_periph/include/wrp_sdk_periph/imu_sensor_node.hpp similarity index 100% rename from include/wrp_ros/peripheral/imu_sensor_node.hpp rename to wrp_sdk_periph/include/wrp_sdk_periph/imu_sensor_node.hpp diff --git a/include/wrp_ros/peripheral/lift_controller_node.hpp b/wrp_sdk_periph/include/wrp_sdk_periph/lift_controller_node.hpp similarity index 65% rename from include/wrp_ros/peripheral/lift_controller_node.hpp rename to wrp_sdk_periph/include/wrp_sdk_periph/lift_controller_node.hpp index de34c47..b0aa9cf 100644 --- a/include/wrp_ros/peripheral/lift_controller_node.hpp +++ b/wrp_sdk_periph/include/wrp_sdk_periph/lift_controller_node.hpp @@ -15,11 +15,12 @@ #include #include -#include -#include -#include #include "wrp_sdk/peripheral/lift_controller.hpp" +#include +#include +#include + namespace westonrobot { class LiftControllerNode { public: @@ -31,18 +32,18 @@ class LiftControllerNode { std::string device_path_ = "/dev/ttyUSB0"; ros::NodeHandle nh_; - ros::Publisher lift_status_pub_; + ros::Publisher lift_state_pub_; ros::ServiceServer query_server_; - actionlib::SimpleActionServer lift_control_server_; + actionlib::SimpleActionServer lift_control_server_; - wrp_ros::LiftStatus lift_status_; + wrp_sdk_msgs::LiftState lift_state_; LiftController lift_controller_; void PublishLiftState(void); static void ExitSignalHandler(int sig); - void LiftControllerCallback(const wrp_ros::LiftControlGoalConstPtr& goal); - bool QueryCallback(wrp_ros::LiftQuery::Request& req, - wrp_ros::LiftQuery::Response& res); + void LiftControllerCallback(const wrp_sdk_msgs::LiftControlGoalConstPtr& goal); + bool QueryCallback(wrp_sdk_msgs::LiftQuery::Request& req, + wrp_sdk_msgs::LiftQuery::Response& res); bool ReadParameters(void); }; } // namespace westonrobot diff --git a/include/wrp_ros/peripheral/power_regulator_node.hpp b/wrp_sdk_periph/include/wrp_sdk_periph/power_regulator_node.hpp similarity index 75% rename from include/wrp_ros/peripheral/power_regulator_node.hpp rename to wrp_sdk_periph/include/wrp_sdk_periph/power_regulator_node.hpp index 50410db..5cdd800 100644 --- a/include/wrp_ros/peripheral/power_regulator_node.hpp +++ b/wrp_sdk_periph/include/wrp_sdk_periph/power_regulator_node.hpp @@ -13,8 +13,8 @@ #include #include -#include "wrp_ros/PowerRegulatorDeviceState.h" -#include "wrp_ros/PowerRegulatorControl.h" +#include "wrp_sdk_msgs/PowerRegulatorDeviceState.h" +#include "wrp_sdk_msgs/PowerRegulatorControl.h" #include "wrp_sdk/interface/power_regulator_interface.hpp" @@ -34,8 +34,8 @@ class PowerRegulatorNode { ros::ServiceServer cmd_service_; void PublishCallback(const PowerRegulatorInterface::DeviceState& data); - bool HandleCommand(wrp_ros::PowerRegulatorControl::Request& req, - wrp_ros::PowerRegulatorControl::Response& res); + bool HandleCommand(wrp_sdk_msgs::PowerRegulatorControl::Request& req, + wrp_sdk_msgs::PowerRegulatorControl::Response& res); bool ReadParameters(); }; } // namespace westonrobot diff --git a/include/wrp_ros/peripheral/ultrasonic_sensor_node.hpp b/wrp_sdk_periph/include/wrp_sdk_periph/ultrasonic_sensor_node.hpp similarity index 100% rename from include/wrp_ros/peripheral/ultrasonic_sensor_node.hpp rename to wrp_sdk_periph/include/wrp_sdk_periph/ultrasonic_sensor_node.hpp diff --git a/wrp_sdk_periph/launch/gps_receiver.launch b/wrp_sdk_periph/launch/gps_receiver.launch new file mode 100644 index 0000000..a17cb85 --- /dev/null +++ b/wrp_sdk_periph/launch/gps_receiver.launch @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/wrp_sdk_periph/launch/imu_sensor.launch b/wrp_sdk_periph/launch/imu_sensor.launch new file mode 100644 index 0000000..b5d691f --- /dev/null +++ b/wrp_sdk_periph/launch/imu_sensor.launch @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/wrp_sdk_periph/launch/power_regulator.launch b/wrp_sdk_periph/launch/power_regulator.launch new file mode 100644 index 0000000..e09e13b --- /dev/null +++ b/wrp_sdk_periph/launch/power_regulator.launch @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/wrp_sdk_periph/launch/ultrasonic_sensor.launch b/wrp_sdk_periph/launch/ultrasonic_sensor.launch new file mode 100644 index 0000000..12bab29 --- /dev/null +++ b/wrp_sdk_periph/launch/ultrasonic_sensor.launch @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/package.xml b/wrp_sdk_periph/package.xml similarity index 74% rename from package.xml rename to wrp_sdk_periph/package.xml index eea96c2..230d98e 100644 --- a/package.xml +++ b/wrp_sdk_periph/package.xml @@ -1,19 +1,25 @@ - wrp_ros + wrp_sdk_periph 0.0.0 - The wrp_ros package + The wrp_sdk_periph package - Ruixiang Du - Weston Robot + + + + hans.kurnia - BSD + + + + + TODO - + @@ -44,17 +50,10 @@ catkin - message_generation roscpp - sensor_msgs - std_msgs - geometry_msgs - tf2 - tf2_ros + wrp_sdk_msgs actionlib - actionlib_msgs - message_runtime diff --git a/src/peripheral/README.md b/wrp_sdk_periph/src/README.md similarity index 89% rename from src/peripheral/README.md rename to wrp_sdk_periph/src/README.md index 4dbf367..d24bccc 100644 --- a/src/peripheral/README.md +++ b/wrp_sdk_periph/src/README.md @@ -1,4 +1,4 @@ -# wrp_ros peripherals +# wrp_sdk_periph peripherals ## About @@ -47,11 +47,11 @@ ROS wrappers around wrp_sdk peripheral drivers. | Published Topic | Type | Description | | ------------------------ | ---------------------------------- | --------------------------------------- | -| `/power_regulator/state` | wrp_ros::PowerRegulatorDeviceState | Outputs the power regulator state data. | +| `/power_regulator/state` | wrp_sdk_periph::PowerRegulatorDeviceState | Outputs the power regulator state data. | | Service | Type | Description | | ---------------------- | ------------------------------ | ---------------------------------------- | -| `/power_regulator/cmd` | wrp_ros::PowerRegulatorControl | Control power regulator output channels. | +| `/power_regulator/cmd` | wrp_sdk_periph::PowerRegulatorControl | Control power regulator output channels. | | Parameter | Type | Description | | ------------- | ------ | ------------------------------------------------------------ | @@ -61,15 +61,15 @@ ROS wrappers around wrp_sdk peripheral drivers. | Published Topic | Type | Description | | ------------------------------ | ------------------- | ------------------------------------------ | -| `/lift_controller/lift_status` | wrp_ros::LiftStatus | Outputs the lift id and position. | +| `/lift_controller/lift_state` | wrp_sdk_periph::LiftState | Outputs the lift id and position. | | Action | Type | Description | | ----------------------- | -------------------------- | ---------------------------- | -| `/lift_controller/goal` | wrp_ros::LiftControlAction | Provides a goal to the lift. | +| `/lift_controller/goal` | wrp_sdk_periph::LiftControlAction | Provides a goal to the lift. | | Service | Type | Description | | ------------------------------ | ------------------ | ---------------------------------------- | -| `/lift_controller/query_state` | wrp_ros::LiftQuery | Query for state of the provided lift id. | +| `/lift_controller/query_state` | wrp_sdk_periph::LiftQuery | Query for state of the provided lift id. | | Parameter | Type | Description | | ------------- | ------ | ---------------------------------------------------------------- | diff --git a/src/peripheral/gps_receiver_node.cpp b/wrp_sdk_periph/src/gps_receiver_node.cpp similarity index 97% rename from src/peripheral/gps_receiver_node.cpp rename to wrp_sdk_periph/src/gps_receiver_node.cpp index 661c609..bcaaac1 100644 --- a/src/peripheral/gps_receiver_node.cpp +++ b/wrp_sdk_periph/src/gps_receiver_node.cpp @@ -7,7 +7,7 @@ * Copyright (c) 2021 Weston Robot Pte. Ltd. */ -#include "wrp_ros/peripheral/gps_receiver_node.hpp" +#include "wrp_sdk_periph/peripheral/gps_receiver_node.hpp" #include "wrp_sdk/peripheral/gps_receiver_nmea.hpp" diff --git a/src/peripheral/imu_sensor_node.cpp b/wrp_sdk_periph/src/imu_sensor_node.cpp similarity index 98% rename from src/peripheral/imu_sensor_node.cpp rename to wrp_sdk_periph/src/imu_sensor_node.cpp index 1395e42..8360a36 100644 --- a/src/peripheral/imu_sensor_node.cpp +++ b/wrp_sdk_periph/src/imu_sensor_node.cpp @@ -7,7 +7,7 @@ * Copyright (c) 2021 Weston Robot Pte. Ltd. */ -#include "wrp_ros/peripheral/imu_sensor_node.hpp" +#include "wrp_sdk_periph/peripheral/imu_sensor_node.hpp" #include "wrp_sdk/peripheral/imu_sensor_wit.hpp" #include "wrp_sdk/peripheral/imu_sensor_hipnuc.hpp" diff --git a/src/peripheral/lift_controller_node.cpp b/wrp_sdk_periph/src/lift_controller_node.cpp similarity index 76% rename from src/peripheral/lift_controller_node.cpp rename to wrp_sdk_periph/src/lift_controller_node.cpp index 504bc6f..4d0a6ed 100755 --- a/src/peripheral/lift_controller_node.cpp +++ b/wrp_sdk_periph/src/lift_controller_node.cpp @@ -7,13 +7,14 @@ * * @copyright Copyright (c) 2024 Weston Robot Pte. Ltd. */ -#include "wrp_ros/peripheral/lift_controller_node.hpp" +#include "wrp_sdk_periph/lift_controller_node.hpp" + namespace westonrobot { LiftControllerNode::LiftControllerNode() : lift_controller_(), lift_control_server_( nh_, "/lift_controller/goal", - [this](const wrp_ros::LiftControlGoalConstPtr& goal) { + [this](const wrp_sdk_msgs::LiftControlGoalConstPtr& goal) { this->LiftControllerCallback(goal); }, false) { @@ -27,8 +28,8 @@ LiftControllerNode::LiftControllerNode() ros::shutdown(); } - lift_status_pub_ = - nh_.advertise("/lift_controller/lift_status", 10); + lift_state_pub_ = + nh_.advertise("/lift_controller/lift_state", 10); query_server_ = nh_.advertiseService( "/lift_controller/query_state", &LiftControllerNode::QueryCallback, this); @@ -44,12 +45,12 @@ LiftControllerNode::~LiftControllerNode() { } void LiftControllerNode::LiftControllerCallback( - const wrp_ros::LiftControlGoalConstPtr& goal) { - wrp_ros::LiftControlFeedback feedback; - wrp_ros::LiftControlResult result; + const wrp_sdk_msgs::LiftControlGoalConstPtr& goal) { + wrp_sdk_msgs::LiftControlFeedback feedback; + wrp_sdk_msgs::LiftControlResult result; - if (goal->id != lift_status_.LIFT_HORIZONTAL && - goal->id != lift_status_.LIFT_VERTICAL) { + if (goal->id != lift_state_.LIFT_HORIZONTAL && + goal->id != lift_state_.LIFT_VERTICAL) { ROS_ERROR("Invalid id. Valid id are 0 (horizontal) and 1 (vertical)"); result.id = goal->id; lift_control_server_.setAborted(result, "Invalid id"); @@ -79,10 +80,10 @@ void LiftControllerNode::LiftControllerCallback( lift_control_server_.setSucceeded(result); } -bool LiftControllerNode::QueryCallback(wrp_ros::LiftQuery::Request& req, - wrp_ros::LiftQuery::Response& res) { - if (req.id != lift_status_.LIFT_HORIZONTAL && - req.id != lift_status_.LIFT_VERTICAL) { +bool LiftControllerNode::QueryCallback(wrp_sdk_msgs::LiftQuery::Request& req, + wrp_sdk_msgs::LiftQuery::Response& res) { + if (req.id != lift_state_.LIFT_HORIZONTAL && + req.id != lift_state_.LIFT_VERTICAL) { ROS_ERROR("Invalid id. Valid id are 0 (horizontal) and 1 (vertical)"); return false; } @@ -96,13 +97,13 @@ bool LiftControllerNode::QueryCallback(wrp_ros::LiftQuery::Request& req, void LiftControllerNode::PublishLiftState() { signal(SIGINT, LiftControllerNode::ExitSignalHandler); while (ros::ok) { - for (uint8_t id = lift_status_.LIFT_HORIZONTAL; - id <= lift_status_.LIFT_VERTICAL; ++id) { + for (uint8_t id = lift_state_.LIFT_HORIZONTAL; + id <= lift_state_.LIFT_VERTICAL; ++id) { LiftState lift_state = lift_controller_.GetLiftState(id); - lift_status_.id = id; - lift_status_.position = lift_state.position; - lift_status_pub_.publish(lift_status_); + lift_state_.id = id; + lift_state_.position = lift_state.position; + lift_state_pub_.publish(lift_state_); } ros::spinOnce(); ros::Rate(10).sleep(); diff --git a/src/peripheral/power_regulator_node.cpp b/wrp_sdk_periph/src/power_regulator_node.cpp similarity index 85% rename from src/peripheral/power_regulator_node.cpp rename to wrp_sdk_periph/src/power_regulator_node.cpp index 2245ed9..ec7e810 100644 --- a/src/peripheral/power_regulator_node.cpp +++ b/wrp_sdk_periph/src/power_regulator_node.cpp @@ -7,7 +7,7 @@ * Copyright (c) 2021 Weston Robot Pte. Ltd. */ -#include "wrp_ros/peripheral/power_regulator_node.hpp" +#include "wrp_sdk_periph/peripheral/power_regulator_node.hpp" #include "wrp_sdk/peripheral/power_regulator_v2.hpp" @@ -25,7 +25,7 @@ PowerRegulatorNode::PowerRegulatorNode() { ros::shutdown(); } - state_pub_ = nh_.advertise( + state_pub_ = nh_.advertise( "/power_regulator/state", 5); cmd_service_ = nh_.advertiseService("/power_regulator/cmd", @@ -38,21 +38,21 @@ PowerRegulatorNode::PowerRegulatorNode() { PowerRegulatorNode::~PowerRegulatorNode() { ros::shutdown(); } bool PowerRegulatorNode::HandleCommand( - wrp_ros::PowerRegulatorControl::Request& req, - wrp_ros::PowerRegulatorControl::Response& res) { + wrp_sdk_periph::PowerRegulatorControl::Request& req, + wrp_sdk_periph::PowerRegulatorControl::Response& res) { ROS_INFO("Power regulator channel: %d, %d", req.channel, req.enable); PowerRegulatorInterface::OutputChannel chn; - if (req.channel == wrp_ros::PowerRegulatorControl::Request::CHANNEL_19V) { + if (req.channel == wrp_sdk_periph::PowerRegulatorControl::Request::CHANNEL_19V) { chn = PowerRegulatorV2::kChannel19V; } else if (req.channel == - wrp_ros::PowerRegulatorControl::Request::CHANNEL_12V) { + wrp_sdk_periph::PowerRegulatorControl::Request::CHANNEL_12V) { chn = PowerRegulatorV2::kChannel12V; } else if (req.channel == - wrp_ros::PowerRegulatorControl::Request::CHANNEL_5VI) { + wrp_sdk_periph::PowerRegulatorControl::Request::CHANNEL_5VI) { chn = PowerRegulatorV2::kChannel5Vi; } else if (req.channel == - wrp_ros::PowerRegulatorControl::Request::CHANNEL_12VI) { + wrp_sdk_periph::PowerRegulatorControl::Request::CHANNEL_12VI) { chn = PowerRegulatorV2::kChannel12Vi; } else { res.state = false; @@ -68,7 +68,7 @@ void PowerRegulatorNode::PublishCallback( const PowerRegulatorInterface::DeviceState& data) { // ROS_INFO("regulator msg received"); - wrp_ros::PowerRegulatorDeviceState state_msg; + wrp_sdk_periph::PowerRegulatorDeviceState state_msg; state_msg.input_voltage = data.input_voltage; state_msg.fan_speed = data.fan_speed; diff --git a/src/peripheral/ultrasonic_sensor_node.cpp b/wrp_sdk_periph/src/ultrasonic_sensor_node.cpp similarity index 97% rename from src/peripheral/ultrasonic_sensor_node.cpp rename to wrp_sdk_periph/src/ultrasonic_sensor_node.cpp index efd0fa6..e3f9716 100644 --- a/src/peripheral/ultrasonic_sensor_node.cpp +++ b/wrp_sdk_periph/src/ultrasonic_sensor_node.cpp @@ -7,7 +7,7 @@ * Copyright (c) 2021 Weston Robot Pte. Ltd. */ -#include "wrp_ros/peripheral/ultrasonic_sensor_node.hpp" +#include "wrp_sdk_periph/ultrasonic_sensor_node.hpp" #include "wrp_sdk/peripheral/ultrasonic_sensor_dyp.hpp" #include "wrp_sdk/peripheral/ultrasonic_sensor_w200d.hpp" diff --git a/wrp_sdk_robot/CMakeLists.txt b/wrp_sdk_robot/CMakeLists.txt new file mode 100644 index 0000000..5d46fb6 --- /dev/null +++ b/wrp_sdk_robot/CMakeLists.txt @@ -0,0 +1,52 @@ +cmake_minimum_required(VERSION 3.0.2) +project(wrp_sdk_robot) + +# # Compile as C++11, supported in ROS Kinetic and newer +add_compile_options(-std=c++11) + +string(REPLACE ":" ";" CMAKE_PREFIX_PATH "$ENV{CMAKE_PREFIX_PATH}") +list(APPEND CMAKE_PREFIX_PATH "/opt/weston_robot/lib/cmake") + +# # Find catkin macros and libraries +# # if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz) +# # is used, also find other catkin packages +find_package(catkin REQUIRED COMPONENTS + geometry_msgs + nav_msgs + roscpp + sensor_msgs + tf2 + tf2_ros + wrp_sdk_msgs +) + +find_package(wrp_sdk 1.3 REQUIRED) + +# ################################## +# # catkin specific configuration ## +# ################################## +catkin_package( + INCLUDE_DIRS include + LIBRARIES ${PROJECT_NAME} + CATKIN_DEPENDS geometry_msgs nav_msgs roscpp sensor_msgs tf2 tf2_ros wrp_sdk_msgs + DEPENDS wrp_sdk +) + +# ########## +# # Build ## +# ########## +include_directories( + include + ${catkin_INCLUDE_DIRS} +) + +add_executable(mobile_base_node src/mobile_base_node.cpp) +target_link_libraries(mobile_base_node ${catkin_LIBRARIES} westonrobot::wrp_sdk_robot) +add_dependencies(mobile_base_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS}) + +## Mark cpp header files for installation +install(DIRECTORY include/${PROJECT_NAME}/ + DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION} + FILES_MATCHING PATTERN "*.h" + PATTERN ".svn" EXCLUDE +) \ No newline at end of file diff --git a/include/wrp_ros/mobile_base/mobile_base_ros.hpp b/wrp_sdk_robot/include/wrp_sdk_robot/mobile_base_node.hpp similarity index 61% rename from include/wrp_ros/mobile_base/mobile_base_ros.hpp rename to wrp_sdk_robot/include/wrp_sdk_robot/mobile_base_node.hpp index 2952294..b9bbc17 100644 --- a/include/wrp_ros/mobile_base/mobile_base_ros.hpp +++ b/wrp_sdk_robot/include/wrp_sdk_robot/mobile_base_node.hpp @@ -1,14 +1,12 @@ -/* - * mobile_base_ros.hpp - * - * Created on: Dec 16, 2021 16:13 - * Description: - * - * Copyright (c) 2021 Weston Robot Pte. Ltd. +/** + * @file mobile_base_node.hpp + * @brief + * @date 17-05-2024 + * + * @copyright Copyright (c) 2024 Weston Robot Pte. Ltd. */ - -#ifndef MOBILE_BASE_ROS_HPP -#define MOBILE_BASE_ROS_HPP +#ifndef WRP_SDK_ROBOT_MOBILE_BASE_NODE_HPP +#define WRP_SDK_ROBOT_MOBILE_BASE_NODE_HPP #include @@ -18,20 +16,20 @@ #include #include -#include "wrp_ros/MotionCommand.h" -#include "wrp_ros/AccessControl.h" -#include "wrp_ros/AssistedModeControl.h" -#include "wrp_ros/LightControl.h" -#include "wrp_ros/MotionReset.h" +#include "wrp_sdk_msgs/MotionCommand.h" +#include "wrp_sdk_msgs/AccessControl.h" +#include "wrp_sdk_msgs/AssistedModeControl.h" +#include "wrp_sdk_msgs/LightControl.h" +#include "wrp_sdk_msgs/MotionReset.h" #include "wrp_sdk/interface/mobile_robot_interface.hpp" namespace westonrobot { -class MobileBaseRos { +class MobileBaseNode { public: - MobileBaseRos(ros::NodeHandle* nh); - ~MobileBaseRos() = default; + MobileBaseNode(ros::NodeHandle* nh); + ~MobileBaseNode() = default; void SetAutoReconnect(bool enable); @@ -87,15 +85,15 @@ class MobileBaseRos { void MotionCmdCallback(const geometry_msgs::Twist::ConstPtr& msg); - bool HandleAccessControl(wrp_ros::AccessControl::Request& req, - wrp_ros::AccessControl::Response& res); - bool HandleAssistedModeControl(wrp_ros::AssistedModeControl::Request& req, - wrp_ros::AssistedModeControl::Response& res); - bool HandleLightControl(wrp_ros::LightControl::Request& req, - wrp_ros::LightControl::Response& res); - bool HandleMotionReset(wrp_ros::MotionReset::Request& req, - wrp_ros::MotionReset::Response& res); + bool HandleAccessControl(wrp_sdk_msgs::AccessControl::Request& req, + wrp_sdk_msgs::AccessControl::Response& res); + bool HandleAssistedModeControl(wrp_sdk_msgs::AssistedModeControl::Request& req, + wrp_sdk_msgs::AssistedModeControl::Response& res); + bool HandleLightControl(wrp_sdk_msgs::LightControl::Request& req, + wrp_sdk_msgs::LightControl::Response& res); + bool HandleMotionReset(wrp_sdk_msgs::MotionReset::Request& req, + wrp_sdk_msgs::MotionReset::Response& res); }; } // namespace westonrobot -#endif /* MOBILE_BASE_ROS_HPP */ +#endif /* WRP_SDK_ROBOT_MOBILE_BASE_NODE_HPP */ diff --git a/launch/description/scout_mini_description.launch b/wrp_sdk_robot/launch/description/scout_mini_description.launch similarity index 75% rename from launch/description/scout_mini_description.launch rename to wrp_sdk_robot/launch/description/scout_mini_description.launch index 804a402..996b683 100644 --- a/launch/description/scout_mini_description.launch +++ b/wrp_sdk_robot/launch/description/scout_mini_description.launch @@ -1,5 +1,5 @@ - + diff --git a/launch/description/scout_v2_description.launch b/wrp_sdk_robot/launch/description/scout_v2_description.launch similarity index 76% rename from launch/description/scout_v2_description.launch rename to wrp_sdk_robot/launch/description/scout_v2_description.launch index 6a7e1ce..9fe2f72 100644 --- a/launch/description/scout_v2_description.launch +++ b/wrp_sdk_robot/launch/description/scout_v2_description.launch @@ -1,5 +1,5 @@ - + diff --git a/launch/mobile_base/scout.launch b/wrp_sdk_robot/launch/mobile_base/scout.launch similarity index 91% rename from launch/mobile_base/scout.launch rename to wrp_sdk_robot/launch/mobile_base/scout.launch index 4d665d5..7d9705c 100644 --- a/launch/mobile_base/scout.launch +++ b/wrp_sdk_robot/launch/mobile_base/scout.launch @@ -12,7 +12,7 @@ - + diff --git a/launch/mobile_base/scout_mini.launch b/wrp_sdk_robot/launch/mobile_base/scout_mini.launch similarity index 91% rename from launch/mobile_base/scout_mini.launch rename to wrp_sdk_robot/launch/mobile_base/scout_mini.launch index c2b9a6b..f8b9999 100644 --- a/launch/mobile_base/scout_mini.launch +++ b/wrp_sdk_robot/launch/mobile_base/scout_mini.launch @@ -12,7 +12,7 @@ - + diff --git a/launch/mobile_base/tracer.launch b/wrp_sdk_robot/launch/mobile_base/tracer.launch similarity index 91% rename from launch/mobile_base/tracer.launch rename to wrp_sdk_robot/launch/mobile_base/tracer.launch index e995012..29b5da4 100644 --- a/launch/mobile_base/tracer.launch +++ b/wrp_sdk_robot/launch/mobile_base/tracer.launch @@ -12,7 +12,7 @@ - + diff --git a/meshes/scout_mini/mini_base_link.dae b/wrp_sdk_robot/meshes/scout_mini/mini_base_link.dae similarity index 100% rename from meshes/scout_mini/mini_base_link.dae rename to wrp_sdk_robot/meshes/scout_mini/mini_base_link.dae diff --git a/meshes/scout_mini/mini_wheel.dae b/wrp_sdk_robot/meshes/scout_mini/mini_wheel.dae similarity index 100% rename from meshes/scout_mini/mini_wheel.dae rename to wrp_sdk_robot/meshes/scout_mini/mini_wheel.dae diff --git a/meshes/scout_v2/base_link.dae b/wrp_sdk_robot/meshes/scout_v2/base_link.dae similarity index 100% rename from meshes/scout_v2/base_link.dae rename to wrp_sdk_robot/meshes/scout_v2/base_link.dae diff --git a/meshes/scout_v2/wheel_type1.dae b/wrp_sdk_robot/meshes/scout_v2/wheel_type1.dae similarity index 100% rename from meshes/scout_v2/wheel_type1.dae rename to wrp_sdk_robot/meshes/scout_v2/wheel_type1.dae diff --git a/meshes/scout_v2/wheel_type2.dae b/wrp_sdk_robot/meshes/scout_v2/wheel_type2.dae similarity index 100% rename from meshes/scout_v2/wheel_type2.dae rename to wrp_sdk_robot/meshes/scout_v2/wheel_type2.dae diff --git a/wrp_sdk_robot/package.xml b/wrp_sdk_robot/package.xml new file mode 100644 index 0000000..30e703a --- /dev/null +++ b/wrp_sdk_robot/package.xml @@ -0,0 +1,68 @@ + + + wrp_sdk_robot + 0.0.0 + The wrp_sdk_robot package + + + + + hans.kurnia + + + + + + TODO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + catkin + + geometry_msgs + nav_msgs + roscpp + sensor_msgs + tf2 + tf2_ros + wrp_sdk_msgs + xacro + + + + + + + + diff --git a/src/mobile_base/mobile_base_ros.cpp b/wrp_sdk_robot/src/mobile_base_node.cpp similarity index 76% rename from src/mobile_base/mobile_base_ros.cpp rename to wrp_sdk_robot/src/mobile_base_node.cpp index fd52079..1d50c9f 100644 --- a/src/mobile_base/mobile_base_ros.cpp +++ b/wrp_sdk_robot/src/mobile_base_node.cpp @@ -1,13 +1,11 @@ -/* - * mobile_base.cpp - * - * Created on: Dec 16, 2021 16:13 - * Description: - * - * Copyright (c) 2021 Weston Robot Pte. Ltd. +/** + * @file mobile_base_ros.cpp + * @brief + * @date 17-05-2024 + * + * @copyright Copyright (c) 2024 Weston Robot Pte. Ltd. */ - -#include "wrp_ros/mobile_base/mobile_base_ros.hpp" +#include "wrp_sdk_robot/mobile_base_node.hpp" #include @@ -20,19 +18,19 @@ #include -#include "wrp_ros/SystemState.h" -#include "wrp_ros/MotionState.h" -#include "wrp_ros/ActuatorStateArray.h" -#include "wrp_ros/RangeData.h" +#include "wrp_sdk_msgs/SystemState.h" +#include "wrp_sdk_msgs/MotionState.h" +#include "wrp_sdk_msgs/ActuatorStateArray.h" +#include "wrp_sdk_msgs/RangeData.h" namespace westonrobot { -MobileBaseRos::MobileBaseRos(ros::NodeHandle* nh) : nh_(nh) { - if (!MobileBaseRos::ReadParameters()) { +MobileBaseNode::MobileBaseNode(ros::NodeHandle* nh) : nh_(nh) { + if (!MobileBaseNode::ReadParameters()) { ROS_ERROR("Could not load parameters"); ros::shutdown(); } - if (!MobileBaseRos::SetupRobot()) { + if (!MobileBaseNode::SetupRobot()) { ROS_ERROR("Failed to setup robot"); ros::shutdown(); } @@ -41,7 +39,7 @@ MobileBaseRos::MobileBaseRos(ros::NodeHandle* nh) : nh_(nh) { SetupService(); } -bool MobileBaseRos::ReadParameters() { +bool MobileBaseNode::ReadParameters() { nh_->getParam("can_device", can_device_); nh_->getParam("robot_type", robot_type_); nh_->getParam("base_frame", base_frame_); @@ -62,7 +60,7 @@ bool MobileBaseRos::ReadParameters() { return true; } -bool MobileBaseRos::SetupRobot() { +bool MobileBaseNode::SetupRobot() { // create appropriate adapter if (robot_type_ == "weston") { robot_ = std::make_shared(); @@ -93,42 +91,42 @@ bool MobileBaseRos::SetupRobot() { return true; } -void MobileBaseRos::SetupSubscription() { +void MobileBaseNode::SetupSubscription() { // publishers system_state_publisher_ = - nh_->advertise("/system_state", 10); + nh_->advertise("/system_state", 10); motion_state_publisher_ = - nh_->advertise("/motion_state", 10); + nh_->advertise("/motion_state", 10); actuator_state_publisher_ = - nh_->advertise("/actuator_state", 10); + nh_->advertise("/actuator_state", 10); odom_publisher_ = nh_->advertise("/odom", 50); battery_state_publisher_ = nh_->advertise("/battery_state", 10); // subscribers motion_cmd_subscriber_ = nh_->subscribe( - "/cmd_vel", 5, &MobileBaseRos::MotionCmdCallback, this); + "/cmd_vel", 5, &MobileBaseNode::MotionCmdCallback, this); } -void MobileBaseRos::SetupService() { +void MobileBaseNode::SetupService() { access_control_service_ = nh_->advertiseService( - "access_control", &MobileBaseRos::HandleAccessControl, this); + "access_control", &MobileBaseNode::HandleAccessControl, this); assisted_mode_control_service_ = nh_->advertiseService( - "assisted_mode_control", &MobileBaseRos::HandleAssistedModeControl, this); + "assisted_mode_control", &MobileBaseNode::HandleAssistedModeControl, this); light_control_service_ = nh_->advertiseService( - "light_control", &MobileBaseRos::HandleLightControl, this); + "light_control", &MobileBaseNode::HandleLightControl, this); motion_reset_service_ = nh_->advertiseService( - "motion_reset", &MobileBaseRos::HandleMotionReset, this); + "motion_reset", &MobileBaseNode::HandleMotionReset, this); } -void MobileBaseRos::PublishRobotState() { +void MobileBaseNode::PublishRobotState() { auto system_state = robot_->GetSystemState(); auto motion_state = robot_->GetMotionState(); auto actuator_state = robot_->GetActuatorState(); auto battery_state = robot_->GetBatteryState(); // system state - wrp_ros::SystemState system_state_msg; + wrp_sdk_msgs::SystemState system_state_msg; system_state_msg.rc_connected = system_state.rc_connected; system_state_msg.error_code = static_cast(system_state.error_code); system_state_msg.operational_state = @@ -139,7 +137,7 @@ void MobileBaseRos::PublishRobotState() { system_state_publisher_.publish(system_state_msg); // motion state - wrp_ros::MotionState motion_state_msg; + wrp_sdk_msgs::MotionState motion_state_msg; motion_state_msg.desired_linear.x = motion_state.desired_linear.x; motion_state_msg.desired_linear.y = motion_state.desired_linear.y; motion_state_msg.desired_linear.z = motion_state.desired_linear.z; @@ -154,9 +152,9 @@ void MobileBaseRos::PublishRobotState() { motion_state_publisher_.publish(motion_state_msg); // actuator state - wrp_ros::ActuatorStateArray actuator_state_msg; + wrp_sdk_msgs::ActuatorStateArray actuator_state_msg; for (int i = 0; i < actuator_state.size(); ++i) { - wrp_ros::ActuatorState actuator_msg; + wrp_sdk_msgs::ActuatorState actuator_msg; actuator_msg.id = actuator_state[i].id; actuator_msg.motor.rpm = actuator_state[i].motor.rpm; actuator_msg.motor.current = actuator_state[i].motor.current; @@ -191,11 +189,11 @@ void MobileBaseRos::PublishRobotState() { battery_state_publisher_.publish(battery_state_msg); } -void MobileBaseRos::PublishSensorData() { +void MobileBaseNode::PublishSensorData() { // TODO } -void MobileBaseRos::PublishWheelOdometry() { +void MobileBaseNode::PublishWheelOdometry() { auto robot_odom = robot_->GetOdometry(); // ATTN: odometry directly from wrp_sdk still in progress @@ -207,7 +205,7 @@ void MobileBaseRos::PublishWheelOdometry() { robot_twist.angular.y = robot_odom.angular.y; robot_twist.angular.z = robot_odom.angular.z; - nav_msgs::Odometry odom_msg = MobileBaseRos::CalculateOdometry(robot_twist); + nav_msgs::Odometry odom_msg = MobileBaseNode::CalculateOdometry(robot_twist); // publish tf transformation geometry_msgs::TransformStamped tf_msg; @@ -224,7 +222,7 @@ void MobileBaseRos::PublishWheelOdometry() { odom_publisher_.publish(odom_msg); } -nav_msgs::Odometry MobileBaseRos::CalculateOdometry( +nav_msgs::Odometry MobileBaseNode::CalculateOdometry( geometry_msgs::Twist robot_twist) { auto current_time = ros::Time::now(); float dt = (current_time - last_time_).toSec(); @@ -265,7 +263,7 @@ nav_msgs::Odometry MobileBaseRos::CalculateOdometry( return odom_msg; } -void MobileBaseRos::MotionCmdCallback( +void MobileBaseNode::MotionCmdCallback( const geometry_msgs::Twist::ConstPtr& msg) { MotionCommand cmd; @@ -280,23 +278,23 @@ void MobileBaseRos::MotionCmdCallback( // ROS_INFO("CMD received:%f, %f", msg->linear.x, msg->angular.z); } -bool MobileBaseRos::HandleAccessControl(wrp_ros::AccessControl::Request& req, - wrp_ros::AccessControl::Response& res) { +bool MobileBaseNode::HandleAccessControl(wrp_sdk_msgs::AccessControl::Request& req, + wrp_sdk_msgs::AccessControl::Response& res) { if (req.action_type == - wrp_ros::AccessControl::Request::ACTION_TYPE_REQUEST_CONTROL) { + wrp_sdk_msgs::AccessControl::Request::ACTION_TYPE_REQUEST_CONTROL) { auto result = robot_->RequestControl(); res.result_code = static_cast(result); } else if (req.action_type == - wrp_ros::AccessControl::Request::ACTION_TYPE_RENOUNCE_CONTROL) { + wrp_sdk_msgs::AccessControl::Request::ACTION_TYPE_RENOUNCE_CONTROL) { auto result = robot_->RenounceControl(); res.result_code = static_cast(result); } return true; } -bool MobileBaseRos::HandleAssistedModeControl( - wrp_ros::AssistedModeControl::Request& req, - wrp_ros::AssistedModeControl::Response& res) { +bool MobileBaseNode::HandleAssistedModeControl( + wrp_sdk_msgs::AssistedModeControl::Request& req, + wrp_sdk_msgs::AssistedModeControl::Response& res) { AssistedModeSetCommand cmd; cmd.enable = req.enable; robot_->SetAssistedMode(cmd); @@ -304,8 +302,8 @@ bool MobileBaseRos::HandleAssistedModeControl( return true; } -bool MobileBaseRos::HandleLightControl(wrp_ros::LightControl::Request& req, - wrp_ros::LightControl::Response& res) { +bool MobileBaseNode::HandleLightControl(wrp_sdk_msgs::LightControl::Request& req, + wrp_sdk_msgs::LightControl::Response& res) { LightCommand cmd; cmd.id = req.id; @@ -321,25 +319,25 @@ bool MobileBaseRos::HandleLightControl(wrp_ros::LightControl::Request& req, return true; } -bool MobileBaseRos::HandleMotionReset(wrp_ros::MotionReset::Request& req, - wrp_ros::MotionReset::Response& res) { +bool MobileBaseNode::HandleMotionReset(wrp_sdk_msgs::MotionReset::Request& req, + wrp_sdk_msgs::MotionReset::Response& res) { MotionResetCommand cmd; cmd.type = static_cast(req.type); if (robot_->SdkHasControlToken()) { robot_->SetMotionResetCommand(cmd); - res.result_code = wrp_ros::MotionReset::Response::MOTION_RESET_SUCCCESS; + res.result_code = wrp_sdk_msgs::MotionReset::Response::MOTION_RESET_SUCCCESS; } else { - res.result_code = wrp_ros::MotionReset::Response::MOTION_RESET_FAILURE; + res.result_code = wrp_sdk_msgs::MotionReset::Response::MOTION_RESET_FAILURE; } return true; } -void MobileBaseRos::SetAutoReconnect(bool enable) { auto_reconnect_ = enable; } +void MobileBaseNode::SetAutoReconnect(bool enable) { auto_reconnect_ = enable; } -void MobileBaseRos::Run(double loop_hz) { +void MobileBaseNode::Run(double loop_hz) { loop_period_ = 1.0 / loop_hz; ros::Rate rate(loop_hz); while (ros::ok()) { @@ -359,4 +357,16 @@ void MobileBaseRos::Run(double loop_hz) { rate.sleep(); } } -} // namespace westonrobot \ No newline at end of file +} // namespace westonrobot + +int main(int argc, char **argv) { + // setup ROS node + ros::init(argc, argv, "mobile_base_node"); + ros::NodeHandle node("~"); + + westonrobot::MobileBaseNode base(&node); + + base.Run(50); + + return 0; +} \ No newline at end of file diff --git a/urdf/scout_mini/scout_mini.urdf b/wrp_sdk_robot/urdf/scout_mini/scout_mini.urdf similarity index 100% rename from urdf/scout_mini/scout_mini.urdf rename to wrp_sdk_robot/urdf/scout_mini/scout_mini.urdf diff --git a/urdf/scout_mini/scout_mini.xacro b/wrp_sdk_robot/urdf/scout_mini/scout_mini.xacro similarity index 93% rename from urdf/scout_mini/scout_mini.xacro rename to wrp_sdk_robot/urdf/scout_mini/scout_mini.xacro index f241620..397e5f2 100644 --- a/urdf/scout_mini/scout_mini.xacro +++ b/wrp_sdk_robot/urdf/scout_mini/scout_mini.xacro @@ -5,7 +5,7 @@ - + @@ -28,7 +28,7 @@ - + diff --git a/urdf/scout_mini/scout_mini_wheel.xacro b/wrp_sdk_robot/urdf/scout_mini/scout_mini_wheel.xacro similarity index 96% rename from urdf/scout_mini/scout_mini_wheel.xacro rename to wrp_sdk_robot/urdf/scout_mini/scout_mini_wheel.xacro index 5a27afa..0368666 100644 --- a/urdf/scout_mini/scout_mini_wheel.xacro +++ b/wrp_sdk_robot/urdf/scout_mini/scout_mini_wheel.xacro @@ -38,7 +38,7 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSI - + diff --git a/urdf/scout_v2/scout_v2.urdf b/wrp_sdk_robot/urdf/scout_v2/scout_v2.urdf similarity index 90% rename from urdf/scout_v2/scout_v2.urdf rename to wrp_sdk_robot/urdf/scout_v2/scout_v2.urdf index 0b3e34d..5a7997d 100644 --- a/urdf/scout_v2/scout_v2.urdf +++ b/wrp_sdk_robot/urdf/scout_v2/scout_v2.urdf @@ -9,7 +9,7 @@ - + @@ -39,7 +39,7 @@ - + @@ -64,7 +64,7 @@ - + @@ -89,7 +89,7 @@ - + @@ -114,7 +114,7 @@ - + diff --git a/urdf/scout_v2/scout_v2.xacro b/wrp_sdk_robot/urdf/scout_v2/scout_v2.xacro similarity index 91% rename from urdf/scout_v2/scout_v2.xacro rename to wrp_sdk_robot/urdf/scout_v2/scout_v2.xacro index e06af87..e7d7524 100644 --- a/urdf/scout_v2/scout_v2.xacro +++ b/wrp_sdk_robot/urdf/scout_v2/scout_v2.xacro @@ -5,8 +5,8 @@ - - + + @@ -28,7 +28,7 @@ - + diff --git a/urdf/scout_v2/scout_wheel_type1.xacro b/wrp_sdk_robot/urdf/scout_v2/scout_wheel_type1.xacro similarity index 96% rename from urdf/scout_v2/scout_wheel_type1.xacro rename to wrp_sdk_robot/urdf/scout_v2/scout_wheel_type1.xacro index bb8b5dc..07cae90 100644 --- a/urdf/scout_v2/scout_wheel_type1.xacro +++ b/wrp_sdk_robot/urdf/scout_v2/scout_wheel_type1.xacro @@ -37,7 +37,7 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSI - + diff --git a/urdf/scout_v2/scout_wheel_type2.xacro b/wrp_sdk_robot/urdf/scout_v2/scout_wheel_type2.xacro similarity index 96% rename from urdf/scout_v2/scout_wheel_type2.xacro rename to wrp_sdk_robot/urdf/scout_v2/scout_wheel_type2.xacro index 6440fb8..df90958 100644 --- a/urdf/scout_v2/scout_wheel_type2.xacro +++ b/wrp_sdk_robot/urdf/scout_v2/scout_wheel_type2.xacro @@ -37,7 +37,7 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSI - +