From: LeonardoBizzoni Date: Sat, 14 Mar 2026 19:16:58 +0000 (+0100) Subject: config & mode change message&services generation X-Git-Url: http://git.leonardobizzoni.com/?a=commitdiff_plain;h=a935529a9ed3d61f8a733cdbc5753fb5aa344cbc;p=pioneer-stm32 config & mode change message&services generation --- diff --git a/pioneer_workstation_ws/Makefile b/pioneer_workstation_ws/Makefile index 81ed6d5..51d7667 100644 --- a/pioneer_workstation_ws/Makefile +++ b/pioneer_workstation_ws/Makefile @@ -4,8 +4,8 @@ SHELL := /bin/bash run: colcon build - source install/setup.bash && ros2 run pioneer3DX_controller Pioneer3DX_Controller + source install/setup.bash && ros2 run pioneer3dx_controller Pioneer3dx_Controller debug: colcon build --cmake-args -DCMAKE_BUILD_TYPE=RelWithDebInfo - source install/setup.bash && ros2 run --prefix 'gdb -ex start --args' pioneer3DX_controller Pioneer3DX_Controller + source install/setup.bash && ros2 run --prefix 'gdb -ex start --args' pioneer3dx_controller Pioneer3dx_Controller diff --git a/pioneer_workstation_ws/src/pioneer3DX_controller/CMakeLists.txt b/pioneer_workstation_ws/src/pioneer3dx_controller/CMakeLists.txt similarity index 51% rename from pioneer_workstation_ws/src/pioneer3DX_controller/CMakeLists.txt rename to pioneer_workstation_ws/src/pioneer3dx_controller/CMakeLists.txt index afa82c8..cd1290b 100644 --- a/pioneer_workstation_ws/src/pioneer3DX_controller/CMakeLists.txt +++ b/pioneer_workstation_ws/src/pioneer3dx_controller/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.8) -project(pioneer3DX_controller) +project(pioneer3dx_controller) if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") add_compile_options(-Wall -Wextra -Wpedantic) @@ -9,10 +9,26 @@ endif() find_package(ament_cmake REQUIRED) find_package(rclcpp REQUIRED) find_package(nav_msgs REQUIRED) +find_package(service_msgs REQUIRED) +find_package(rosidl_default_generators REQUIRED) -add_executable(Pioneer3DX_Controller src/main.cpp src/p3dx_node.cpp) -ament_target_dependencies(Pioneer3DX_Controller rclcpp nav_msgs) -install(TARGETS Pioneer3DX_Controller DESTINATION lib/${PROJECT_NAME}) +rosidl_generate_interfaces(${PROJECT_NAME} + "messages/ChangeMode.msg" + "messages/ConfigLed.msg" + "messages/ConfigPid.msg" + "messages/ConfigRobot.msg" + "services/ChangeMode.srv" + "services/ConfigLed.srv" + "services/ConfigPid.srv" + "services/ConfigRobot.srv" + DEPENDENCIES service_msgs +) + +add_executable(Pioneer3dx_Controller src/main.cpp src/p3dx_node.cpp) +ament_target_dependencies(Pioneer3dx_Controller rclcpp nav_msgs) +rosidl_get_typesupport_target(cpp_typesupport_target ${PROJECT_NAME} "rosidl_typesupport_cpp") +target_link_libraries(Pioneer3dx_Controller ${cpp_typesupport_target}) +install(TARGETS Pioneer3dx_Controller DESTINATION lib/${PROJECT_NAME}) if(BUILD_TESTING) find_package(ament_lint_auto REQUIRED) diff --git a/pioneer_workstation_ws/src/pioneer3dx_controller/messages/ChangeMode.msg b/pioneer_workstation_ws/src/pioneer3dx_controller/messages/ChangeMode.msg new file mode 100644 index 0000000..56f716d --- /dev/null +++ b/pioneer_workstation_ws/src/pioneer3dx_controller/messages/ChangeMode.msg @@ -0,0 +1 @@ +byte mode \ No newline at end of file diff --git a/pioneer_workstation_ws/src/pioneer3dx_controller/messages/ConfigLed.msg b/pioneer_workstation_ws/src/pioneer3dx_controller/messages/ConfigLed.msg new file mode 100644 index 0000000..2145c4e --- /dev/null +++ b/pioneer_workstation_ws/src/pioneer3dx_controller/messages/ConfigLed.msg @@ -0,0 +1,4 @@ +float32 voltage_red +float32 voltage_orange +float32 voltage_hysteresis +uint32 update_period \ No newline at end of file diff --git a/pioneer_workstation_ws/src/pioneer3dx_controller/messages/ConfigPid.msg b/pioneer_workstation_ws/src/pioneer3dx_controller/messages/ConfigPid.msg new file mode 100644 index 0000000..8ff2151 --- /dev/null +++ b/pioneer_workstation_ws/src/pioneer3dx_controller/messages/ConfigPid.msg @@ -0,0 +1,3 @@ +float32[3] left +float32[3] right +float32[3] cross \ No newline at end of file diff --git a/pioneer_workstation_ws/src/pioneer3dx_controller/messages/ConfigRobot.msg b/pioneer_workstation_ws/src/pioneer3dx_controller/messages/ConfigRobot.msg new file mode 100644 index 0000000..b858b26 --- /dev/null +++ b/pioneer_workstation_ws/src/pioneer3dx_controller/messages/ConfigRobot.msg @@ -0,0 +1,5 @@ +float32 baseline +float32 wheel_circumference_left +float32 wheel_circumference_right +uint32 ticks_per_revolution_left +uint32 ticks_per_revolution_right \ No newline at end of file diff --git a/pioneer_workstation_ws/src/pioneer3DX_controller/package.xml b/pioneer_workstation_ws/src/pioneer3dx_controller/package.xml similarity index 68% rename from pioneer_workstation_ws/src/pioneer3DX_controller/package.xml rename to pioneer_workstation_ws/src/pioneer3dx_controller/package.xml index ab2ebe4..f7a6a12 100644 --- a/pioneer_workstation_ws/src/pioneer3DX_controller/package.xml +++ b/pioneer_workstation_ws/src/pioneer3dx_controller/package.xml @@ -1,15 +1,22 @@ - pioneer3DX_controller + pioneer3dx_controller 0.0.0 TODO: Package description leo TODO: License declaration ament_cmake + rosidl_default_generators rclcpp + nav_msgs + service_msgs + + rosidl_default_runtime + + rosidl_interface_packages ament_lint_auto ament_lint_common diff --git a/pioneer_workstation_ws/src/pioneer3dx_controller/services/ChangeMode.srv b/pioneer_workstation_ws/src/pioneer3dx_controller/services/ChangeMode.srv new file mode 100644 index 0000000..66599cc --- /dev/null +++ b/pioneer_workstation_ws/src/pioneer3dx_controller/services/ChangeMode.srv @@ -0,0 +1,3 @@ +byte mode +--- +byte status_response \ No newline at end of file diff --git a/pioneer_workstation_ws/src/pioneer3dx_controller/services/ConfigLed.srv b/pioneer_workstation_ws/src/pioneer3dx_controller/services/ConfigLed.srv new file mode 100644 index 0000000..1b6afde --- /dev/null +++ b/pioneer_workstation_ws/src/pioneer3dx_controller/services/ConfigLed.srv @@ -0,0 +1,6 @@ +float32 voltage_red +float32 voltage_orange +float32 voltage_hysteresis +uint32 update_period +--- +byte status_response diff --git a/pioneer_workstation_ws/src/pioneer3dx_controller/services/ConfigPid.srv b/pioneer_workstation_ws/src/pioneer3dx_controller/services/ConfigPid.srv new file mode 100644 index 0000000..96d0a48 --- /dev/null +++ b/pioneer_workstation_ws/src/pioneer3dx_controller/services/ConfigPid.srv @@ -0,0 +1,5 @@ +float32[3] left +float32[3] right +float32[3] cross +--- +byte status_response \ No newline at end of file diff --git a/pioneer_workstation_ws/src/pioneer3dx_controller/services/ConfigRobot.srv b/pioneer_workstation_ws/src/pioneer3dx_controller/services/ConfigRobot.srv new file mode 100644 index 0000000..23edd9d --- /dev/null +++ b/pioneer_workstation_ws/src/pioneer3dx_controller/services/ConfigRobot.srv @@ -0,0 +1,7 @@ +float32 baseline +float32 wheel_circumference_left +float32 wheel_circumference_right +uint32 ticks_per_revolution_left +uint32 ticks_per_revolution_right +--- +byte status_response \ No newline at end of file diff --git a/pioneer_workstation_ws/src/pioneer3DX_controller/src/main.cpp b/pioneer_workstation_ws/src/pioneer3dx_controller/src/main.cpp similarity index 100% rename from pioneer_workstation_ws/src/pioneer3DX_controller/src/main.cpp rename to pioneer_workstation_ws/src/pioneer3dx_controller/src/main.cpp diff --git a/pioneer_workstation_ws/src/pioneer3DX_controller/src/main.hpp b/pioneer_workstation_ws/src/pioneer3dx_controller/src/main.hpp similarity index 100% rename from pioneer_workstation_ws/src/pioneer3DX_controller/src/main.hpp rename to pioneer_workstation_ws/src/pioneer3dx_controller/src/main.hpp diff --git a/pioneer_workstation_ws/src/pioneer3DX_controller/src/p3dx_node.cpp b/pioneer_workstation_ws/src/pioneer3dx_controller/src/p3dx_node.cpp similarity index 97% rename from pioneer_workstation_ws/src/pioneer3DX_controller/src/p3dx_node.cpp rename to pioneer_workstation_ws/src/pioneer3dx_controller/src/p3dx_node.cpp index 13a0bd3..fb1e4f6 100644 --- a/pioneer_workstation_ws/src/pioneer3DX_controller/src/p3dx_node.cpp +++ b/pioneer_workstation_ws/src/pioneer3dx_controller/src/p3dx_node.cpp @@ -1,5 +1,7 @@ #include "p3dx_node.hpp" +#include "pioneer3dx_controller/msg/change_mode.hpp" + using namespace std::chrono_literals; P3DX_Controller_Node::P3DX_Controller_Node() : @@ -96,7 +98,7 @@ void P3DX_Controller_Node::stm32_message_print(const FMW_Message *msg) "\n header.crc = %u", message_types[msg->header.type], msg->header.crc); assert(buffer_len > 0); - assert(buffer_len < sizeof(buffer)); + assert(buffer_len < (int32_t)sizeof(buffer)); switch (msg->header.type) { case FMW_MessageType_Response: { @@ -108,7 +110,7 @@ void P3DX_Controller_Node::stm32_message_print(const FMW_Message *msg) "\n ticks_right = %d", result_types[msg->response.result], msg->response.delta_millis, msg->response.ticks_left, msg->response.ticks_right); - assert(buffer_len < sizeof(buffer)); + assert(buffer_len < (int32_t)sizeof(buffer)); } break; default: { assert(false && "unreachable"); diff --git a/pioneer_workstation_ws/src/pioneer3DX_controller/src/p3dx_node.hpp b/pioneer_workstation_ws/src/pioneer3dx_controller/src/p3dx_node.hpp similarity index 100% rename from pioneer_workstation_ws/src/pioneer3DX_controller/src/p3dx_node.hpp rename to pioneer_workstation_ws/src/pioneer3dx_controller/src/p3dx_node.hpp diff --git a/pioneer_workstation_ws/src/pioneer3DX_controller/src/stm32_messages.h b/pioneer_workstation_ws/src/pioneer3dx_controller/src/stm32_messages.h similarity index 100% rename from pioneer_workstation_ws/src/pioneer3DX_controller/src/stm32_messages.h rename to pioneer_workstation_ws/src/pioneer3dx_controller/src/stm32_messages.h