From c83e6f8fa30a9d96a5173eac156a69a928e9c2e2 Mon Sep 17 00:00:00 2001 From: ruffsl Date: Wed, 16 Jun 2021 16:07:07 -0700 Subject: [PATCH] Initial ros2 port --- CMakeLists.txt | 47 ++++++++++++++++++++++++-------------------- msg/BatteryState.msg | 2 +- package.xml | 24 ++++++++++++++++------ 3 files changed, 45 insertions(+), 28 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5c2455e..4211af6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,27 +1,32 @@ -cmake_minimum_required(VERSION 2.8.3) +cmake_minimum_required(VERSION 3.5) project(power_msgs) -find_package(catkin REQUIRED - COMPONENTS - message_generation - std_msgs -) +# Default to C++14 +if(NOT CMAKE_CXX_STANDARD) + set(CMAKE_CXX_STANDARD 14) +endif() -add_message_files( - FILES - BatteryState.msg - BreakerState.msg -) +if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") + add_compile_options(-Wall -Wextra -Wpedantic) +endif() -add_service_files( - FILES - BreakerCommand.srv -) +# find dependencies +find_package(ament_cmake REQUIRED) +find_package(builtin_interfaces REQUIRED) +find_package(rosidl_default_generators REQUIRED) +find_package(std_msgs REQUIRED) -generate_messages(DEPENDENCIES std_msgs) +rosidl_generate_interfaces(${PROJECT_NAME} + "msg/BatteryState.msg" + "msg/BreakerState.msg" + "srv/BreakerCommand.srv" + DEPENDENCIES builtin_interfaces std_msgs) -catkin_package( - CATKIN_DEPENDS - message_runtime - std_msgs -) \ No newline at end of file +if(BUILD_TESTING) + find_package(ament_lint_auto REQUIRED) + ament_lint_auto_find_test_dependencies() +endif() + +ament_export_dependencies(rosidl_default_runtime) + +ament_package() diff --git a/msg/BatteryState.msg b/msg/BatteryState.msg index c1568cc..46cb676 100644 --- a/msg/BatteryState.msg +++ b/msg/BatteryState.msg @@ -10,7 +10,7 @@ bool is_charging # When charging, this is the remaining time until fully charged. # When discharging, this is the time until battery is empty. # Non-zero values are considered valid. -duration remaining_time +builtin_interfaces/Duration remaining_time # Total capacity of battery float32 total_capacity diff --git a/package.xml b/package.xml index 2ba7d9b..c5b847e 100644 --- a/package.xml +++ b/package.xml @@ -1,4 +1,6 @@ - + + + power_msgs 0.4.1 @@ -14,12 +16,22 @@ BSD http://ros.org/wiki/power_msgs - - catkin + ament_cmake + rosidl_default_generators + + builtin_interfaces std_msgs - message_generation - std_msgs - message_runtime + builtin_interfaces + rosidl_default_runtime + std_msgs + + ament_lint_auto + ament_lint_common + + rosidl_interface_packages + + ament_cmake +