From 39877a461823e8b131dd7db9c0e9d7bcf873ecb3 Mon Sep 17 00:00:00 2001 From: {Noir-swim} <{noriri.jwu@gmail.com}> Date: Sun, 2 Jun 2024 16:45:32 +0900 Subject: [PATCH 01/10] make pacledt-compose'Node' --- packet/packet_composed/CMakeLists.txt | 54 +++++++++++++++++++ .../include/packet_composed/sensorspacket.hpp | 23 ++++++++ packet/packet_composed/package.xml | 20 +++++++ packet/packet_composed/src/composed.cpp | 45 ++++++++++++++++ packet/packet_composed/src/composed_main.cpp | 17 ++++++ 5 files changed, 159 insertions(+) create mode 100644 packet/packet_composed/CMakeLists.txt create mode 100644 packet/packet_composed/include/packet_composed/sensorspacket.hpp create mode 100644 packet/packet_composed/package.xml create mode 100644 packet/packet_composed/src/composed.cpp create mode 100644 packet/packet_composed/src/composed_main.cpp diff --git a/packet/packet_composed/CMakeLists.txt b/packet/packet_composed/CMakeLists.txt new file mode 100644 index 0000000..c4e6c6a --- /dev/null +++ b/packet/packet_composed/CMakeLists.txt @@ -0,0 +1,54 @@ +cmake_minimum_required(VERSION 3.8) +project(packet_composed) + +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) +# uncomment the following section in order to fill in +# further dependencies manually. +# find_package( REQUIRED) +find_package(rclcpp REQUIRED) +find_package(packet_interfaces REQUIRED) + +# `composed`executableを作る + add_executable(composed + src/composed_main.cpp + src/composed.cpp + ) + + # `composed`executableの依存関係 + ament_target_dependencies(composed + rclcpp # ROS2標準ライブラリ + std_msgs # ROS2が用意している標準的なmessage型の定義を含むライブラリ + ) + + # `composed`executableが参照するヘッダファイルがあるフォルダー + target_include_directories(composed + PUBLIC + $ + $ + ) + + # `listener`executableの置き場所 + # 各executableの置き場所 + install(TARGETS + composed + DESTINATION lib/${PROJECT_NAME} + ) + +if(BUILD_TESTING) + find_package(ament_lint_auto REQUIRED) + # the following line skips the linter which checks for copyrights + # comment the line when a copyright and license is added to all source files + set(ament_cmake_copyright_FOUND TRUE) + # the following line skips cpplint (only works in a git repo) + # comment the line when this package is in a git repo and when + # a copyright and license is added to all source files + set(ament_cmake_cpplint_FOUND TRUE) + ament_lint_auto_find_test_dependencies() +endif() + +ament_package() diff --git a/packet/packet_composed/include/packet_composed/sensorspacket.hpp b/packet/packet_composed/include/packet_composed/sensorspacket.hpp new file mode 100644 index 0000000..5d0c967 --- /dev/null +++ b/packet/packet_composed/include/packet_composed/sensorspacket.hpp @@ -0,0 +1,23 @@ +#include + +#include "rclcpp/rclcpp.hpp" +// talker.cppでmsgを使えるようなincludeの構文 +#include "std_msgs/msg/string.hpp" + +// `composed`nodeを扱うクラス +class composed : public rclcpp::Node { +private: + // `chatter`topicのpublisher + std::shared_ptr> _publisher; + // 定期的に実行するためのタイマー + std::shared_ptr _timer; + // messageをpublishするごとにカウントアップさせる + unsigned int _count; + + // タイマーで定期的に実行する関数 宣言 + void _loop(); + +public: + // コンストラクタ + composed(); +}; \ No newline at end of file diff --git a/packet/packet_composed/package.xml b/packet/packet_composed/package.xml new file mode 100644 index 0000000..6d0ee21 --- /dev/null +++ b/packet/packet_composed/package.xml @@ -0,0 +1,20 @@ + + + + packet_composed + 0.0.0 + TODO: Package description + norikonakano + TODO: License declaration + + ament_cmake + rclcpp + packet_interfaces + + ament_lint_auto + ament_lint_common + + + ament_cmake + + diff --git a/packet/packet_composed/src/composed.cpp b/packet/packet_composed/src/composed.cpp new file mode 100644 index 0000000..10b0402 --- /dev/null +++ b/packet/packet_composed/src/composed.cpp @@ -0,0 +1,45 @@ +#include // 時間ユーティリティ タイマー作成時に使う +#include // 関数型プログラミング笑 +#include // stringstream iostreamみたいなやつ +#include // みんな大好き文字列 + +#include "packet_composed/sensorspacket.hpp" // composedクラス + +// タイマーで定期的に実行する関数 宣言 +void composed::_loop() { + // 文字列ストリーム + // std::coutの書き込み先がstd::stringになったみたいな感じ + std::stringstream ss; + // 構築 "Hello, world! 0" みたいになる + ss << "Hello, world! " << _count; + // 将来publishするmessage#include "packet_interfaces/msg/Composed.msg" + std_msgs::msg::String msg{}; + // std::string型のデータを代入 + msg.data = ss.str(); + // ログ出力 + RCLCPP_INFO(this->get_logger(), "say %s", ss.str().c_str()); + // RCLCPP_INFO_STREAM(this->get_logger(), "say: [" << msg.data << "]"); + // messageをpublish + _publisher->publish(msg); + // _countをインクリメント publishするたびにカウントが増加するようになる + _count++; +} + +// composedコンストラクタ 定義 +composed::composed() : + rclcpp::Node("composed"), // node名をcomposedに設定 + _publisher(), // _publisherのshared_ptrをnullptrで初期化 + _timer(), // タイマーをnullptrで初期化 + _count(0) // カウントの初期値は0 +{ + // これで50msとかかけるようになる + using namespace std::chrono_literals; + // publisherを作成 + // `chatter`topicにQoS 10で出力すると設定 + _publisher = this->create_publisher("/sensorspacket", 10); + // タイマーで定期的に呼び出される関数 + auto loop = std::bind(&composed::_loop, this); + // タイマー作成 + // 500ミリ秒ごとにloopが呼び出される + _timer = this->create_wall_timer(500ms, loop); +} \ No newline at end of file diff --git a/packet/packet_composed/src/composed_main.cpp b/packet/packet_composed/src/composed_main.cpp new file mode 100644 index 0000000..735466e --- /dev/null +++ b/packet/packet_composed/src/composed_main.cpp @@ -0,0 +1,17 @@ +// listener_main.cppと同じなのでコメントは略 + +#include +#include +#include "packet_composed/sensorspacket.hpp" + +int main(int argc, char * argv[]) { + rclcpp::init(argc, argv); + // ROS2プロセスの初期化 + auto node = std::make_shared(); + // `listener`nodeを作成 + rclcpp::spin(node); + // 作成したnodeを実行 + rclcpp::shutdown(); + // ROS2プロセスを終了 + return 0; +} \ No newline at end of file From 8fd3bb22300b91cfad2bb1d106f6019754609c3d Mon Sep 17 00:00:00 2001 From: {Noir-swim} <{noriri.jwu@gmail.com}> Date: Mon, 10 Jun 2024 21:46:24 +0900 Subject: [PATCH 02/10] did "comment content" --- packet/packet_composed/CMakeLists.txt | 29 +++------------ .../include/packet_composed/sensorspacket.hpp | 16 +++----- packet/packet_composed/src/composed.cpp | 37 +++++-------------- packet/packet_composed/src/composed_main.cpp | 8 +--- 4 files changed, 23 insertions(+), 67 deletions(-) diff --git a/packet/packet_composed/CMakeLists.txt b/packet/packet_composed/CMakeLists.txt index c4e6c6a..279cda0 100644 --- a/packet/packet_composed/CMakeLists.txt +++ b/packet/packet_composed/CMakeLists.txt @@ -13,42 +13,25 @@ find_package(ament_cmake REQUIRED) find_package(rclcpp REQUIRED) find_package(packet_interfaces REQUIRED) -# `composed`executableを作る add_executable(composed - src/composed_main.cpp + src/composed_main.cpp src/composed.cpp ) - # `composed`executableの依存関係 ament_target_dependencies(composed - rclcpp # ROS2標準ライブラリ - std_msgs # ROS2が用意している標準的なmessage型の定義を含むライブラリ + rclcpp + packet_interfaces ) - # `composed`executableが参照するヘッダファイルがあるフォルダー target_include_directories(composed PUBLIC $ $ ) - - # `listener`executableの置き場所 - # 各executableの置き場所 install(TARGETS - composed - DESTINATION lib/${PROJECT_NAME} + composed + DESTINATION lib/${PROJECT_NAME} ) - -if(BUILD_TESTING) - find_package(ament_lint_auto REQUIRED) - # the following line skips the linter which checks for copyrights - # comment the line when a copyright and license is added to all source files - set(ament_cmake_copyright_FOUND TRUE) - # the following line skips cpplint (only works in a git repo) - # comment the line when this package is in a git repo and when - # a copyright and license is added to all source files - set(ament_cmake_cpplint_FOUND TRUE) - ament_lint_auto_find_test_dependencies() -endif() ament_package() + diff --git a/packet/packet_composed/include/packet_composed/sensorspacket.hpp b/packet/packet_composed/include/packet_composed/sensorspacket.hpp index 5d0c967..b32464b 100644 --- a/packet/packet_composed/include/packet_composed/sensorspacket.hpp +++ b/packet/packet_composed/include/packet_composed/sensorspacket.hpp @@ -1,23 +1,19 @@ #include - #include "rclcpp/rclcpp.hpp" -// talker.cppでmsgを使えるようなincludeの構文 #include "std_msgs/msg/string.hpp" +#ifndef PACKET_COMPOSED_SENSORPACKET_HPP +#define PACKET_COMPOSED_SENSORPACKET_HPP -// `composed`nodeを扱うクラス class composed : public rclcpp::Node { private: - // `chatter`topicのpublisher + std::shared_ptr> _publisher; - // 定期的に実行するためのタイマー std::shared_ptr _timer; - // messageをpublishするごとにカウントアップさせる unsigned int _count; - - // タイマーで定期的に実行する関数 宣言 void _loop(); public: - // コンストラクタ composed(); -}; \ No newline at end of file +}; + +#endif // PACKET_COMPOSED_SENSORPACKET_HPP \ No newline at end of file diff --git a/packet/packet_composed/src/composed.cpp b/packet/packet_composed/src/composed.cpp index 10b0402..39930d2 100644 --- a/packet/packet_composed/src/composed.cpp +++ b/packet/packet_composed/src/composed.cpp @@ -1,45 +1,28 @@ -#include // 時間ユーティリティ タイマー作成時に使う -#include // 関数型プログラミング笑 -#include // stringstream iostreamみたいなやつ -#include // みんな大好き文字列 +#include +#include +#include -#include "packet_composed/sensorspacket.hpp" // composedクラス +#include "packet_composed/sensorspacket.hpp" -// タイマーで定期的に実行する関数 宣言 void composed::_loop() { - // 文字列ストリーム - // std::coutの書き込み先がstd::stringになったみたいな感じ std::stringstream ss; - // 構築 "Hello, world! 0" みたいになる ss << "Hello, world! " << _count; - // 将来publishするmessage#include "packet_interfaces/msg/Composed.msg" std_msgs::msg::String msg{}; - // std::string型のデータを代入 msg.data = ss.str(); - // ログ出力 RCLCPP_INFO(this->get_logger(), "say %s", ss.str().c_str()); - // RCLCPP_INFO_STREAM(this->get_logger(), "say: [" << msg.data << "]"); - // messageをpublish _publisher->publish(msg); - // _countをインクリメント publishするたびにカウントが増加するようになる _count++; } -// composedコンストラクタ 定義 + composed::composed() : - rclcpp::Node("composed"), // node名をcomposedに設定 - _publisher(), // _publisherのshared_ptrをnullptrで初期化 - _timer(), // タイマーをnullptrで初期化 - _count(0) // カウントの初期値は0 + rclcpp::Node("composed"), + _publisher(), + _timer(), + _count(0) { - // これで50msとかかけるようになる using namespace std::chrono_literals; - // publisherを作成 - // `chatter`topicにQoS 10で出力すると設定 _publisher = this->create_publisher("/sensorspacket", 10); - // タイマーで定期的に呼び出される関数 auto loop = std::bind(&composed::_loop, this); - // タイマー作成 - // 500ミリ秒ごとにloopが呼び出される _timer = this->create_wall_timer(500ms, loop); -} \ No newline at end of file +} diff --git a/packet/packet_composed/src/composed_main.cpp b/packet/packet_composed/src/composed_main.cpp index 735466e..80080d3 100644 --- a/packet/packet_composed/src/composed_main.cpp +++ b/packet/packet_composed/src/composed_main.cpp @@ -1,17 +1,11 @@ -// listener_main.cppと同じなのでコメントは略 - #include #include #include "packet_composed/sensorspacket.hpp" int main(int argc, char * argv[]) { rclcpp::init(argc, argv); - // ROS2プロセスの初期化 auto node = std::make_shared(); - // `listener`nodeを作成 rclcpp::spin(node); - // 作成したnodeを実行 rclcpp::shutdown(); - // ROS2プロセスを終了 return 0; -} \ No newline at end of file +} From 82026ad614b6cb7e64142643301242320c880e42 Mon Sep 17 00:00:00 2001 From: {Noir-swim} <{noriri.jwu@gmail.com}> Date: Mon, 10 Jun 2024 22:18:29 +0900 Subject: [PATCH 03/10] did "comment content" --- packet/packet_composed/CMakeLists.txt | 8 ++++---- .../include/packet_composed/sensorspacket.hpp | 11 ++++++----- packet/packet_composed/package.xml | 7 +------ packet/packet_composed/src/composed.cpp | 6 +++--- packet/packet_composed/src/composed_main.cpp | 2 +- 5 files changed, 15 insertions(+), 19 deletions(-) diff --git a/packet/packet_composed/CMakeLists.txt b/packet/packet_composed/CMakeLists.txt index 279cda0..c22f920 100644 --- a/packet/packet_composed/CMakeLists.txt +++ b/packet/packet_composed/CMakeLists.txt @@ -13,23 +13,23 @@ find_package(ament_cmake REQUIRED) find_package(rclcpp REQUIRED) find_package(packet_interfaces REQUIRED) - add_executable(composed + add_executable(Composed src/composed_main.cpp src/composed.cpp ) - ament_target_dependencies(composed + ament_target_dependencies(Composed rclcpp packet_interfaces ) - target_include_directories(composed + target_include_directories(Composed PUBLIC $ $ ) install(TARGETS - composed + Composed DESTINATION lib/${PROJECT_NAME} ) diff --git a/packet/packet_composed/include/packet_composed/sensorspacket.hpp b/packet/packet_composed/include/packet_composed/sensorspacket.hpp index b32464b..f821cc9 100644 --- a/packet/packet_composed/include/packet_composed/sensorspacket.hpp +++ b/packet/packet_composed/include/packet_composed/sensorspacket.hpp @@ -1,10 +1,11 @@ +#ifndef PACKET_COMPOSED_SENSORPACKET_HPP +#define PACKET_COMPOSED_SENSORPACKET_HPP + #include #include "rclcpp/rclcpp.hpp" #include "std_msgs/msg/string.hpp" -#ifndef PACKET_COMPOSED_SENSORPACKET_HPP -#define PACKET_COMPOSED_SENSORPACKET_HPP -class composed : public rclcpp::Node { +class Composed : public rclcpp::Node { private: std::shared_ptr> _publisher; @@ -13,7 +14,7 @@ class composed : public rclcpp::Node { void _loop(); public: - composed(); + Composed(); }; -#endif // PACKET_COMPOSED_SENSORPACKET_HPP \ No newline at end of file +#endif // PACKET_COMPOSED_SENSORPACKET_HPP diff --git a/packet/packet_composed/package.xml b/packet/packet_composed/package.xml index 6d0ee21..597b503 100644 --- a/packet/packet_composed/package.xml +++ b/packet/packet_composed/package.xml @@ -5,15 +5,10 @@ 0.0.0 TODO: Package description norikonakano - TODO: License declaration - + MIT ament_cmake rclcpp packet_interfaces - - ament_lint_auto - ament_lint_common - ament_cmake diff --git a/packet/packet_composed/src/composed.cpp b/packet/packet_composed/src/composed.cpp index 39930d2..fb7dfbc 100644 --- a/packet/packet_composed/src/composed.cpp +++ b/packet/packet_composed/src/composed.cpp @@ -4,7 +4,7 @@ #include "packet_composed/sensorspacket.hpp" -void composed::_loop() { +void Composed::_loop() { std::stringstream ss; ss << "Hello, world! " << _count; std_msgs::msg::String msg{}; @@ -15,7 +15,7 @@ void composed::_loop() { } -composed::composed() : +Composed::Composed() : rclcpp::Node("composed"), _publisher(), _timer(), @@ -23,6 +23,6 @@ composed::composed() : { using namespace std::chrono_literals; _publisher = this->create_publisher("/sensorspacket", 10); - auto loop = std::bind(&composed::_loop, this); + auto loop = std::bind(&Composed::_loop, this); _timer = this->create_wall_timer(500ms, loop); } diff --git a/packet/packet_composed/src/composed_main.cpp b/packet/packet_composed/src/composed_main.cpp index 80080d3..e8c76fe 100644 --- a/packet/packet_composed/src/composed_main.cpp +++ b/packet/packet_composed/src/composed_main.cpp @@ -4,7 +4,7 @@ int main(int argc, char * argv[]) { rclcpp::init(argc, argv); - auto node = std::make_shared(); + auto node = std::make_shared(); rclcpp::spin(node); rclcpp::shutdown(); return 0; From 5203aa09706ebdf29f4880e8a85d71f28cb5cc2b Mon Sep 17 00:00:00 2001 From: {Noir-swim} <{noriri.jwu@gmail.com}> Date: Mon, 17 Jun 2024 23:00:32 +0900 Subject: [PATCH 04/10] =?UTF-8?q?packet=5Finterfaces=E3=81=AEmsg=E3=83=95?= =?UTF-8?q?=E3=82=A1=E3=82=A4=E3=83=AB=E3=81=AB=E5=AF=BE=E3=81=99=E3=82=8B?= =?UTF-8?q?=E5=87=BA=E5=8A=9B=E9=96=A2=E4=BF=82=E3=81=AE=E3=83=8E=E3=83=BC?= =?UTF-8?q?=E3=83=89=E7=AD=89=E3=82=92Figma=E8=A6=8B=E3=81=AA=E3=81=8C?= =?UTF-8?q?=E3=82=89=E4=BD=9C=E3=81=A3=E3=81=A6=E3=81=BF=E3=81=9F=E3=81=A4?= =?UTF-8?q?=E3=82=82=E3=82=8A=E3=81=A7=E3=81=99=E3=80=82=E3=80=82=E8=A7=A3?= =?UTF-8?q?=E9=87=88=E9=81=95=E3=81=84=E3=81=A7=E4=BD=99=E8=A8=88=E3=81=AA?= =?UTF-8?q?=E3=81=93=E3=81=A8=E3=82=92=E3=81=97=E3=81=A6=E3=81=84=E3=82=8B?= =?UTF-8?q?=E6=B0=97=E3=81=8C=E3=81=97=E3=81=BE=E3=81=99=E3=80=82=E3=81=94?= =?UTF-8?q?=E6=8C=87=E6=91=98=E3=81=84=E3=81=9F=E3=81=A0=E3=81=8D=E3=81=9F?= =?UTF-8?q?=E3=81=84=E3=81=A7=E3=81=99=E3=80=82=E3=82=88=E3=82=8D=E3=81=97?= =?UTF-8?q?=E3=81=8F=E3=81=8A=E9=A1=98=E3=81=84=E3=81=84=E3=81=9F=E3=81=97?= =?UTF-8?q?=E3=81=BE=E3=81=99=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../order/power/packet_power/CMakeLists.txt | 36 +++++++++++++++++++ .../include/packet_power/powerspacket.hpp | 20 +++++++++++ packet/order/power/packet_power/package.xml | 15 ++++++++ packet/order/power/packet_power/src/power.cpp | 28 +++++++++++++++ .../power/packet_power/src/power_main.cpp | 11 ++++++ packet/order/quit/packet_quit/CMakeLists.txt | 36 +++++++++++++++++++ .../include/packet_quit/quitspacket.hpp | 21 +++++++++++ packet/order/quit/packet_quit/package.xml | 15 ++++++++ packet/order/quit/packet_quit/src/quit.cpp | 29 +++++++++++++++ .../order/quit/packet_quit/src/quit_main.cpp | 11 ++++++ .../.vscode/c_cpp_properties.json | 23 ++++++++++++ packet/packet_composed/.vscode/settings.json | 16 +++++++++ .../include/packet_composed/sensorspacket.hpp | 4 +-- .../current/packet_current/CMakeLists.txt | 36 +++++++++++++++++++ .../include/packet_current/currentspacket.hpp | 20 +++++++++++ .../current/packet_current/package.xml | 15 ++++++++ .../current/packet_current/src/current.cpp | 28 +++++++++++++++ .../packet_current/src/current_main.cpp | 11 ++++++ .../sensors/depth/packet_depth/CMakeLists.txt | 36 +++++++++++++++++++ .../include/packet_depth/depthspacket.hpp | 20 +++++++++++ .../sensors/depth/packet_depth/package.xml | 16 +++++++++ .../sensors/depth/packet_depth/src/depth.cpp | 28 +++++++++++++++ .../depth/packet_depth/src/depth_main.cpp | 11 ++++++ .../flex/flex1/packet_flex1/CMakeLists.txt | 36 +++++++++++++++++++ .../include/packet_flex1/flex1spacket.hpp | 20 +++++++++++ .../flex/flex1/packet_flex1/package.xml | 15 ++++++++ .../flex/flex1/packet_flex1/src/flex1.cpp | 28 +++++++++++++++ .../flex1/packet_flex1/src/flex1_main.cpp | 12 +++++++ .../flex/flex2/packet_flex2/CMakeLists.txt | 36 +++++++++++++++++++ .../include/packet_flex2/flex2spacket.hpp | 20 +++++++++++ .../flex/flex2/packet_flex2/package.xml | 15 ++++++++ .../flex/flex2/packet_flex2/src/flex2.cpp | 28 +++++++++++++++ .../flex2/packet_flex2/src/flex2_main.cpp | 11 ++++++ .../voltage/packet_voltage/CMakeLists.txt | 36 +++++++++++++++++++ .../include/packet_voltage/voltagepacket.hpp | 20 +++++++++++ .../voltage/packet_voltage/package.xml | 15 ++++++++ .../voltage/packet_voltage/src/voltage.cpp | 28 +++++++++++++++ .../packet_voltage/src/voltage_main.cpp | 11 ++++++ packet/packet_composed/src/composed.cpp | 2 +- 39 files changed, 816 insertions(+), 3 deletions(-) create mode 100644 packet/order/power/packet_power/CMakeLists.txt create mode 100644 packet/order/power/packet_power/include/packet_power/powerspacket.hpp create mode 100644 packet/order/power/packet_power/package.xml create mode 100644 packet/order/power/packet_power/src/power.cpp create mode 100644 packet/order/power/packet_power/src/power_main.cpp create mode 100644 packet/order/quit/packet_quit/CMakeLists.txt create mode 100644 packet/order/quit/packet_quit/include/packet_quit/quitspacket.hpp create mode 100644 packet/order/quit/packet_quit/package.xml create mode 100644 packet/order/quit/packet_quit/src/quit.cpp create mode 100644 packet/order/quit/packet_quit/src/quit_main.cpp create mode 100644 packet/packet_composed/.vscode/c_cpp_properties.json create mode 100644 packet/packet_composed/.vscode/settings.json create mode 100644 packet/packet_composed/sensors/current/packet_current/CMakeLists.txt create mode 100644 packet/packet_composed/sensors/current/packet_current/include/packet_current/currentspacket.hpp create mode 100644 packet/packet_composed/sensors/current/packet_current/package.xml create mode 100644 packet/packet_composed/sensors/current/packet_current/src/current.cpp create mode 100644 packet/packet_composed/sensors/current/packet_current/src/current_main.cpp create mode 100644 packet/packet_composed/sensors/depth/packet_depth/CMakeLists.txt create mode 100644 packet/packet_composed/sensors/depth/packet_depth/include/packet_depth/depthspacket.hpp create mode 100644 packet/packet_composed/sensors/depth/packet_depth/package.xml create mode 100644 packet/packet_composed/sensors/depth/packet_depth/src/depth.cpp create mode 100644 packet/packet_composed/sensors/depth/packet_depth/src/depth_main.cpp create mode 100644 packet/packet_composed/sensors/flex/flex1/packet_flex1/CMakeLists.txt create mode 100644 packet/packet_composed/sensors/flex/flex1/packet_flex1/include/packet_flex1/flex1spacket.hpp create mode 100644 packet/packet_composed/sensors/flex/flex1/packet_flex1/package.xml create mode 100644 packet/packet_composed/sensors/flex/flex1/packet_flex1/src/flex1.cpp create mode 100644 packet/packet_composed/sensors/flex/flex1/packet_flex1/src/flex1_main.cpp create mode 100644 packet/packet_composed/sensors/flex/flex2/packet_flex2/CMakeLists.txt create mode 100644 packet/packet_composed/sensors/flex/flex2/packet_flex2/include/packet_flex2/flex2spacket.hpp create mode 100644 packet/packet_composed/sensors/flex/flex2/packet_flex2/package.xml create mode 100644 packet/packet_composed/sensors/flex/flex2/packet_flex2/src/flex2.cpp create mode 100644 packet/packet_composed/sensors/flex/flex2/packet_flex2/src/flex2_main.cpp create mode 100644 packet/packet_composed/sensors/voltage/packet_voltage/CMakeLists.txt create mode 100644 packet/packet_composed/sensors/voltage/packet_voltage/include/packet_voltage/voltagepacket.hpp create mode 100644 packet/packet_composed/sensors/voltage/packet_voltage/package.xml create mode 100644 packet/packet_composed/sensors/voltage/packet_voltage/src/voltage.cpp create mode 100644 packet/packet_composed/sensors/voltage/packet_voltage/src/voltage_main.cpp diff --git a/packet/order/power/packet_power/CMakeLists.txt b/packet/order/power/packet_power/CMakeLists.txt new file mode 100644 index 0000000..4b8bc78 --- /dev/null +++ b/packet/order/power/packet_power/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.8) +project(packet_power) + +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) +# uncomment the following section in order to fill in +# further dependencies manually. +# find_package( REQUIRED) +find_package(rclcpp REQUIRED) +find_package(packet_interfaces REQUIRED) + + add_executable(Power + src/Power_main.cpp + src/Power.cpp + ) + + ament_target_dependencies(Power + rclcpp + packet_interfaces + ) + + target_include_directories(Power + PUBLIC + $ + $ + ) + install(TARGETS + Power + DESTINATION lib/${PROJECT_NAME} + ) + +ament_package() diff --git a/packet/order/power/packet_power/include/packet_power/powerspacket.hpp b/packet/order/power/packet_power/include/packet_power/powerspacket.hpp new file mode 100644 index 0000000..0083965 --- /dev/null +++ b/packet/order/power/packet_power/include/packet_power/powerspacket.hpp @@ -0,0 +1,20 @@ +#ifndef PACKET_POWER_POWERSPACKET_HPP +#define PACKET_POWER_POWERSPACKET_HPP + +#include +#include "rclcpp/rclcpp.hpp" +#include "std_msgs/msg/string.hpp" + +class Power : public rclcpp::Node { +private: + + std::shared_ptr> _publisher; + std::shared_ptr _timer; + unsigned int _count; + void _loop(); + +public: + Power(); +}; + +#endif // PACKET_POWER_POWERSPACKET_HPP diff --git a/packet/order/power/packet_power/package.xml b/packet/order/power/packet_power/package.xml new file mode 100644 index 0000000..0bb0bac --- /dev/null +++ b/packet/order/power/packet_power/package.xml @@ -0,0 +1,15 @@ + + + + packet_power + 0.0.0 + TODO: Package description + norikonakano + MIT + ament_cmake + rclcpp + packet_interfaces + + ament_cmake + + diff --git a/packet/order/power/packet_power/src/power.cpp b/packet/order/power/packet_power/src/power.cpp new file mode 100644 index 0000000..a6aabbe --- /dev/null +++ b/packet/order/power/packet_power/src/power.cpp @@ -0,0 +1,28 @@ +#include +#include +#include + +#include "packet_power/powerspacket.hpp" + +void Power::_loop() { + std::stringstream ss; + ss << "Hello, world! " << _count; + std_msgs::msg::String msg{}; + msg.data = ss.str(); + RCLCPP_INFO(this->get_logger(), "say %s", ss.str().c_str()); + _publisher->publish(msg); + _count++; +} + + +power::Power() : + rclcpp::Node("power"), + _publisher(), + _timer(), + _count(0) +{ + using namespace std::chrono_literals; + _publisher = this->create_publisher("/powerspacket", 10); + auto loop = std::bind(&Power::_loop, this); + _timer = this->create_wall_timer(500ms, loop); +} diff --git a/packet/order/power/packet_power/src/power_main.cpp b/packet/order/power/packet_power/src/power_main.cpp new file mode 100644 index 0000000..5af4c6d --- /dev/null +++ b/packet/order/power/packet_power/src/power_main.cpp @@ -0,0 +1,11 @@ +#include +#include +#include "packet_power/powerspacket.hpp" + +int main(int argc, char * argv[]) { + rclcpp::init(argc, argv); + auto node = std::make_shared(); + rclcpp::spin(node); + rclcpp::shutdown(); + return 0; +} diff --git a/packet/order/quit/packet_quit/CMakeLists.txt b/packet/order/quit/packet_quit/CMakeLists.txt new file mode 100644 index 0000000..839a539 --- /dev/null +++ b/packet/order/quit/packet_quit/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.8) +project(packet_quit) + +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) +# uncomment the following section in order to fill in +# further dependencies manually. +# find_package( REQUIRED) +find_package(rclcpp REQUIRED) +find_package(packet_interfaces REQUIRED) + + add_executable(Quit + src/quit_main.cpp + src/quit.cpp + ) + + ament_target_dependencies(Quit + rclcpp + packet_interfaces + ) + + target_include_directories(Quit + PUBLIC + $ + $ + ) + install(TARGETS + Quit + DESTINATION lib/${PROJECT_NAME} + ) + +ament_package() diff --git a/packet/order/quit/packet_quit/include/packet_quit/quitspacket.hpp b/packet/order/quit/packet_quit/include/packet_quit/quitspacket.hpp new file mode 100644 index 0000000..f470885 --- /dev/null +++ b/packet/order/quit/packet_quit/include/packet_quit/quitspacket.hpp @@ -0,0 +1,21 @@ +#ifndef PACKET_QUIT_QUITSPACKET_HPP +#define PACKET_QUIT_QUITSPACKET_HPP + +#include +#include "rclcpp/rclcpp.hpp" +#include "std_msgs/msg/string.hpp" + +class Quit : public rclcpp::Node { +private: + + std::shared_ptr> _publisher; + std::shared_ptr _timer; + unsigned int _count; + void _loop(); + +public: + Quit(); +}; + +#endif // PACKET_QUIT_QUITSPACKET_HPP + diff --git a/packet/order/quit/packet_quit/package.xml b/packet/order/quit/packet_quit/package.xml new file mode 100644 index 0000000..428e66b --- /dev/null +++ b/packet/order/quit/packet_quit/package.xml @@ -0,0 +1,15 @@ + + + + packet_quit + 0.0.0 + TODO: Package description + norikonakano + MIT + ament_cmake + rclcpp + packet_interfaces + + ament_cmake + + diff --git a/packet/order/quit/packet_quit/src/quit.cpp b/packet/order/quit/packet_quit/src/quit.cpp new file mode 100644 index 0000000..751e399 --- /dev/null +++ b/packet/order/quit/packet_quit/src/quit.cpp @@ -0,0 +1,29 @@ +#include +#include +#include + +#include "packet_quit/quitspacket.hpp" + +void Quit::_loop() { + std::stringstream ss; + ss << "Hello, world! " << _count; + std_msgs::msg::String msg{}; + msg.data = ss.str(); + RCLCPP_INFO(this->get_logger(), "say %s", ss.str().c_str()); + _publisher->publish(msg); + _count++; +} + + +Quit::Quit() : + rclcpp::Node("quit"), + _publisher(), + _timer(), + _count(0) +{ + using namespace std::chrono_literals; + _publisher = this->create_publisher("/quitspacket", 10); + auto loop = std::bind(&Quit::_loop, this); + _timer = this->create_wall_timer(500ms, loop); +} + diff --git a/packet/order/quit/packet_quit/src/quit_main.cpp b/packet/order/quit/packet_quit/src/quit_main.cpp new file mode 100644 index 0000000..23d0533 --- /dev/null +++ b/packet/order/quit/packet_quit/src/quit_main.cpp @@ -0,0 +1,11 @@ +#include +#include +#include "packet_quit/quitspacket.hpp" + +int main(int argc, char * argv[]) { + rclcpp::init(argc, argv); + auto node = std::make_shared(); + rclcpp::spin(node); + rclcpp::shutdown(); + return 0; +} diff --git a/packet/packet_composed/.vscode/c_cpp_properties.json b/packet/packet_composed/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..e4c98a0 --- /dev/null +++ b/packet/packet_composed/.vscode/c_cpp_properties.json @@ -0,0 +1,23 @@ +{ + "configurations": [ + { + "browse": { + "databaseFilename": "${default}", + "limitSymbolsToIncludedHeaders": false + }, + "includePath": [ + "/home/norikonakano/24jam_ws/install/packet_interfaces/include/**", + "/opt/ros/iron/include/**", + "/home/norikonakano/24jam_ws/src/2024_cavolinia/packet/packet_composed/include/**", + "include/**", + "/usr/include/**" + ], + "name": "ROS", + "intelliSenseMode": "gcc-x64", + "compilerPath": "/usr/bin/gcc", + "cStandard": "gnu11", + "cppStandard": "c++14" + } + ], + "version": 4 +} \ No newline at end of file diff --git a/packet/packet_composed/.vscode/settings.json b/packet/packet_composed/.vscode/settings.json new file mode 100644 index 0000000..2ca360d --- /dev/null +++ b/packet/packet_composed/.vscode/settings.json @@ -0,0 +1,16 @@ +{ + "python.autoComplete.extraPaths": [ + "/home/norikonakano/24jam_ws/install/pi_i2c/lib/python3.10/site-packages", + "/home/norikonakano/24jam_ws/install/nucleo_communicate_py/lib/python3.10/site-packages", + "/home/norikonakano/24jam_ws/install/packet_interfaces/lib/python3.10/site-packages", + "/home/norikonakano/24jam_ws/install/joystick/lib/python3.10/site-packages", + "/opt/ros/iron/lib/python3.10/site-packages" + ], + "python.analysis.extraPaths": [ + "/home/norikonakano/24jam_ws/install/pi_i2c/lib/python3.10/site-packages", + "/home/norikonakano/24jam_ws/install/nucleo_communicate_py/lib/python3.10/site-packages", + "/home/norikonakano/24jam_ws/install/packet_interfaces/lib/python3.10/site-packages", + "/home/norikonakano/24jam_ws/install/joystick/lib/python3.10/site-packages", + "/opt/ros/iron/lib/python3.10/site-packages" + ] +} \ No newline at end of file diff --git a/packet/packet_composed/include/packet_composed/sensorspacket.hpp b/packet/packet_composed/include/packet_composed/sensorspacket.hpp index f821cc9..cfa6b96 100644 --- a/packet/packet_composed/include/packet_composed/sensorspacket.hpp +++ b/packet/packet_composed/include/packet_composed/sensorspacket.hpp @@ -1,5 +1,5 @@ -#ifndef PACKET_COMPOSED_SENSORPACKET_HPP -#define PACKET_COMPOSED_SENSORPACKET_HPP +#ifndef PACKET_COMPOSED_SENSORSPACKET_HPP +#define PACKET_COMPOSED_SENSORSPACKET_HPP #include #include "rclcpp/rclcpp.hpp" diff --git a/packet/packet_composed/sensors/current/packet_current/CMakeLists.txt b/packet/packet_composed/sensors/current/packet_current/CMakeLists.txt new file mode 100644 index 0000000..ea26507 --- /dev/null +++ b/packet/packet_composed/sensors/current/packet_current/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.8) +project(packet_current) + +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) +# uncomment the following section in order to fill in +# further dependencies manually. +# find_package( REQUIRED) +find_package(rclcpp REQUIRED) +find_package(packet_interfaces REQUIRED) + + add_executable(Current + src/current_main.cpp + src/current.cpp + ) + + ament_target_dependencies(Current + rclcpp + packet_interfaces + ) + + target_include_directories(Current + PUBLIC + $ + $ + ) + install(TARGETS + Current + DESTINATION lib/${PROJECT_NAME} + ) + +ament_package() diff --git a/packet/packet_composed/sensors/current/packet_current/include/packet_current/currentspacket.hpp b/packet/packet_composed/sensors/current/packet_current/include/packet_current/currentspacket.hpp new file mode 100644 index 0000000..8205f7c --- /dev/null +++ b/packet/packet_composed/sensors/current/packet_current/include/packet_current/currentspacket.hpp @@ -0,0 +1,20 @@ +#ifndef PACKET_CURRENT_CURRENTSPACKET_HPP +#define PACKET_CURRENT_CURRENTSPACKET_HPP + +#include +#include "rclcpp/rclcpp.hpp" +#include "std_msgs/msg/string.hpp" + +class Current : public rclcpp::Node { +private: + + std::shared_ptr> _publisher; + std::shared_ptr _timer; + unsigned int _count; + void _loop(); + +public: + Current(); +}; + +#endif // PACKET_CURRENT_CURRENTSPACKET_HPP diff --git a/packet/packet_composed/sensors/current/packet_current/package.xml b/packet/packet_composed/sensors/current/packet_current/package.xml new file mode 100644 index 0000000..f3dbc9d --- /dev/null +++ b/packet/packet_composed/sensors/current/packet_current/package.xml @@ -0,0 +1,15 @@ + + + + packet_current + 0.0.0 + TODO: Package description + norikonakano + MIT + ament_cmake + rclcpp + packet_interfaces + + ament_cmake + + diff --git a/packet/packet_composed/sensors/current/packet_current/src/current.cpp b/packet/packet_composed/sensors/current/packet_current/src/current.cpp new file mode 100644 index 0000000..7334cec --- /dev/null +++ b/packet/packet_composed/sensors/current/packet_current/src/current.cpp @@ -0,0 +1,28 @@ +#include +#include +#include + +#include "packet_current/currentspacket.hpp" + +void Current::_loop() { + std::stringstream ss; + ss << "Hello, world! " << _count; + std_msgs::msg::String msg{}; + msg.data = ss.str(); + RCLCPP_INFO(this->get_logger(), "say %s", ss.str().c_str()); + _publisher->publish(msg); + _count++; +} + + +Current::Current() : + rclcpp::Node("Current"), + _publisher(), + _timer(), + _count(0) +{ + using namespace std::chrono_literals; + _publisher = this->create_publisher("/currents_composed", 10); + auto loop = std::bind(&Current::_loop, this); + _timer = this->create_wall_timer(500ms, loop); +} diff --git a/packet/packet_composed/sensors/current/packet_current/src/current_main.cpp b/packet/packet_composed/sensors/current/packet_current/src/current_main.cpp new file mode 100644 index 0000000..d4789d5 --- /dev/null +++ b/packet/packet_composed/sensors/current/packet_current/src/current_main.cpp @@ -0,0 +1,11 @@ +#include +#include +#include "packet_current/currentspacket.hpp" + +int main(int argc, char * argv[]) { + rclcpp::init(argc, argv); + auto node = std::make_shared(); + rclcpp::spin(node); + rclcpp::shutdown(); + return 0; +} diff --git a/packet/packet_composed/sensors/depth/packet_depth/CMakeLists.txt b/packet/packet_composed/sensors/depth/packet_depth/CMakeLists.txt new file mode 100644 index 0000000..3683e97 --- /dev/null +++ b/packet/packet_composed/sensors/depth/packet_depth/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.8) +project(packet_depth) + +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) +# uncomment the following section in order to fill in +# further dependencies manually. +# find_package( REQUIRED) +find_package(rclcpp REQUIRED) +find_package(packet_interfaces REQUIRED) + + add_executable(Depth + src/depth_main.cpp + src/depth.cpp + ) + + ament_target_dependencies(Depth + rclcpp + packet_interfaces + ) + + target_include_directories(Depth + PUBLIC + $ + $ + ) + install(TARGETS + Depth + DESTINATION lib/${PROJECT_NAME} + ) + +ament_package() diff --git a/packet/packet_composed/sensors/depth/packet_depth/include/packet_depth/depthspacket.hpp b/packet/packet_composed/sensors/depth/packet_depth/include/packet_depth/depthspacket.hpp new file mode 100644 index 0000000..61ab5de --- /dev/null +++ b/packet/packet_composed/sensors/depth/packet_depth/include/packet_depth/depthspacket.hpp @@ -0,0 +1,20 @@ +#ifndef PACKET_DEPTH_DEPTHSPACKET_HPP +#define PACKET_DEPTH_DEPTHSPACKET_HPP + +#include +#include "rclcpp/rclcpp.hpp" +#include "std_msgs/msg/string.hpp" + +class Depth : public rclcpp::Node { +private: + + std::shared_ptr> _publisher; + std::shared_ptr _timer; + unsigned int _count; + void _loop(); + +public: + Depth(); +}; + +#endif // PACKET_DEPTH_DEPTHSPACKET_HPP diff --git a/packet/packet_composed/sensors/depth/packet_depth/package.xml b/packet/packet_composed/sensors/depth/packet_depth/package.xml new file mode 100644 index 0000000..83387c6 --- /dev/null +++ b/packet/packet_composed/sensors/depth/packet_depth/package.xml @@ -0,0 +1,16 @@ + + + + packet_depth + 0.0.0 + TODO: Package description + norikonakano + MIT + ament_cmake + rclcpp + packet_interfaces + + ament_cmake + + + diff --git a/packet/packet_composed/sensors/depth/packet_depth/src/depth.cpp b/packet/packet_composed/sensors/depth/packet_depth/src/depth.cpp new file mode 100644 index 0000000..a0aa241 --- /dev/null +++ b/packet/packet_composed/sensors/depth/packet_depth/src/depth.cpp @@ -0,0 +1,28 @@ +#include +#include +#include + +#include "packet_depth/depthspacket.hpp" + +void Depth::_loop() { + std::stringstream ss; + ss << "Hello, world! " << _count; + std_msgs::msg::String msg{}; + msg.data = ss.str(); + RCLCPP_INFO(this->get_logger(), "say %s", ss.str().c_str()); + _publisher->publish(msg); + _count++; +} + + +Depth::Depth() : + rclcpp::Node("depth"), + _publisher(), + _timer(), + _count(0) +{ + using namespace std::chrono_literals; + _publisher = this->create_publisher("/depths_composed", 10); + auto loop = std::bind(&Depth::_loop, this); + _timer = this->create_wall_timer(500ms, loop); +} diff --git a/packet/packet_composed/sensors/depth/packet_depth/src/depth_main.cpp b/packet/packet_composed/sensors/depth/packet_depth/src/depth_main.cpp new file mode 100644 index 0000000..16415ff --- /dev/null +++ b/packet/packet_composed/sensors/depth/packet_depth/src/depth_main.cpp @@ -0,0 +1,11 @@ +#include +#include +#include "packet_depth/depthspacket.hpp" + +int main(int argc, char * argv[]) { + rclcpp::init(argc, argv); + auto node = std::make_shared(); + rclcpp::spin(node); + rclcpp::shutdown(); + return 0; +} diff --git a/packet/packet_composed/sensors/flex/flex1/packet_flex1/CMakeLists.txt b/packet/packet_composed/sensors/flex/flex1/packet_flex1/CMakeLists.txt new file mode 100644 index 0000000..84f0a6b --- /dev/null +++ b/packet/packet_composed/sensors/flex/flex1/packet_flex1/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.8) +project(packet_flex1) + +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) +# uncomment the following section in order to fill in +# further dependencies manually. +# find_package( REQUIRED) +find_package(rclcpp REQUIRED) +find_package(packet_interfaces REQUIRED) + + add_executable(Flex1 + src/flex1_main.cpp + src/flex1.cpp + ) + + ament_target_dependencies(Flex1 + rclcpp + packet_interfaces + ) + + target_include_directories(Flex1 + PUBLIC + $ + $ + ) + install(TARGETS + Flex1 + DESTINATION lib/${PROJECT_NAME} + ) + +ament_package() diff --git a/packet/packet_composed/sensors/flex/flex1/packet_flex1/include/packet_flex1/flex1spacket.hpp b/packet/packet_composed/sensors/flex/flex1/packet_flex1/include/packet_flex1/flex1spacket.hpp new file mode 100644 index 0000000..e814f3b --- /dev/null +++ b/packet/packet_composed/sensors/flex/flex1/packet_flex1/include/packet_flex1/flex1spacket.hpp @@ -0,0 +1,20 @@ +#ifndef PACKET_FLEX1_FLEX1SPACKET_HPP +#define PACKET_FLEX1_FLEX1SPACKET_HPP + +#include +#include "rclcpp/rclcpp.hpp" +#include "std_msgs/msg/string.hpp" + +class Flex1 : public rclcpp::Node { +private: + + std::shared_ptr> _publisher; + std::shared_ptr _timer; + unsigned int _count; + void _loop(); + +public: + Flex1(); +}; + +#endif // PACKET_FLEX1_FLEX1SPACKET_HPP diff --git a/packet/packet_composed/sensors/flex/flex1/packet_flex1/package.xml b/packet/packet_composed/sensors/flex/flex1/packet_flex1/package.xml new file mode 100644 index 0000000..eb7aae3 --- /dev/null +++ b/packet/packet_composed/sensors/flex/flex1/packet_flex1/package.xml @@ -0,0 +1,15 @@ + + + + packet_flex1 + 0.0.0 + TODO: Package description + norikonakano + MIT + ament_cmake + rclcpp + packet_interfaces + + ament_cmake + + diff --git a/packet/packet_composed/sensors/flex/flex1/packet_flex1/src/flex1.cpp b/packet/packet_composed/sensors/flex/flex1/packet_flex1/src/flex1.cpp new file mode 100644 index 0000000..3ed53fe --- /dev/null +++ b/packet/packet_composed/sensors/flex/flex1/packet_flex1/src/flex1.cpp @@ -0,0 +1,28 @@ +#include +#include +#include + +#include "packet_flex1/flex1spacket.hpp" + +void Flex1::_loop() { + std::stringstream ss; + ss << "Hello, world! " << _count; + std_msgs::msg::String msg{}; + msg.data = ss.str(); + RCLCPP_INFO(this->get_logger(), "say %s", ss.str().c_str()); + _publisher->publish(msg); + _count++; +} + + +Flex1::Flex1() : + rclcpp::Node("Flex1"), + _publisher(), + _timer(), + _count(0) +{ + using namespace std::chrono_literals; + _publisher = this->create_publisher("/Flex1_composed", 10); + auto loop = std::bind(&Flex1::_loop, this); + _timer = this->create_wall_timer(500ms, loop); +} diff --git a/packet/packet_composed/sensors/flex/flex1/packet_flex1/src/flex1_main.cpp b/packet/packet_composed/sensors/flex/flex1/packet_flex1/src/flex1_main.cpp new file mode 100644 index 0000000..ac82c9b --- /dev/null +++ b/packet/packet_composed/sensors/flex/flex1/packet_flex1/src/flex1_main.cpp @@ -0,0 +1,12 @@ +#include +#include +#include "packet_flex1/flex1spacket.hpp" + +int main(int argc, char * argv[]) { + rclcpp::init(argc, argv); + auto node = std::make_shared(); + rclcpp::spin(node); + rclcpp::shutdown(); + return 0; +} + diff --git a/packet/packet_composed/sensors/flex/flex2/packet_flex2/CMakeLists.txt b/packet/packet_composed/sensors/flex/flex2/packet_flex2/CMakeLists.txt new file mode 100644 index 0000000..d2c6b05 --- /dev/null +++ b/packet/packet_composed/sensors/flex/flex2/packet_flex2/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.8) +project(packet_flex2) + +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) +# uncomment the following section in order to fill in +# further dependencies manually. +# find_package( REQUIRED) +find_package(rclcpp REQUIRED) +find_package(packet_interfaces REQUIRED) + + add_executable(Flex2 + src/flex1_main.cpp + src/flex1.cpp + ) + + ament_target_dependencies(Flex2 + rclcpp + packet_interfaces + ) + + target_include_directories(Flex2 + PUBLIC + $ + $ + ) + install(TARGETS + Flex2 + DESTINATION lib/${PROJECT_NAME} + ) + +ament_package() diff --git a/packet/packet_composed/sensors/flex/flex2/packet_flex2/include/packet_flex2/flex2spacket.hpp b/packet/packet_composed/sensors/flex/flex2/packet_flex2/include/packet_flex2/flex2spacket.hpp new file mode 100644 index 0000000..00d8917 --- /dev/null +++ b/packet/packet_composed/sensors/flex/flex2/packet_flex2/include/packet_flex2/flex2spacket.hpp @@ -0,0 +1,20 @@ +#ifndef PACKET_FLEX2_FLEX1SPACKET_HPP +#define PACKET_FLEX2_FLEX1SPACKET_HPP + +#include +#include "rclcpp/rclcpp.hpp" +#include "std_msgs/msg/string.hpp" + +class Flex2 : public rclcpp::Node { +private: + + std::shared_ptr> _publisher; + std::shared_ptr _timer; + unsigned int _count; + void _loop(); + +public: + Flex2(); +}; + +#endif // PACKET_FLEX2_FLEX1SPACKET_HPP diff --git a/packet/packet_composed/sensors/flex/flex2/packet_flex2/package.xml b/packet/packet_composed/sensors/flex/flex2/packet_flex2/package.xml new file mode 100644 index 0000000..4b77ff6 --- /dev/null +++ b/packet/packet_composed/sensors/flex/flex2/packet_flex2/package.xml @@ -0,0 +1,15 @@ + + + + packet_flex2 + 0.0.0 + TODO: Package description + norikonakano + MIT + ament_cmake + rclcpp + packet_interfaces + + ament_cmake + + diff --git a/packet/packet_composed/sensors/flex/flex2/packet_flex2/src/flex2.cpp b/packet/packet_composed/sensors/flex/flex2/packet_flex2/src/flex2.cpp new file mode 100644 index 0000000..4921b2f --- /dev/null +++ b/packet/packet_composed/sensors/flex/flex2/packet_flex2/src/flex2.cpp @@ -0,0 +1,28 @@ +#include +#include +#include + +#include "packet_flex2/flex1spacket.hpp" + +void Flex1::_loop() { + std::stringstream ss; + ss << "Hello, world! " << _count; + std_msgs::msg::String msg{}; + msg.data = ss.str(); + RCLCPP_INFO(this->get_logger(), "say %s", ss.str().c_str()); + _publisher->publish(msg); + _count++; +} + + +Flex2::Flex2() : + rclcpp::Node("Flex1"), + _publisher(), + _timer(), + _count(0) +{ + using namespace std::chrono_literals; + _publisher = this->create_publisher("/Flex2_composed", 10); + auto loop = std::bind(&Flex2::_loop, this); + _timer = this->create_wall_timer(500ms, loop); +} diff --git a/packet/packet_composed/sensors/flex/flex2/packet_flex2/src/flex2_main.cpp b/packet/packet_composed/sensors/flex/flex2/packet_flex2/src/flex2_main.cpp new file mode 100644 index 0000000..732e656 --- /dev/null +++ b/packet/packet_composed/sensors/flex/flex2/packet_flex2/src/flex2_main.cpp @@ -0,0 +1,11 @@ +#include +#include +#include "packet_flex2/flex1spacket.hpp" + +int main(int argc, char * argv[]) { + rclcpp::init(argc, argv); + auto node = std::make_shared(); + rclcpp::spin(node); + rclcpp::shutdown(); + return 0; +} diff --git a/packet/packet_composed/sensors/voltage/packet_voltage/CMakeLists.txt b/packet/packet_composed/sensors/voltage/packet_voltage/CMakeLists.txt new file mode 100644 index 0000000..4cd0d8b --- /dev/null +++ b/packet/packet_composed/sensors/voltage/packet_voltage/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.8) +project(packet_voltage) + +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) +# uncomment the following section in order to fill in +# further dependencies manually. +# find_package( REQUIRED) +find_package(rclcpp REQUIRED) +find_package(packet_interfaces REQUIRED) + + add_executable(Voltage + src/voltage_main.cpp + src/voltage.cpp + ) + + ament_target_dependencies(Voltage + rclcpp + packet_interfaces + ) + + target_include_directories(Voltage + PUBLIC + $ + $ + ) + install(TARGETS + Voltage + DESTINATION lib/${PROJECT_NAME} + ) + +ament_package() \ No newline at end of file diff --git a/packet/packet_composed/sensors/voltage/packet_voltage/include/packet_voltage/voltagepacket.hpp b/packet/packet_composed/sensors/voltage/packet_voltage/include/packet_voltage/voltagepacket.hpp new file mode 100644 index 0000000..edc10bf --- /dev/null +++ b/packet/packet_composed/sensors/voltage/packet_voltage/include/packet_voltage/voltagepacket.hpp @@ -0,0 +1,20 @@ +#ifndef PACKET_VOLTAGE_VOLTAGEPACKET_HPP +#define PACKET_VOLTAGE_VOLTAGEPACKET_HPP + +#include +#include "rclcpp/rclcpp.hpp" +#include "std_msgs/msg/string.hpp" + +class Voltage : public rclcpp::Node { +private: + + std::shared_ptr> _publisher; + std::shared_ptr _timer; + unsigned int _count; + void _loop(); + +public: + Voltage(); +}; + +#endif // PACKET_VOLTAGE_VOLTAGEPACKET_HPP diff --git a/packet/packet_composed/sensors/voltage/packet_voltage/package.xml b/packet/packet_composed/sensors/voltage/packet_voltage/package.xml new file mode 100644 index 0000000..f179027 --- /dev/null +++ b/packet/packet_composed/sensors/voltage/packet_voltage/package.xml @@ -0,0 +1,15 @@ + + + + packet_voltage + 0.0.0 + TODO: Package description + norikonakano + MIT + ament_cmake + rclcpp + packet_interfaces + + ament_cmake + + diff --git a/packet/packet_composed/sensors/voltage/packet_voltage/src/voltage.cpp b/packet/packet_composed/sensors/voltage/packet_voltage/src/voltage.cpp new file mode 100644 index 0000000..00bf3c0 --- /dev/null +++ b/packet/packet_composed/sensors/voltage/packet_voltage/src/voltage.cpp @@ -0,0 +1,28 @@ +#include +#include +#include + +#include "packet_voltage/voltagepacket.hpp" + +void Composed::_loop() { + std::stringstream ss; + ss << "Hello, world! " << _count; + std_msgs::msg::String msg{}; + msg.data = ss.str(); + RCLCPP_INFO(this->get_logger(), "say %s", ss.str().c_str()); + _publisher->publish(msg); + _count++; +} + + +Voltage::Voltage() : + rclcpp::Node("voltage"), + _publisher(), + _timer(), + _count(0) +{ + using namespace std::chrono_literals; + _publisher = this->create_publisher("/voltages_composed", 10); + auto loop = std::bind(&Voltage::_loop, this); + _timer = this->create_wall_timer(500ms, loop); +} diff --git a/packet/packet_composed/sensors/voltage/packet_voltage/src/voltage_main.cpp b/packet/packet_composed/sensors/voltage/packet_voltage/src/voltage_main.cpp new file mode 100644 index 0000000..ed7bd2b --- /dev/null +++ b/packet/packet_composed/sensors/voltage/packet_voltage/src/voltage_main.cpp @@ -0,0 +1,11 @@ +#include +#include +#include "packet_voltage/voltagepacket.hpp" + +int main(int argc, char * argv[]) { + rclcpp::init(argc, argv); + auto node = std::make_shared(); + rclcpp::spin(node); + rclcpp::shutdown(); + return 0; +} diff --git a/packet/packet_composed/src/composed.cpp b/packet/packet_composed/src/composed.cpp index fb7dfbc..6647b97 100644 --- a/packet/packet_composed/src/composed.cpp +++ b/packet/packet_composed/src/composed.cpp @@ -22,7 +22,7 @@ Composed::Composed() : _count(0) { using namespace std::chrono_literals; - _publisher = this->create_publisher("/sensorspacket", 10); + _publisher = this->create_publisher("/sensors_composed", 10); auto loop = std::bind(&Composed::_loop, this); _timer = this->create_wall_timer(500ms, loop); } From 6cfe834c62dbcc5776281976a34deb2be5ce9e31 Mon Sep 17 00:00:00 2001 From: {Noir-swim} <{noriri.jwu@gmail.com}> Date: Wed, 26 Jun 2024 00:11:13 +0900 Subject: [PATCH 05/10] =?UTF-8?q?=E4=B8=8D=E8=A6=81=E3=81=AA=E3=83=95?= =?UTF-8?q?=E3=82=A1=E3=82=A4=E3=83=AB=E6=B6=88=E3=81=97=E3=81=BE=E3=81=97?= =?UTF-8?q?=E3=81=9F=E3=80=82composed.cpp=E3=80=81sensorspacket.hpp,CMakeL?= =?UTF-8?q?ists.txt,package.xml=E3=82=92=E4=BF=AE=E6=AD=A3=E3=81=97?= =?UTF-8?q?=E3=81=BE=E3=81=97=E3=81=9F=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../order/power/packet_power/CMakeLists.txt | 36 ------- .../include/packet_power/powerspacket.hpp | 20 ---- packet/order/power/packet_power/package.xml | 15 --- packet/order/power/packet_power/src/power.cpp | 28 ----- .../power/packet_power/src/power_main.cpp | 11 -- packet/order/quit/packet_quit/CMakeLists.txt | 36 ------- .../include/packet_quit/quitspacket.hpp | 21 ---- packet/order/quit/packet_quit/package.xml | 15 --- packet/order/quit/packet_quit/src/quit.cpp | 29 ----- .../order/quit/packet_quit/src/quit_main.cpp | 11 -- packet/packet_composed/CMakeLists.txt | 4 + .../include/packet_composed/sensorspacket.hpp | 26 ++++- packet/packet_composed/package.xml | 9 ++ .../current/packet_current/CMakeLists.txt | 36 ------- .../include/packet_current/currentspacket.hpp | 20 ---- .../current/packet_current/package.xml | 15 --- .../current/packet_current/src/current.cpp | 28 ----- .../packet_current/src/current_main.cpp | 11 -- .../sensors/depth/packet_depth/CMakeLists.txt | 36 ------- .../include/packet_depth/depthspacket.hpp | 20 ---- .../sensors/depth/packet_depth/package.xml | 16 --- .../sensors/depth/packet_depth/src/depth.cpp | 28 ----- .../depth/packet_depth/src/depth_main.cpp | 11 -- .../flex/flex1/packet_flex1/CMakeLists.txt | 36 ------- .../include/packet_flex1/flex1spacket.hpp | 20 ---- .../flex/flex1/packet_flex1/package.xml | 15 --- .../flex/flex1/packet_flex1/src/flex1.cpp | 28 ----- .../flex1/packet_flex1/src/flex1_main.cpp | 12 --- .../flex/flex2/packet_flex2/CMakeLists.txt | 36 ------- .../include/packet_flex2/flex2spacket.hpp | 20 ---- .../flex/flex2/packet_flex2/package.xml | 15 --- .../flex/flex2/packet_flex2/src/flex2.cpp | 28 ----- .../flex2/packet_flex2/src/flex2_main.cpp | 11 -- .../voltage/packet_voltage/CMakeLists.txt | 36 ------- .../include/packet_voltage/voltagepacket.hpp | 20 ---- .../voltage/packet_voltage/package.xml | 15 --- .../voltage/packet_voltage/src/voltage.cpp | 28 ----- .../packet_voltage/src/voltage_main.cpp | 11 -- packet/packet_composed/src/composed.cpp | 100 ++++++++++++++++-- 39 files changed, 126 insertions(+), 787 deletions(-) delete mode 100644 packet/order/power/packet_power/CMakeLists.txt delete mode 100644 packet/order/power/packet_power/include/packet_power/powerspacket.hpp delete mode 100644 packet/order/power/packet_power/package.xml delete mode 100644 packet/order/power/packet_power/src/power.cpp delete mode 100644 packet/order/power/packet_power/src/power_main.cpp delete mode 100644 packet/order/quit/packet_quit/CMakeLists.txt delete mode 100644 packet/order/quit/packet_quit/include/packet_quit/quitspacket.hpp delete mode 100644 packet/order/quit/packet_quit/package.xml delete mode 100644 packet/order/quit/packet_quit/src/quit.cpp delete mode 100644 packet/order/quit/packet_quit/src/quit_main.cpp delete mode 100644 packet/packet_composed/sensors/current/packet_current/CMakeLists.txt delete mode 100644 packet/packet_composed/sensors/current/packet_current/include/packet_current/currentspacket.hpp delete mode 100644 packet/packet_composed/sensors/current/packet_current/package.xml delete mode 100644 packet/packet_composed/sensors/current/packet_current/src/current.cpp delete mode 100644 packet/packet_composed/sensors/current/packet_current/src/current_main.cpp delete mode 100644 packet/packet_composed/sensors/depth/packet_depth/CMakeLists.txt delete mode 100644 packet/packet_composed/sensors/depth/packet_depth/include/packet_depth/depthspacket.hpp delete mode 100644 packet/packet_composed/sensors/depth/packet_depth/package.xml delete mode 100644 packet/packet_composed/sensors/depth/packet_depth/src/depth.cpp delete mode 100644 packet/packet_composed/sensors/depth/packet_depth/src/depth_main.cpp delete mode 100644 packet/packet_composed/sensors/flex/flex1/packet_flex1/CMakeLists.txt delete mode 100644 packet/packet_composed/sensors/flex/flex1/packet_flex1/include/packet_flex1/flex1spacket.hpp delete mode 100644 packet/packet_composed/sensors/flex/flex1/packet_flex1/package.xml delete mode 100644 packet/packet_composed/sensors/flex/flex1/packet_flex1/src/flex1.cpp delete mode 100644 packet/packet_composed/sensors/flex/flex1/packet_flex1/src/flex1_main.cpp delete mode 100644 packet/packet_composed/sensors/flex/flex2/packet_flex2/CMakeLists.txt delete mode 100644 packet/packet_composed/sensors/flex/flex2/packet_flex2/include/packet_flex2/flex2spacket.hpp delete mode 100644 packet/packet_composed/sensors/flex/flex2/packet_flex2/package.xml delete mode 100644 packet/packet_composed/sensors/flex/flex2/packet_flex2/src/flex2.cpp delete mode 100644 packet/packet_composed/sensors/flex/flex2/packet_flex2/src/flex2_main.cpp delete mode 100644 packet/packet_composed/sensors/voltage/packet_voltage/CMakeLists.txt delete mode 100644 packet/packet_composed/sensors/voltage/packet_voltage/include/packet_voltage/voltagepacket.hpp delete mode 100644 packet/packet_composed/sensors/voltage/packet_voltage/package.xml delete mode 100644 packet/packet_composed/sensors/voltage/packet_voltage/src/voltage.cpp delete mode 100644 packet/packet_composed/sensors/voltage/packet_voltage/src/voltage_main.cpp diff --git a/packet/order/power/packet_power/CMakeLists.txt b/packet/order/power/packet_power/CMakeLists.txt deleted file mode 100644 index 4b8bc78..0000000 --- a/packet/order/power/packet_power/CMakeLists.txt +++ /dev/null @@ -1,36 +0,0 @@ -cmake_minimum_required(VERSION 3.8) -project(packet_power) - -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) -# uncomment the following section in order to fill in -# further dependencies manually. -# find_package( REQUIRED) -find_package(rclcpp REQUIRED) -find_package(packet_interfaces REQUIRED) - - add_executable(Power - src/Power_main.cpp - src/Power.cpp - ) - - ament_target_dependencies(Power - rclcpp - packet_interfaces - ) - - target_include_directories(Power - PUBLIC - $ - $ - ) - install(TARGETS - Power - DESTINATION lib/${PROJECT_NAME} - ) - -ament_package() diff --git a/packet/order/power/packet_power/include/packet_power/powerspacket.hpp b/packet/order/power/packet_power/include/packet_power/powerspacket.hpp deleted file mode 100644 index 0083965..0000000 --- a/packet/order/power/packet_power/include/packet_power/powerspacket.hpp +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef PACKET_POWER_POWERSPACKET_HPP -#define PACKET_POWER_POWERSPACKET_HPP - -#include -#include "rclcpp/rclcpp.hpp" -#include "std_msgs/msg/string.hpp" - -class Power : public rclcpp::Node { -private: - - std::shared_ptr> _publisher; - std::shared_ptr _timer; - unsigned int _count; - void _loop(); - -public: - Power(); -}; - -#endif // PACKET_POWER_POWERSPACKET_HPP diff --git a/packet/order/power/packet_power/package.xml b/packet/order/power/packet_power/package.xml deleted file mode 100644 index 0bb0bac..0000000 --- a/packet/order/power/packet_power/package.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - packet_power - 0.0.0 - TODO: Package description - norikonakano - MIT - ament_cmake - rclcpp - packet_interfaces - - ament_cmake - - diff --git a/packet/order/power/packet_power/src/power.cpp b/packet/order/power/packet_power/src/power.cpp deleted file mode 100644 index a6aabbe..0000000 --- a/packet/order/power/packet_power/src/power.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include -#include -#include - -#include "packet_power/powerspacket.hpp" - -void Power::_loop() { - std::stringstream ss; - ss << "Hello, world! " << _count; - std_msgs::msg::String msg{}; - msg.data = ss.str(); - RCLCPP_INFO(this->get_logger(), "say %s", ss.str().c_str()); - _publisher->publish(msg); - _count++; -} - - -power::Power() : - rclcpp::Node("power"), - _publisher(), - _timer(), - _count(0) -{ - using namespace std::chrono_literals; - _publisher = this->create_publisher("/powerspacket", 10); - auto loop = std::bind(&Power::_loop, this); - _timer = this->create_wall_timer(500ms, loop); -} diff --git a/packet/order/power/packet_power/src/power_main.cpp b/packet/order/power/packet_power/src/power_main.cpp deleted file mode 100644 index 5af4c6d..0000000 --- a/packet/order/power/packet_power/src/power_main.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include -#include -#include "packet_power/powerspacket.hpp" - -int main(int argc, char * argv[]) { - rclcpp::init(argc, argv); - auto node = std::make_shared(); - rclcpp::spin(node); - rclcpp::shutdown(); - return 0; -} diff --git a/packet/order/quit/packet_quit/CMakeLists.txt b/packet/order/quit/packet_quit/CMakeLists.txt deleted file mode 100644 index 839a539..0000000 --- a/packet/order/quit/packet_quit/CMakeLists.txt +++ /dev/null @@ -1,36 +0,0 @@ -cmake_minimum_required(VERSION 3.8) -project(packet_quit) - -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) -# uncomment the following section in order to fill in -# further dependencies manually. -# find_package( REQUIRED) -find_package(rclcpp REQUIRED) -find_package(packet_interfaces REQUIRED) - - add_executable(Quit - src/quit_main.cpp - src/quit.cpp - ) - - ament_target_dependencies(Quit - rclcpp - packet_interfaces - ) - - target_include_directories(Quit - PUBLIC - $ - $ - ) - install(TARGETS - Quit - DESTINATION lib/${PROJECT_NAME} - ) - -ament_package() diff --git a/packet/order/quit/packet_quit/include/packet_quit/quitspacket.hpp b/packet/order/quit/packet_quit/include/packet_quit/quitspacket.hpp deleted file mode 100644 index f470885..0000000 --- a/packet/order/quit/packet_quit/include/packet_quit/quitspacket.hpp +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef PACKET_QUIT_QUITSPACKET_HPP -#define PACKET_QUIT_QUITSPACKET_HPP - -#include -#include "rclcpp/rclcpp.hpp" -#include "std_msgs/msg/string.hpp" - -class Quit : public rclcpp::Node { -private: - - std::shared_ptr> _publisher; - std::shared_ptr _timer; - unsigned int _count; - void _loop(); - -public: - Quit(); -}; - -#endif // PACKET_QUIT_QUITSPACKET_HPP - diff --git a/packet/order/quit/packet_quit/package.xml b/packet/order/quit/packet_quit/package.xml deleted file mode 100644 index 428e66b..0000000 --- a/packet/order/quit/packet_quit/package.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - packet_quit - 0.0.0 - TODO: Package description - norikonakano - MIT - ament_cmake - rclcpp - packet_interfaces - - ament_cmake - - diff --git a/packet/order/quit/packet_quit/src/quit.cpp b/packet/order/quit/packet_quit/src/quit.cpp deleted file mode 100644 index 751e399..0000000 --- a/packet/order/quit/packet_quit/src/quit.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include -#include -#include - -#include "packet_quit/quitspacket.hpp" - -void Quit::_loop() { - std::stringstream ss; - ss << "Hello, world! " << _count; - std_msgs::msg::String msg{}; - msg.data = ss.str(); - RCLCPP_INFO(this->get_logger(), "say %s", ss.str().c_str()); - _publisher->publish(msg); - _count++; -} - - -Quit::Quit() : - rclcpp::Node("quit"), - _publisher(), - _timer(), - _count(0) -{ - using namespace std::chrono_literals; - _publisher = this->create_publisher("/quitspacket", 10); - auto loop = std::bind(&Quit::_loop, this); - _timer = this->create_wall_timer(500ms, loop); -} - diff --git a/packet/order/quit/packet_quit/src/quit_main.cpp b/packet/order/quit/packet_quit/src/quit_main.cpp deleted file mode 100644 index 23d0533..0000000 --- a/packet/order/quit/packet_quit/src/quit_main.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include -#include -#include "packet_quit/quitspacket.hpp" - -int main(int argc, char * argv[]) { - rclcpp::init(argc, argv); - auto node = std::make_shared(); - rclcpp::spin(node); - rclcpp::shutdown(); - return 0; -} diff --git a/packet/packet_composed/CMakeLists.txt b/packet/packet_composed/CMakeLists.txt index c22f920..233c0f1 100644 --- a/packet/packet_composed/CMakeLists.txt +++ b/packet/packet_composed/CMakeLists.txt @@ -12,6 +12,8 @@ find_package(ament_cmake REQUIRED) # find_package( REQUIRED) find_package(rclcpp REQUIRED) find_package(packet_interfaces REQUIRED) +find_package(std_msgs REQUIRED) +find_package(sensor_msgs REQUIRED) add_executable(Composed src/composed_main.cpp @@ -20,6 +22,8 @@ find_package(packet_interfaces REQUIRED) ament_target_dependencies(Composed rclcpp + std_msgs + sensor_msgs packet_interfaces ) diff --git a/packet/packet_composed/include/packet_composed/sensorspacket.hpp b/packet/packet_composed/include/packet_composed/sensorspacket.hpp index cfa6b96..dfa56ef 100644 --- a/packet/packet_composed/include/packet_composed/sensorspacket.hpp +++ b/packet/packet_composed/include/packet_composed/sensorspacket.hpp @@ -7,11 +7,31 @@ class Composed : public rclcpp::Node { private: + rclcpp::Publisher::SharedPtr _publisher; + rclcpp::Publisher::SharedPtr composed_publisher; + + rclcpp::Subscription::SharedPtr depth_subscription; + rclcpp::Subscription::SharedPtr imu_subscription; + rclcpp::Subscription::SharedPtr flex1_subscription; + rclcpp::Subscription::SharedPtr flex2_subscription; + rclcpp::Subscription::SharedPtr current_subscription; + rclcpp::Subscription::SharedPtr voltage_subscription; + + //まとめてpublishするためにタイマーのつもり + rclcpp::TimerBase::SharedPtr _timer; + size_t _count; + packet_interfaces::msg::Composed composed_msg; - std::shared_ptr> _publisher; - std::shared_ptr _timer; - unsigned int _count; void _loop(); + void depth_topic_callback(const packet_interfaces::msg::Depth& msg); + void imu_topic_callback(const sensor_msgs::msg::Imu& msg); + void flex1_topic_callback(const packet_interfaces::msg::Flex1& msg); + void flex2_topic_callback(const packet_interfaces::msg::Flex2& msg); + void current_topic_callback(const packet_interfaces::msg::current& msg); + void voltage_topic_callback(const packet_interfaces::msg::voltage& msg); + + + // さらにいくつかのメソッド, プロパティが必要になる public: Composed(); diff --git a/packet/packet_composed/package.xml b/packet/packet_composed/package.xml index 597b503..1a65917 100644 --- a/packet/packet_composed/package.xml +++ b/packet/packet_composed/package.xml @@ -8,7 +8,16 @@ MIT ament_cmake rclcpp + std_msgs + sensor_msgs packet_interfaces + packet_interfaces + + rclcpp + std_msgs + sensor_msgs + packet_interfaces + ament_cmake diff --git a/packet/packet_composed/sensors/current/packet_current/CMakeLists.txt b/packet/packet_composed/sensors/current/packet_current/CMakeLists.txt deleted file mode 100644 index ea26507..0000000 --- a/packet/packet_composed/sensors/current/packet_current/CMakeLists.txt +++ /dev/null @@ -1,36 +0,0 @@ -cmake_minimum_required(VERSION 3.8) -project(packet_current) - -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) -# uncomment the following section in order to fill in -# further dependencies manually. -# find_package( REQUIRED) -find_package(rclcpp REQUIRED) -find_package(packet_interfaces REQUIRED) - - add_executable(Current - src/current_main.cpp - src/current.cpp - ) - - ament_target_dependencies(Current - rclcpp - packet_interfaces - ) - - target_include_directories(Current - PUBLIC - $ - $ - ) - install(TARGETS - Current - DESTINATION lib/${PROJECT_NAME} - ) - -ament_package() diff --git a/packet/packet_composed/sensors/current/packet_current/include/packet_current/currentspacket.hpp b/packet/packet_composed/sensors/current/packet_current/include/packet_current/currentspacket.hpp deleted file mode 100644 index 8205f7c..0000000 --- a/packet/packet_composed/sensors/current/packet_current/include/packet_current/currentspacket.hpp +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef PACKET_CURRENT_CURRENTSPACKET_HPP -#define PACKET_CURRENT_CURRENTSPACKET_HPP - -#include -#include "rclcpp/rclcpp.hpp" -#include "std_msgs/msg/string.hpp" - -class Current : public rclcpp::Node { -private: - - std::shared_ptr> _publisher; - std::shared_ptr _timer; - unsigned int _count; - void _loop(); - -public: - Current(); -}; - -#endif // PACKET_CURRENT_CURRENTSPACKET_HPP diff --git a/packet/packet_composed/sensors/current/packet_current/package.xml b/packet/packet_composed/sensors/current/packet_current/package.xml deleted file mode 100644 index f3dbc9d..0000000 --- a/packet/packet_composed/sensors/current/packet_current/package.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - packet_current - 0.0.0 - TODO: Package description - norikonakano - MIT - ament_cmake - rclcpp - packet_interfaces - - ament_cmake - - diff --git a/packet/packet_composed/sensors/current/packet_current/src/current.cpp b/packet/packet_composed/sensors/current/packet_current/src/current.cpp deleted file mode 100644 index 7334cec..0000000 --- a/packet/packet_composed/sensors/current/packet_current/src/current.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include -#include -#include - -#include "packet_current/currentspacket.hpp" - -void Current::_loop() { - std::stringstream ss; - ss << "Hello, world! " << _count; - std_msgs::msg::String msg{}; - msg.data = ss.str(); - RCLCPP_INFO(this->get_logger(), "say %s", ss.str().c_str()); - _publisher->publish(msg); - _count++; -} - - -Current::Current() : - rclcpp::Node("Current"), - _publisher(), - _timer(), - _count(0) -{ - using namespace std::chrono_literals; - _publisher = this->create_publisher("/currents_composed", 10); - auto loop = std::bind(&Current::_loop, this); - _timer = this->create_wall_timer(500ms, loop); -} diff --git a/packet/packet_composed/sensors/current/packet_current/src/current_main.cpp b/packet/packet_composed/sensors/current/packet_current/src/current_main.cpp deleted file mode 100644 index d4789d5..0000000 --- a/packet/packet_composed/sensors/current/packet_current/src/current_main.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include -#include -#include "packet_current/currentspacket.hpp" - -int main(int argc, char * argv[]) { - rclcpp::init(argc, argv); - auto node = std::make_shared(); - rclcpp::spin(node); - rclcpp::shutdown(); - return 0; -} diff --git a/packet/packet_composed/sensors/depth/packet_depth/CMakeLists.txt b/packet/packet_composed/sensors/depth/packet_depth/CMakeLists.txt deleted file mode 100644 index 3683e97..0000000 --- a/packet/packet_composed/sensors/depth/packet_depth/CMakeLists.txt +++ /dev/null @@ -1,36 +0,0 @@ -cmake_minimum_required(VERSION 3.8) -project(packet_depth) - -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) -# uncomment the following section in order to fill in -# further dependencies manually. -# find_package( REQUIRED) -find_package(rclcpp REQUIRED) -find_package(packet_interfaces REQUIRED) - - add_executable(Depth - src/depth_main.cpp - src/depth.cpp - ) - - ament_target_dependencies(Depth - rclcpp - packet_interfaces - ) - - target_include_directories(Depth - PUBLIC - $ - $ - ) - install(TARGETS - Depth - DESTINATION lib/${PROJECT_NAME} - ) - -ament_package() diff --git a/packet/packet_composed/sensors/depth/packet_depth/include/packet_depth/depthspacket.hpp b/packet/packet_composed/sensors/depth/packet_depth/include/packet_depth/depthspacket.hpp deleted file mode 100644 index 61ab5de..0000000 --- a/packet/packet_composed/sensors/depth/packet_depth/include/packet_depth/depthspacket.hpp +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef PACKET_DEPTH_DEPTHSPACKET_HPP -#define PACKET_DEPTH_DEPTHSPACKET_HPP - -#include -#include "rclcpp/rclcpp.hpp" -#include "std_msgs/msg/string.hpp" - -class Depth : public rclcpp::Node { -private: - - std::shared_ptr> _publisher; - std::shared_ptr _timer; - unsigned int _count; - void _loop(); - -public: - Depth(); -}; - -#endif // PACKET_DEPTH_DEPTHSPACKET_HPP diff --git a/packet/packet_composed/sensors/depth/packet_depth/package.xml b/packet/packet_composed/sensors/depth/packet_depth/package.xml deleted file mode 100644 index 83387c6..0000000 --- a/packet/packet_composed/sensors/depth/packet_depth/package.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - packet_depth - 0.0.0 - TODO: Package description - norikonakano - MIT - ament_cmake - rclcpp - packet_interfaces - - ament_cmake - - - diff --git a/packet/packet_composed/sensors/depth/packet_depth/src/depth.cpp b/packet/packet_composed/sensors/depth/packet_depth/src/depth.cpp deleted file mode 100644 index a0aa241..0000000 --- a/packet/packet_composed/sensors/depth/packet_depth/src/depth.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include -#include -#include - -#include "packet_depth/depthspacket.hpp" - -void Depth::_loop() { - std::stringstream ss; - ss << "Hello, world! " << _count; - std_msgs::msg::String msg{}; - msg.data = ss.str(); - RCLCPP_INFO(this->get_logger(), "say %s", ss.str().c_str()); - _publisher->publish(msg); - _count++; -} - - -Depth::Depth() : - rclcpp::Node("depth"), - _publisher(), - _timer(), - _count(0) -{ - using namespace std::chrono_literals; - _publisher = this->create_publisher("/depths_composed", 10); - auto loop = std::bind(&Depth::_loop, this); - _timer = this->create_wall_timer(500ms, loop); -} diff --git a/packet/packet_composed/sensors/depth/packet_depth/src/depth_main.cpp b/packet/packet_composed/sensors/depth/packet_depth/src/depth_main.cpp deleted file mode 100644 index 16415ff..0000000 --- a/packet/packet_composed/sensors/depth/packet_depth/src/depth_main.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include -#include -#include "packet_depth/depthspacket.hpp" - -int main(int argc, char * argv[]) { - rclcpp::init(argc, argv); - auto node = std::make_shared(); - rclcpp::spin(node); - rclcpp::shutdown(); - return 0; -} diff --git a/packet/packet_composed/sensors/flex/flex1/packet_flex1/CMakeLists.txt b/packet/packet_composed/sensors/flex/flex1/packet_flex1/CMakeLists.txt deleted file mode 100644 index 84f0a6b..0000000 --- a/packet/packet_composed/sensors/flex/flex1/packet_flex1/CMakeLists.txt +++ /dev/null @@ -1,36 +0,0 @@ -cmake_minimum_required(VERSION 3.8) -project(packet_flex1) - -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) -# uncomment the following section in order to fill in -# further dependencies manually. -# find_package( REQUIRED) -find_package(rclcpp REQUIRED) -find_package(packet_interfaces REQUIRED) - - add_executable(Flex1 - src/flex1_main.cpp - src/flex1.cpp - ) - - ament_target_dependencies(Flex1 - rclcpp - packet_interfaces - ) - - target_include_directories(Flex1 - PUBLIC - $ - $ - ) - install(TARGETS - Flex1 - DESTINATION lib/${PROJECT_NAME} - ) - -ament_package() diff --git a/packet/packet_composed/sensors/flex/flex1/packet_flex1/include/packet_flex1/flex1spacket.hpp b/packet/packet_composed/sensors/flex/flex1/packet_flex1/include/packet_flex1/flex1spacket.hpp deleted file mode 100644 index e814f3b..0000000 --- a/packet/packet_composed/sensors/flex/flex1/packet_flex1/include/packet_flex1/flex1spacket.hpp +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef PACKET_FLEX1_FLEX1SPACKET_HPP -#define PACKET_FLEX1_FLEX1SPACKET_HPP - -#include -#include "rclcpp/rclcpp.hpp" -#include "std_msgs/msg/string.hpp" - -class Flex1 : public rclcpp::Node { -private: - - std::shared_ptr> _publisher; - std::shared_ptr _timer; - unsigned int _count; - void _loop(); - -public: - Flex1(); -}; - -#endif // PACKET_FLEX1_FLEX1SPACKET_HPP diff --git a/packet/packet_composed/sensors/flex/flex1/packet_flex1/package.xml b/packet/packet_composed/sensors/flex/flex1/packet_flex1/package.xml deleted file mode 100644 index eb7aae3..0000000 --- a/packet/packet_composed/sensors/flex/flex1/packet_flex1/package.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - packet_flex1 - 0.0.0 - TODO: Package description - norikonakano - MIT - ament_cmake - rclcpp - packet_interfaces - - ament_cmake - - diff --git a/packet/packet_composed/sensors/flex/flex1/packet_flex1/src/flex1.cpp b/packet/packet_composed/sensors/flex/flex1/packet_flex1/src/flex1.cpp deleted file mode 100644 index 3ed53fe..0000000 --- a/packet/packet_composed/sensors/flex/flex1/packet_flex1/src/flex1.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include -#include -#include - -#include "packet_flex1/flex1spacket.hpp" - -void Flex1::_loop() { - std::stringstream ss; - ss << "Hello, world! " << _count; - std_msgs::msg::String msg{}; - msg.data = ss.str(); - RCLCPP_INFO(this->get_logger(), "say %s", ss.str().c_str()); - _publisher->publish(msg); - _count++; -} - - -Flex1::Flex1() : - rclcpp::Node("Flex1"), - _publisher(), - _timer(), - _count(0) -{ - using namespace std::chrono_literals; - _publisher = this->create_publisher("/Flex1_composed", 10); - auto loop = std::bind(&Flex1::_loop, this); - _timer = this->create_wall_timer(500ms, loop); -} diff --git a/packet/packet_composed/sensors/flex/flex1/packet_flex1/src/flex1_main.cpp b/packet/packet_composed/sensors/flex/flex1/packet_flex1/src/flex1_main.cpp deleted file mode 100644 index ac82c9b..0000000 --- a/packet/packet_composed/sensors/flex/flex1/packet_flex1/src/flex1_main.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include -#include -#include "packet_flex1/flex1spacket.hpp" - -int main(int argc, char * argv[]) { - rclcpp::init(argc, argv); - auto node = std::make_shared(); - rclcpp::spin(node); - rclcpp::shutdown(); - return 0; -} - diff --git a/packet/packet_composed/sensors/flex/flex2/packet_flex2/CMakeLists.txt b/packet/packet_composed/sensors/flex/flex2/packet_flex2/CMakeLists.txt deleted file mode 100644 index d2c6b05..0000000 --- a/packet/packet_composed/sensors/flex/flex2/packet_flex2/CMakeLists.txt +++ /dev/null @@ -1,36 +0,0 @@ -cmake_minimum_required(VERSION 3.8) -project(packet_flex2) - -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) -# uncomment the following section in order to fill in -# further dependencies manually. -# find_package( REQUIRED) -find_package(rclcpp REQUIRED) -find_package(packet_interfaces REQUIRED) - - add_executable(Flex2 - src/flex1_main.cpp - src/flex1.cpp - ) - - ament_target_dependencies(Flex2 - rclcpp - packet_interfaces - ) - - target_include_directories(Flex2 - PUBLIC - $ - $ - ) - install(TARGETS - Flex2 - DESTINATION lib/${PROJECT_NAME} - ) - -ament_package() diff --git a/packet/packet_composed/sensors/flex/flex2/packet_flex2/include/packet_flex2/flex2spacket.hpp b/packet/packet_composed/sensors/flex/flex2/packet_flex2/include/packet_flex2/flex2spacket.hpp deleted file mode 100644 index 00d8917..0000000 --- a/packet/packet_composed/sensors/flex/flex2/packet_flex2/include/packet_flex2/flex2spacket.hpp +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef PACKET_FLEX2_FLEX1SPACKET_HPP -#define PACKET_FLEX2_FLEX1SPACKET_HPP - -#include -#include "rclcpp/rclcpp.hpp" -#include "std_msgs/msg/string.hpp" - -class Flex2 : public rclcpp::Node { -private: - - std::shared_ptr> _publisher; - std::shared_ptr _timer; - unsigned int _count; - void _loop(); - -public: - Flex2(); -}; - -#endif // PACKET_FLEX2_FLEX1SPACKET_HPP diff --git a/packet/packet_composed/sensors/flex/flex2/packet_flex2/package.xml b/packet/packet_composed/sensors/flex/flex2/packet_flex2/package.xml deleted file mode 100644 index 4b77ff6..0000000 --- a/packet/packet_composed/sensors/flex/flex2/packet_flex2/package.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - packet_flex2 - 0.0.0 - TODO: Package description - norikonakano - MIT - ament_cmake - rclcpp - packet_interfaces - - ament_cmake - - diff --git a/packet/packet_composed/sensors/flex/flex2/packet_flex2/src/flex2.cpp b/packet/packet_composed/sensors/flex/flex2/packet_flex2/src/flex2.cpp deleted file mode 100644 index 4921b2f..0000000 --- a/packet/packet_composed/sensors/flex/flex2/packet_flex2/src/flex2.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include -#include -#include - -#include "packet_flex2/flex1spacket.hpp" - -void Flex1::_loop() { - std::stringstream ss; - ss << "Hello, world! " << _count; - std_msgs::msg::String msg{}; - msg.data = ss.str(); - RCLCPP_INFO(this->get_logger(), "say %s", ss.str().c_str()); - _publisher->publish(msg); - _count++; -} - - -Flex2::Flex2() : - rclcpp::Node("Flex1"), - _publisher(), - _timer(), - _count(0) -{ - using namespace std::chrono_literals; - _publisher = this->create_publisher("/Flex2_composed", 10); - auto loop = std::bind(&Flex2::_loop, this); - _timer = this->create_wall_timer(500ms, loop); -} diff --git a/packet/packet_composed/sensors/flex/flex2/packet_flex2/src/flex2_main.cpp b/packet/packet_composed/sensors/flex/flex2/packet_flex2/src/flex2_main.cpp deleted file mode 100644 index 732e656..0000000 --- a/packet/packet_composed/sensors/flex/flex2/packet_flex2/src/flex2_main.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include -#include -#include "packet_flex2/flex1spacket.hpp" - -int main(int argc, char * argv[]) { - rclcpp::init(argc, argv); - auto node = std::make_shared(); - rclcpp::spin(node); - rclcpp::shutdown(); - return 0; -} diff --git a/packet/packet_composed/sensors/voltage/packet_voltage/CMakeLists.txt b/packet/packet_composed/sensors/voltage/packet_voltage/CMakeLists.txt deleted file mode 100644 index 4cd0d8b..0000000 --- a/packet/packet_composed/sensors/voltage/packet_voltage/CMakeLists.txt +++ /dev/null @@ -1,36 +0,0 @@ -cmake_minimum_required(VERSION 3.8) -project(packet_voltage) - -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) -# uncomment the following section in order to fill in -# further dependencies manually. -# find_package( REQUIRED) -find_package(rclcpp REQUIRED) -find_package(packet_interfaces REQUIRED) - - add_executable(Voltage - src/voltage_main.cpp - src/voltage.cpp - ) - - ament_target_dependencies(Voltage - rclcpp - packet_interfaces - ) - - target_include_directories(Voltage - PUBLIC - $ - $ - ) - install(TARGETS - Voltage - DESTINATION lib/${PROJECT_NAME} - ) - -ament_package() \ No newline at end of file diff --git a/packet/packet_composed/sensors/voltage/packet_voltage/include/packet_voltage/voltagepacket.hpp b/packet/packet_composed/sensors/voltage/packet_voltage/include/packet_voltage/voltagepacket.hpp deleted file mode 100644 index edc10bf..0000000 --- a/packet/packet_composed/sensors/voltage/packet_voltage/include/packet_voltage/voltagepacket.hpp +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef PACKET_VOLTAGE_VOLTAGEPACKET_HPP -#define PACKET_VOLTAGE_VOLTAGEPACKET_HPP - -#include -#include "rclcpp/rclcpp.hpp" -#include "std_msgs/msg/string.hpp" - -class Voltage : public rclcpp::Node { -private: - - std::shared_ptr> _publisher; - std::shared_ptr _timer; - unsigned int _count; - void _loop(); - -public: - Voltage(); -}; - -#endif // PACKET_VOLTAGE_VOLTAGEPACKET_HPP diff --git a/packet/packet_composed/sensors/voltage/packet_voltage/package.xml b/packet/packet_composed/sensors/voltage/packet_voltage/package.xml deleted file mode 100644 index f179027..0000000 --- a/packet/packet_composed/sensors/voltage/packet_voltage/package.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - packet_voltage - 0.0.0 - TODO: Package description - norikonakano - MIT - ament_cmake - rclcpp - packet_interfaces - - ament_cmake - - diff --git a/packet/packet_composed/sensors/voltage/packet_voltage/src/voltage.cpp b/packet/packet_composed/sensors/voltage/packet_voltage/src/voltage.cpp deleted file mode 100644 index 00bf3c0..0000000 --- a/packet/packet_composed/sensors/voltage/packet_voltage/src/voltage.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include -#include -#include - -#include "packet_voltage/voltagepacket.hpp" - -void Composed::_loop() { - std::stringstream ss; - ss << "Hello, world! " << _count; - std_msgs::msg::String msg{}; - msg.data = ss.str(); - RCLCPP_INFO(this->get_logger(), "say %s", ss.str().c_str()); - _publisher->publish(msg); - _count++; -} - - -Voltage::Voltage() : - rclcpp::Node("voltage"), - _publisher(), - _timer(), - _count(0) -{ - using namespace std::chrono_literals; - _publisher = this->create_publisher("/voltages_composed", 10); - auto loop = std::bind(&Voltage::_loop, this); - _timer = this->create_wall_timer(500ms, loop); -} diff --git a/packet/packet_composed/sensors/voltage/packet_voltage/src/voltage_main.cpp b/packet/packet_composed/sensors/voltage/packet_voltage/src/voltage_main.cpp deleted file mode 100644 index ed7bd2b..0000000 --- a/packet/packet_composed/sensors/voltage/packet_voltage/src/voltage_main.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include -#include -#include "packet_voltage/voltagepacket.hpp" - -int main(int argc, char * argv[]) { - rclcpp::init(argc, argv); - auto node = std::make_shared(); - rclcpp::spin(node); - rclcpp::shutdown(); - return 0; -} diff --git a/packet/packet_composed/src/composed.cpp b/packet/packet_composed/src/composed.cpp index 6647b97..0f0f78d 100644 --- a/packet/packet_composed/src/composed.cpp +++ b/packet/packet_composed/src/composed.cpp @@ -1,9 +1,42 @@ #include #include #include - #include "packet_composed/sensorspacket.hpp" + +Composed::Composed() : + rclcpp::Node("composed"), + _publisher(), + _timer(), + _count(0) +{ + //composed_publisherをコンストラクタで初期化した。 + using namespace std::chrono_literals; + _publisher = this->create_publisher("/sensors_composed", 10); + composed_publisher = this->create_publisher("composed_topic", 10); + + depth_subscription = this->create_subscription( + "depth_topic", 10, std::bind(&Composed::depth_topic_callback, this, std::placeholders::_1)); + + imu_subscription = this->create_subscription( + "imu_topic", 10, std::bind(&Composed::imu_topic_callback, this, std::placeholders::_1)); + + flex1_subscription = this->create_subscription( + "flex1_topic", 10, std::bind(&Composed::flex1_topic_callback, this, std::placeholders::_1)); + + flex2_subscription = this->create_subscription( + "flex2_topic", 10, std::bind(&Composed::flex2_topic_callback, this, std::placeholders::_1)); + + current_subscription = this->create_subscription( + "current_topic", 10, std::bind(&Composed::current_topic_callback, this, std::placeholders::_1)); + + voltage_subscription = this->create_subscription( + "voltage_topic", 10, std::bind(&Composed::voltage_topic_callback, this, std::placeholders::_1)); + + auto loop = std::bind(&Composed::_loop, this); + _timer = this->create_wall_timer(500ms, loop); +} + void Composed::_loop() { std::stringstream ss; ss << "Hello, world! " << _count; @@ -14,15 +47,62 @@ void Composed::_loop() { _count++; } +void Composed::depth_topic_callback(const packet_interfaces::msg::Depth& msg) +{ + RCLCPP_INFO(this->get_logger(), "Received Depth message"); + // Composedメッセージにデータを追加 + auto composed_msg = packet_interfaces::msg::Composed(); + composed_msg.depth = msg; + // 他のデータも追加する + composed_publisher->publish(composed_msg); +} -Composed::Composed() : - rclcpp::Node("composed"), - _publisher(), - _timer(), - _count(0) +void Composed::imu_topic_callback(const sensor_msgs::msg::Imu& msg) { - using namespace std::chrono_literals; - _publisher = this->create_publisher("/sensors_composed", 10); - auto loop = std::bind(&Composed::_loop, this); - _timer = this->create_wall_timer(500ms, loop); + RCLCPP_INFO(this->get_logger(), "Received IMU message"); + // Composedメッセージにデータを追加 + auto composed_msg = packet_interfaces::msg::Composed(); + composed_msg.imu = msg; + // 他のデータも追加する + composed_publisher->publish(composed_msg); +} + +void Composed::flex1_topic_callback(const packet_interfaces::msg::Flex1& msg) +{ + RCLCPP_INFO(this->get_logger(), "Received Flex1 message"); + // Composedメッセージにデータを追加 + auto composed_msg = packet_interfaces::msg::Composed(); + composed_msg.flex1 = msg; + // 他のデータも追加する + composed_publisher->publish(composed_msg); +} + +void Composed::flex2_topic_callback(const packet_interfaces::msg::Flex2& msg) +{ + RCLCPP_INFO(this->get_logger(), "Received Flex2 message"); + // Composedメッセージにデータを追加 + auto composed_msg = packet_interfaces::msg::Composed(); + composed_msg.flex2 = msg; + // 他のデータも追加する + composed_publisher->publish(composed_msg); +} + +void Composed::current_topic_callback(const packet_interfaces::msg::Current2& msg) +{ + RCLCPP_INFO(this->get_logger(), "Received Current message"); + // Composedメッセージにデータを追加 + auto composed_msg = packet_interfaces::msg::Composed(); + composed_msg.Current = msg; + // 他のデータも追加する + composed_publisher->publish(composed_msg); +} + +void Composed::voltage_topic_callback(const packet_interfaces::msg::Voltage& msg) +{ + RCLCPP_INFO(this->get_logger(), "Received Flex2 message"); + // Composedメッセージにデータを追加 + auto composed_msg = packet_interfaces::msg::Composed(); + composed_msg.voltage = msg; + // 他のデータも追加する + composed_publisher->publish(composed_msg); } From d81c8ad945c410fdf820e34761d111e70eb59809 Mon Sep 17 00:00:00 2001 From: {Noir-swim} <{noriri.jwu@gmail.com}> Date: Wed, 26 Jun 2024 00:13:39 +0900 Subject: [PATCH 06/10] =?UTF-8?q?composed.cpp=E3=81=AE=E4=B8=80=E7=95=AA?= =?UTF-8?q?=E4=B8=8B=E3=81=AE=E8=A1=8C=E3=81=AB=E7=A9=BA=E7=99=BD=E3=82=92?= =?UTF-8?q?=E5=85=A5=E3=82=8C=E3=81=BE=E3=81=97=E3=81=9F=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packet/packet_composed/src/composed.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/packet/packet_composed/src/composed.cpp b/packet/packet_composed/src/composed.cpp index 0f0f78d..047aa76 100644 --- a/packet/packet_composed/src/composed.cpp +++ b/packet/packet_composed/src/composed.cpp @@ -106,3 +106,4 @@ void Composed::voltage_topic_callback(const packet_interfaces::msg::Voltage& msg // 他のデータも追加する composed_publisher->publish(composed_msg); } + From a3bfad16561dff9085efc316d6d3856f49c21a33 Mon Sep 17 00:00:00 2001 From: {Noir-swim} <{noriri.jwu@gmail.com}> Date: Fri, 28 Jun 2024 15:07:38 +0900 Subject: [PATCH 07/10] =?UTF-8?q?=E3=82=B3=E3=83=A1=E3=83=B3=E3=83=88?= =?UTF-8?q?=E8=A6=8B=E3=81=A6=E4=BF=AE=E6=AD=A3=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../.vscode/c_cpp_properties.json | 23 ----------------- packet/packet_composed/.vscode/settings.json | 16 ------------ .../include/packet_composed/sensorspacket.hpp | 6 ++--- packet/packet_composed/package.xml | 6 ----- packet/packet_composed/src/composed.cpp | 25 +++++++++---------- 5 files changed, 14 insertions(+), 62 deletions(-) delete mode 100644 packet/packet_composed/.vscode/c_cpp_properties.json delete mode 100644 packet/packet_composed/.vscode/settings.json diff --git a/packet/packet_composed/.vscode/c_cpp_properties.json b/packet/packet_composed/.vscode/c_cpp_properties.json deleted file mode 100644 index e4c98a0..0000000 --- a/packet/packet_composed/.vscode/c_cpp_properties.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "configurations": [ - { - "browse": { - "databaseFilename": "${default}", - "limitSymbolsToIncludedHeaders": false - }, - "includePath": [ - "/home/norikonakano/24jam_ws/install/packet_interfaces/include/**", - "/opt/ros/iron/include/**", - "/home/norikonakano/24jam_ws/src/2024_cavolinia/packet/packet_composed/include/**", - "include/**", - "/usr/include/**" - ], - "name": "ROS", - "intelliSenseMode": "gcc-x64", - "compilerPath": "/usr/bin/gcc", - "cStandard": "gnu11", - "cppStandard": "c++14" - } - ], - "version": 4 -} \ No newline at end of file diff --git a/packet/packet_composed/.vscode/settings.json b/packet/packet_composed/.vscode/settings.json deleted file mode 100644 index 2ca360d..0000000 --- a/packet/packet_composed/.vscode/settings.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "python.autoComplete.extraPaths": [ - "/home/norikonakano/24jam_ws/install/pi_i2c/lib/python3.10/site-packages", - "/home/norikonakano/24jam_ws/install/nucleo_communicate_py/lib/python3.10/site-packages", - "/home/norikonakano/24jam_ws/install/packet_interfaces/lib/python3.10/site-packages", - "/home/norikonakano/24jam_ws/install/joystick/lib/python3.10/site-packages", - "/opt/ros/iron/lib/python3.10/site-packages" - ], - "python.analysis.extraPaths": [ - "/home/norikonakano/24jam_ws/install/pi_i2c/lib/python3.10/site-packages", - "/home/norikonakano/24jam_ws/install/nucleo_communicate_py/lib/python3.10/site-packages", - "/home/norikonakano/24jam_ws/install/packet_interfaces/lib/python3.10/site-packages", - "/home/norikonakano/24jam_ws/install/joystick/lib/python3.10/site-packages", - "/opt/ros/iron/lib/python3.10/site-packages" - ] -} \ No newline at end of file diff --git a/packet/packet_composed/include/packet_composed/sensorspacket.hpp b/packet/packet_composed/include/packet_composed/sensorspacket.hpp index dfa56ef..aa2bd00 100644 --- a/packet/packet_composed/include/packet_composed/sensorspacket.hpp +++ b/packet/packet_composed/include/packet_composed/sensorspacket.hpp @@ -7,15 +7,13 @@ class Composed : public rclcpp::Node { private: - rclcpp::Publisher::SharedPtr _publisher; rclcpp::Publisher::SharedPtr composed_publisher; - rclcpp::Subscription::SharedPtr depth_subscription; rclcpp::Subscription::SharedPtr imu_subscription; rclcpp::Subscription::SharedPtr flex1_subscription; rclcpp::Subscription::SharedPtr flex2_subscription; - rclcpp::Subscription::SharedPtr current_subscription; - rclcpp::Subscription::SharedPtr voltage_subscription; + rclcpp::Subscription::SharedPtr current_subscription; + rclcpp::Subscription::SharedPtr voltage_subscription; //まとめてpublishするためにタイマーのつもり rclcpp::TimerBase::SharedPtr _timer; diff --git a/packet/packet_composed/package.xml b/packet/packet_composed/package.xml index 1a65917..053f41e 100644 --- a/packet/packet_composed/package.xml +++ b/packet/packet_composed/package.xml @@ -12,12 +12,6 @@ sensor_msgs packet_interfaces packet_interfaces - - rclcpp - std_msgs - sensor_msgs - packet_interfaces - ament_cmake diff --git a/packet/packet_composed/src/composed.cpp b/packet/packet_composed/src/composed.cpp index 047aa76..93fdfb2 100644 --- a/packet/packet_composed/src/composed.cpp +++ b/packet/packet_composed/src/composed.cpp @@ -12,26 +12,25 @@ Composed::Composed() : { //composed_publisherをコンストラクタで初期化した。 using namespace std::chrono_literals; - _publisher = this->create_publisher("/sensors_composed", 10); composed_publisher = this->create_publisher("composed_topic", 10); depth_subscription = this->create_subscription( - "depth_topic", 10, std::bind(&Composed::depth_topic_callback, this, std::placeholders::_1)); + "sensors_depth", 10, std::bind(&Composed::depth_topic_callback, this, std::placeholders::_1)); imu_subscription = this->create_subscription( - "imu_topic", 10, std::bind(&Composed::imu_topic_callback, this, std::placeholders::_1)); + "sensors_imu", 10, std::bind(&Composed::imu_topic_callback, this, std::placeholders::_1)); flex1_subscription = this->create_subscription( - "flex1_topic", 10, std::bind(&Composed::flex1_topic_callback, this, std::placeholders::_1)); + "sensors_flex1", 10, std::bind(&Composed::flex1_topic_callback, this, std::placeholders::_1)); flex2_subscription = this->create_subscription( - "flex2_topic", 10, std::bind(&Composed::flex2_topic_callback, this, std::placeholders::_1)); + "sensors_flex2", 10, std::bind(&Composed::flex2_topic_callback, this, std::placeholders::_1)); current_subscription = this->create_subscription( - "current_topic", 10, std::bind(&Composed::current_topic_callback, this, std::placeholders::_1)); + "sensors_current", 10, std::bind(&Composed::current_topic_callback, this, std::placeholders::_1)); voltage_subscription = this->create_subscription( - "voltage_topic", 10, std::bind(&Composed::voltage_topic_callback, this, std::placeholders::_1)); + "sensors_voltage", 10, std::bind(&Composed::voltage_topic_callback, this, std::placeholders::_1)); auto loop = std::bind(&Composed::_loop, this); _timer = this->create_wall_timer(500ms, loop); @@ -49,7 +48,7 @@ void Composed::_loop() { void Composed::depth_topic_callback(const packet_interfaces::msg::Depth& msg) { - RCLCPP_INFO(this->get_logger(), "Received Depth message"); + RCLCPP_DEBUG(this->get_logger(), "Received Depth message"); // Composedメッセージにデータを追加 auto composed_msg = packet_interfaces::msg::Composed(); composed_msg.depth = msg; @@ -59,7 +58,7 @@ void Composed::depth_topic_callback(const packet_interfaces::msg::Depth& msg) void Composed::imu_topic_callback(const sensor_msgs::msg::Imu& msg) { - RCLCPP_INFO(this->get_logger(), "Received IMU message"); + RCLCPP_DEBUG(this->get_logger(), "Received IMU message"); // Composedメッセージにデータを追加 auto composed_msg = packet_interfaces::msg::Composed(); composed_msg.imu = msg; @@ -69,7 +68,7 @@ void Composed::imu_topic_callback(const sensor_msgs::msg::Imu& msg) void Composed::flex1_topic_callback(const packet_interfaces::msg::Flex1& msg) { - RCLCPP_INFO(this->get_logger(), "Received Flex1 message"); + RCLCPP_DEBUG(this->get_logger(), "Received Flex1 message"); // Composedメッセージにデータを追加 auto composed_msg = packet_interfaces::msg::Composed(); composed_msg.flex1 = msg; @@ -79,7 +78,7 @@ void Composed::flex1_topic_callback(const packet_interfaces::msg::Flex1& msg) void Composed::flex2_topic_callback(const packet_interfaces::msg::Flex2& msg) { - RCLCPP_INFO(this->get_logger(), "Received Flex2 message"); + RCLCPP_DEBUG(this->get_logger(), "Received Flex2 message"); // Composedメッセージにデータを追加 auto composed_msg = packet_interfaces::msg::Composed(); composed_msg.flex2 = msg; @@ -89,7 +88,7 @@ void Composed::flex2_topic_callback(const packet_interfaces::msg::Flex2& msg) void Composed::current_topic_callback(const packet_interfaces::msg::Current2& msg) { - RCLCPP_INFO(this->get_logger(), "Received Current message"); + RCLCPP_DEBUG(this->get_logger(), "Received Current message"); // Composedメッセージにデータを追加 auto composed_msg = packet_interfaces::msg::Composed(); composed_msg.Current = msg; @@ -99,7 +98,7 @@ void Composed::current_topic_callback(const packet_interfaces::msg::Current2& ms void Composed::voltage_topic_callback(const packet_interfaces::msg::Voltage& msg) { - RCLCPP_INFO(this->get_logger(), "Received Flex2 message"); + RCLCPP_DEBUG(this->get_logger(), "Received Flex2 message"); // Composedメッセージにデータを追加 auto composed_msg = packet_interfaces::msg::Composed(); composed_msg.voltage = msg; From 8ebeebd62e350edae70eb670b5789f76a04d9e18 Mon Sep 17 00:00:00 2001 From: {Noir-swim} <{noriri.jwu@gmail.com}> Date: Sun, 30 Jun 2024 16:33:34 +0900 Subject: [PATCH 08/10] =?UTF-8?q?topic=E5=90=8D=E3=82=92=E5=A4=89=E3=81=88?= =?UTF-8?q?=E3=81=9F=E3=80=82=E3=82=B3=E3=83=BC=E3=83=89=E3=82=92=E5=A4=89?= =?UTF-8?q?=E6=9B=B4=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../include/packet_composed/sensorspacket.hpp | 17 ++- packet/packet_composed/src/composed.cpp | 134 +++++++++++++----- 2 files changed, 111 insertions(+), 40 deletions(-) diff --git a/packet/packet_composed/include/packet_composed/sensorspacket.hpp b/packet/packet_composed/include/packet_composed/sensorspacket.hpp index aa2bd00..234884a 100644 --- a/packet/packet_composed/include/packet_composed/sensorspacket.hpp +++ b/packet/packet_composed/include/packet_composed/sensorspacket.hpp @@ -27,7 +27,22 @@ class Composed : public rclcpp::Node { void flex2_topic_callback(const packet_interfaces::msg::Flex2& msg); void current_topic_callback(const packet_interfaces::msg::current& msg); void voltage_topic_callback(const packet_interfaces::msg::voltage& msg); - + + packet_interfaces::msg::Depth _depth; + sensor_msgs::msg::Imu _imu; + packet_interfaces::msg::Flex _flex1; + packet_interfaces::msg::Flex _flex2; + packet_interfaces::msg::Current _current; + packet_interfaces::msg::Voltage _voltage; + + bool _depth_received; + bool _imu_received; + bool _flex1_received; + bool _flex2_received; + bool _current_received; + bool _voltage_received; + //ブール関数をつかって、で受信したら初期化させるようにする? + // さらにいくつかのメソッド, プロパティが必要になる diff --git a/packet/packet_composed/src/composed.cpp b/packet/packet_composed/src/composed.cpp index 93fdfb2..409e6ab 100644 --- a/packet/packet_composed/src/composed.cpp +++ b/packet/packet_composed/src/composed.cpp @@ -6,44 +6,80 @@ Composed::Composed() : rclcpp::Node("composed"), - _publisher(), - _timer(), + _timer(), + _depth(), + _imu(), + _flex1(), + _flex2(), + _current(), + _voltage(), + _depth_received(false), + _imu_received(false), + _flex1_received(false), + _flex2_received(false), + _current_received(false), + _voltage_received(false) _count(0) { - //composed_publisherをコンストラクタで初期化した。 + //publisher,subscriptionを作る。 + using namespace std::chrono_literals; - composed_publisher = this->create_publisher("composed_topic", 10); + composed_publisher = this->create_publisher("sensors_composed", 10); depth_subscription = this->create_subscription( - "sensors_depth", 10, std::bind(&Composed::depth_topic_callback, this, std::placeholders::_1)); + "sensors/depth", 10, std::bind(&Composed::depth_topic_callback, this, std::placeholders::_1)); imu_subscription = this->create_subscription( - "sensors_imu", 10, std::bind(&Composed::imu_topic_callback, this, std::placeholders::_1)); + "sensors/imu", 10, std::bind(&Composed::imu_topic_callback, this, std::placeholders::_1)); flex1_subscription = this->create_subscription( - "sensors_flex1", 10, std::bind(&Composed::flex1_topic_callback, this, std::placeholders::_1)); + "sensors/flex/1", 10, std::bind(&Composed::flex1_topic_callback, this, std::placeholders::_1)); flex2_subscription = this->create_subscription( - "sensors_flex2", 10, std::bind(&Composed::flex2_topic_callback, this, std::placeholders::_1)); - + "sensors/flex/2", 10, std::bind(&Composed::flex2_topic_callback, this, std::placeholders::_1)); + current_subscription = this->create_subscription( - "sensors_current", 10, std::bind(&Composed::current_topic_callback, this, std::placeholders::_1)); + "sensors/current", 10, std::bind(&Composed::current_topic_callback, this, std::placeholders::_1)); voltage_subscription = this->create_subscription( - "sensors_voltage", 10, std::bind(&Composed::voltage_topic_callback, this, std::placeholders::_1)); + "sensors/voltage", 10, std::bind(&Composed::, this, std::placeholders::_1)); auto loop = std::bind(&Composed::_loop, this); _timer = this->create_wall_timer(500ms, loop); } void Composed::_loop() { - std::stringstream ss; - ss << "Hello, world! " << _count; - std_msgs::msg::String msg{}; - msg.data = ss.str(); - RCLCPP_INFO(this->get_logger(), "say %s", ss.str().c_str()); - _publisher->publish(msg); - _count++; + + //下のif文のcallbackとtimerのcallbackは非同期に呼ばれるからできなさそう。。。↓ + if (_depth_received && _imu_received && _flex1_received && _flex2_received && _current_received && _voltage_received) + { + auto composed_msg = packet_interfaces::msg::Composed(); + composed_msg.depth = _depth; + composed_msg.imu = _imu; + composed_msg.flex1 = _flex1; + composed_msg.flex2 = _flex2; + composed_msg.current = _current; + composed_msg.voltage = _voltage; + + composed_publisher->publish(composed_msg); + + // メッセージを再度受信させる。 + _depth_received = false; + _imu_received = false; + _flex1_received = false; + _flex2_received = false; + _current_received = false; + _voltage_received = false; + + //文字列はもういらない?? + // std::stringstream ss; + // ss << "Hello, world! " << _count; + // std_msgs::msg::String msg{}; + // msg.data = ss.str(); + // RCLCPP_INFO(this->get_logger(), "say %s", ss.str().c_str()); + // composed_publisher->publish(composed_msg); + // _count++; + } } void Composed::depth_topic_callback(const packet_interfaces::msg::Depth& msg) @@ -51,58 +87,78 @@ void Composed::depth_topic_callback(const packet_interfaces::msg::Depth& msg) RCLCPP_DEBUG(this->get_logger(), "Received Depth message"); // Composedメッセージにデータを追加 auto composed_msg = packet_interfaces::msg::Composed(); - composed_msg.depth = msg; + // composed_msg.depth = msg; + + _depth = msg; // 受信した深度データを保存 + _depth_received = true; + // 他のデータも追加する - composed_publisher->publish(composed_msg); + // composed_publisher->publish(composed_msg); ここでやらず_loopでする? } void Composed::imu_topic_callback(const sensor_msgs::msg::Imu& msg) { RCLCPP_DEBUG(this->get_logger(), "Received IMU message"); // Composedメッセージにデータを追加 - auto composed_msg = packet_interfaces::msg::Composed(); - composed_msg.imu = msg; + // auto composed_msg = packet_interfaces::msg::Composed(); + // composed_msg.imu = msg; + + _imu = msg; // 受信したIMUデータを保存 + _imu_received = true; + // 他のデータも追加する - composed_publisher->publish(composed_msg); + // composed_publisher->publish(composed_msg); ここでやらず_loopでする? } void Composed::flex1_topic_callback(const packet_interfaces::msg::Flex1& msg) { RCLCPP_DEBUG(this->get_logger(), "Received Flex1 message"); // Composedメッセージにデータを追加 - auto composed_msg = packet_interfaces::msg::Composed(); - composed_msg.flex1 = msg; - // 他のデータも追加する - composed_publisher->publish(composed_msg); + // auto composed_msg = packet_interfaces::msg::Composed(); + // composed_msg.flex1 = msg; + + _flex1 = msg; // 受信したFlex1データを保存 + _flex1_received = true; + + //composed_publisher->publish(composed_msg); ここでやらず_loopでする? } void Composed::flex2_topic_callback(const packet_interfaces::msg::Flex2& msg) { RCLCPP_DEBUG(this->get_logger(), "Received Flex2 message"); // Composedメッセージにデータを追加 - auto composed_msg = packet_interfaces::msg::Composed(); - composed_msg.flex2 = msg; - // 他のデータも追加する - composed_publisher->publish(composed_msg); + // auto composed_msg = packet_interfaces::msg::Composed(); + // composed_msg.flex2 = msg; + + _flex2 = msg; // 受信したFlex2データを保存 + _flex2_received = true; + + //composed_publisher->publish(composed_msg); ここでやらず_loopでする? } void Composed::current_topic_callback(const packet_interfaces::msg::Current2& msg) { RCLCPP_DEBUG(this->get_logger(), "Received Current message"); // Composedメッセージにデータを追加 - auto composed_msg = packet_interfaces::msg::Composed(); - composed_msg.Current = msg; - // 他のデータも追加する - composed_publisher->publish(composed_msg); + // auto composed_msg = packet_interfaces::msg::Composed(); + // composed_msg.Current = msg; + + _current = msg; // 受信したCurrentデータを保存 + _current_received = true; + + //composed_publisher->publish(composed_msg); ここでやらず_loopでする? } void Composed::voltage_topic_callback(const packet_interfaces::msg::Voltage& msg) { RCLCPP_DEBUG(this->get_logger(), "Received Flex2 message"); // Composedメッセージにデータを追加 - auto composed_msg = packet_interfaces::msg::Composed(); - composed_msg.voltage = msg; - // 他のデータも追加する - composed_publisher->publish(composed_msg); + // auto composed_msg = packet_interfaces::msg::Composed(); + // composed_msg.voltage = msg; + + _voltage = msg; // 受信したVoltageデータを保存 + _voltage_received = true; + + //composed_publisher->publish(composed_msg); ここでやらず_loopでする? } From f7a54e3f7e9ea8f47cc736bd36115d1531bde709 Mon Sep 17 00:00:00 2001 From: {Noir-swim} <{noriri.jwu@gmail.com}> Date: Tue, 2 Jul 2024 19:28:56 +0900 Subject: [PATCH 09/10] =?UTF-8?q?=E3=82=B3=E3=83=A1=E3=83=B3=E3=83=88?= =?UTF-8?q?=E8=A6=8B=E3=81=A6=E7=9B=B4=E3=81=97=E3=81=BE=E3=81=97=E3=81=9F?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../include/packet_composed/sensorspacket.hpp | 5 -- packet/packet_composed/src/composed.cpp | 73 ++----------------- 2 files changed, 8 insertions(+), 70 deletions(-) diff --git a/packet/packet_composed/include/packet_composed/sensorspacket.hpp b/packet/packet_composed/include/packet_composed/sensorspacket.hpp index 234884a..8bb3941 100644 --- a/packet/packet_composed/include/packet_composed/sensorspacket.hpp +++ b/packet/packet_composed/include/packet_composed/sensorspacket.hpp @@ -15,7 +15,6 @@ class Composed : public rclcpp::Node { rclcpp::Subscription::SharedPtr current_subscription; rclcpp::Subscription::SharedPtr voltage_subscription; - //まとめてpublishするためにタイマーのつもり rclcpp::TimerBase::SharedPtr _timer; size_t _count; packet_interfaces::msg::Composed composed_msg; @@ -41,10 +40,6 @@ class Composed : public rclcpp::Node { bool _flex2_received; bool _current_received; bool _voltage_received; - //ブール関数をつかって、で受信したら初期化させるようにする? - - - // さらにいくつかのメソッド, プロパティが必要になる public: Composed(); diff --git a/packet/packet_composed/src/composed.cpp b/packet/packet_composed/src/composed.cpp index 409e6ab..2b85384 100644 --- a/packet/packet_composed/src/composed.cpp +++ b/packet/packet_composed/src/composed.cpp @@ -19,9 +19,7 @@ Composed::Composed() : _flex2_received(false), _current_received(false), _voltage_received(false) - _count(0) { - //publisher,subscriptionを作る。 using namespace std::chrono_literals; composed_publisher = this->create_publisher("sensors_composed", 10); @@ -42,15 +40,14 @@ Composed::Composed() : "sensors/current", 10, std::bind(&Composed::current_topic_callback, this, std::placeholders::_1)); voltage_subscription = this->create_subscription( - "sensors/voltage", 10, std::bind(&Composed::, this, std::placeholders::_1)); + "sensors/voltage", 10, std::bind(&Composed::voltage_topic_callback, this, std::placeholders::_1)); auto loop = std::bind(&Composed::_loop, this); - _timer = this->create_wall_timer(500ms, loop); + _timer = this->create_wall_timer(10ms, loop); } void Composed::_loop() { - //下のif文のcallbackとtimerのcallbackは非同期に呼ばれるからできなさそう。。。↓ if (_depth_received && _imu_received && _flex1_received && _flex2_received && _current_received && _voltage_received) { auto composed_msg = packet_interfaces::msg::Composed(); @@ -63,102 +60,48 @@ void Composed::_loop() { composed_publisher->publish(composed_msg); - // メッセージを再度受信させる。 - _depth_received = false; - _imu_received = false; - _flex1_received = false; - _flex2_received = false; - _current_received = false; - _voltage_received = false; - - //文字列はもういらない?? - // std::stringstream ss; - // ss << "Hello, world! " << _count; - // std_msgs::msg::String msg{}; - // msg.data = ss.str(); - // RCLCPP_INFO(this->get_logger(), "say %s", ss.str().c_str()); - // composed_publisher->publish(composed_msg); - // _count++; } } void Composed::depth_topic_callback(const packet_interfaces::msg::Depth& msg) { RCLCPP_DEBUG(this->get_logger(), "Received Depth message"); - // Composedメッセージにデータを追加 auto composed_msg = packet_interfaces::msg::Composed(); - // composed_msg.depth = msg; - - _depth = msg; // 受信した深度データを保存 + _depth = msg; _depth_received = true; - - // 他のデータも追加する - // composed_publisher->publish(composed_msg); ここでやらず_loopでする? } void Composed::imu_topic_callback(const sensor_msgs::msg::Imu& msg) { RCLCPP_DEBUG(this->get_logger(), "Received IMU message"); - // Composedメッセージにデータを追加 - // auto composed_msg = packet_interfaces::msg::Composed(); - // composed_msg.imu = msg; - - _imu = msg; // 受信したIMUデータを保存 + _imu = msg; _imu_received = true; - - // 他のデータも追加する - // composed_publisher->publish(composed_msg); ここでやらず_loopでする? } void Composed::flex1_topic_callback(const packet_interfaces::msg::Flex1& msg) { RCLCPP_DEBUG(this->get_logger(), "Received Flex1 message"); - // Composedメッセージにデータを追加 - // auto composed_msg = packet_interfaces::msg::Composed(); - // composed_msg.flex1 = msg; - - _flex1 = msg; // 受信したFlex1データを保存 + _flex1 = msg; _flex1_received = true; - - //composed_publisher->publish(composed_msg); ここでやらず_loopでする? } void Composed::flex2_topic_callback(const packet_interfaces::msg::Flex2& msg) { RCLCPP_DEBUG(this->get_logger(), "Received Flex2 message"); - // Composedメッセージにデータを追加 - // auto composed_msg = packet_interfaces::msg::Composed(); - // composed_msg.flex2 = msg; - - _flex2 = msg; // 受信したFlex2データを保存 + _flex2 = msg; _flex2_received = true; - - //composed_publisher->publish(composed_msg); ここでやらず_loopでする? } void Composed::current_topic_callback(const packet_interfaces::msg::Current2& msg) { RCLCPP_DEBUG(this->get_logger(), "Received Current message"); - // Composedメッセージにデータを追加 - // auto composed_msg = packet_interfaces::msg::Composed(); - // composed_msg.Current = msg; - - _current = msg; // 受信したCurrentデータを保存 + _current = msg; _current_received = true; - - //composed_publisher->publish(composed_msg); ここでやらず_loopでする? } void Composed::voltage_topic_callback(const packet_interfaces::msg::Voltage& msg) { RCLCPP_DEBUG(this->get_logger(), "Received Flex2 message"); - // Composedメッセージにデータを追加 - // auto composed_msg = packet_interfaces::msg::Composed(); - // composed_msg.voltage = msg; - - _voltage = msg; // 受信したVoltageデータを保存 + _voltage = msg; _voltage_received = true; - - //composed_publisher->publish(composed_msg); ここでやらず_loopでする? } - From 5bf7ff3a483e30012c3e3166a108212255508b40 Mon Sep 17 00:00:00 2001 From: {Noir-swim} <{noriri.jwu@gmail.com}> Date: Thu, 4 Jul 2024 14:04:44 +0900 Subject: [PATCH 10/10] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E3=81=97=E3=81=BE?= =?UTF-8?q?=E3=81=97=E3=81=9F=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packet/packet_composed/include/packet_composed/sensorspacket.hpp | 1 - packet/packet_composed/package.xml | 1 - 2 files changed, 2 deletions(-) diff --git a/packet/packet_composed/include/packet_composed/sensorspacket.hpp b/packet/packet_composed/include/packet_composed/sensorspacket.hpp index 8bb3941..d383d10 100644 --- a/packet/packet_composed/include/packet_composed/sensorspacket.hpp +++ b/packet/packet_composed/include/packet_composed/sensorspacket.hpp @@ -16,7 +16,6 @@ class Composed : public rclcpp::Node { rclcpp::Subscription::SharedPtr voltage_subscription; rclcpp::TimerBase::SharedPtr _timer; - size_t _count; packet_interfaces::msg::Composed composed_msg; void _loop(); diff --git a/packet/packet_composed/package.xml b/packet/packet_composed/package.xml index 053f41e..0f77539 100644 --- a/packet/packet_composed/package.xml +++ b/packet/packet_composed/package.xml @@ -11,7 +11,6 @@ std_msgs sensor_msgs packet_interfaces - packet_interfaces ament_cmake