diff --git a/non-ros-files/Programming_Rules.md b/non-ros-files/Programming_Rules.md index 92d3b81..093101e 100644 --- a/non-ros-files/Programming_Rules.md +++ b/non-ros-files/Programming_Rules.md @@ -65,7 +65,7 @@ pubsub <---- depends on *.msg files ----< pubsub_msg This is also done in the background when creating a new package and defining dependencies `ros2 pkg create --dependencies [deps]` for example -`ros2 pkg create pubsub_2 --dependencies std_msgs` +`ros2 pkg create pubsub_2 --dependencies std_msgs builtin_interfaces --build-type ament_cmake` This command creates the new package `pubsub_2` but already links it to the ROS standard messages `std_msgs` so they are available. ## pubsub/ diff --git a/src/custom_interfaces/CMakeLists.txt b/src/custom_interfaces/CMakeLists.txt new file mode 100644 index 0000000..35db97f --- /dev/null +++ b/src/custom_interfaces/CMakeLists.txt @@ -0,0 +1,63 @@ +cmake_minimum_required(VERSION 3.5) +project(custom_interfaces) + +# Default to C99 +if(NOT CMAKE_C_STANDARD) + set(CMAKE_C_STANDARD 99) +endif() + +# Default to C++14 +if(NOT CMAKE_CXX_STANDARD) + set(CMAKE_CXX_STANDARD 14) +endif() + +if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") + add_compile_options(-Wall -Wextra -Wpedantic) +endif() + +# find dependencies +find_package(ament_cmake REQUIRED) +find_package(std_msgs REQUIRED) +find_package(builtin_interfaces REQUIRED) + + + + + + +# --> +# ADD THESE LINES: START HERE + +find_package(rosidl_default_generators REQUIRED) +find_package(rclcpp REQUIRED) + +# CUSTOM LINES: CHANGE FOR YOUR FILENAMES +rosidl_generate_interfaces(${PROJECT_NAME} + "msg/CustomMsg1.msg" + "msg/CustomMsg2.msg" + "srv/CustomSrv1.srv" + DEPENDENCIES builtin_interfaces + ) + +# END HERE +# <-- + + + + + + + + +if(BUILD_TESTING) + find_package(ament_lint_auto REQUIRED) + # the following line skips the linter which checks for copyrights + # uncomment the line when a copyright and license is not present in all source files + #set(ament_cmake_copyright_FOUND TRUE) + # the following line skips cpplint (only works in a git repo) + # uncomment the line when this package is not in a git repo + #set(ament_cmake_cpplint_FOUND TRUE) + ament_lint_auto_find_test_dependencies() +endif() + +ament_package() diff --git a/src/custom_interfaces/msg/CustomMsg1.msg b/src/custom_interfaces/msg/CustomMsg1.msg new file mode 100644 index 0000000..66a846b --- /dev/null +++ b/src/custom_interfaces/msg/CustomMsg1.msg @@ -0,0 +1,8 @@ +# Header data, eg timestamp +# Problem: "header__struct.hpp: No such file or directory" +#Header header + +# Sensor Data coming back from an array of atmospheric sensors +float32[] temperature +float32[] pressure +float32[] humidity diff --git a/src/custom_interfaces/msg/CustomMsg2.msg b/src/custom_interfaces/msg/CustomMsg2.msg new file mode 100644 index 0000000..2e9603d --- /dev/null +++ b/src/custom_interfaces/msg/CustomMsg2.msg @@ -0,0 +1,7 @@ +# Header data, eg timestamp +# Problem: "header__struct.hpp: No such file or directory" +#Header header + +# User inputs, eg. for controlling a camera mast , eg. set angles [rad] +float32 pitch_ctrl +float32 yaw_ctrl diff --git a/src/custom_interfaces/package.xml b/src/custom_interfaces/package.xml new file mode 100644 index 0000000..8c22c2a --- /dev/null +++ b/src/custom_interfaces/package.xml @@ -0,0 +1,42 @@ + + + + custom_interfaces + 0.0.0 + TODO: Package description + rosmobile + TODO: License declaration + + ament_cmake + ament_lint_auto + ament_lint_common + + + + + + builtin_interfaces + rosidl_default_generators + + builtin_interfaces + rosidl_default_runtime + + rosidl_interface_packages + + + + + + + + std_msgs + + + + ament_lint_auto + ament_lint_common + + + ament_cmake + + diff --git a/src/custom_interfaces/srv/CustomSrv1.srv b/src/custom_interfaces/srv/CustomSrv1.srv new file mode 100644 index 0000000..0d93ae4 --- /dev/null +++ b/src/custom_interfaces/srv/CustomSrv1.srv @@ -0,0 +1,10 @@ +# Header data, eg timestamp +# Problem: "header__struct.hpp: No such file or directory" +#Header header + +# Sensor Data coming back from an array of atmospheric sensors +float32[] temperature +float32[] pressure +float32[] humidity +--- +bool success