From a8cb7a3f1ca089c2cb12635176443a3cf92b80cf Mon Sep 17 00:00:00 2001 From: Kentaro Tanaka Date: Thu, 26 Dec 2019 22:02:41 +0900 Subject: [PATCH 01/16] delete description.launch.py --- .../launch/description.launch.py | 48 ------------------- 1 file changed, 48 deletions(-) delete mode 100644 consai2r2_description/launch/description.launch.py diff --git a/consai2r2_description/launch/description.launch.py b/consai2r2_description/launch/description.launch.py deleted file mode 100644 index 0e35c31..0000000 --- a/consai2r2_description/launch/description.launch.py +++ /dev/null @@ -1,48 +0,0 @@ -# Copyright (c) 2019 SSL-Roots -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. - -import os - -from ament_index_python.packages import get_package_share_directory -from launch import LaunchDescription -from launch_ros.actions import Node - - -def generate_launch_description(): - config_path = os.path.join( - get_package_share_directory('consai2r2_description'), 'config', 'config.yaml') - - return LaunchDescription([ - Node( - package='consai2r2_description', node_executable='consai2r2_description_node', - output='screen', parameters=[config_path]), - Node( - package='consai2r2_receiver', node_executable='referee_receiver', - output='screen', parameters=[config_path]), - Node( - package='consai2r2_receiver', node_executable='vision_receiver', - output='screen', parameters=[config_path]), - Node( - package='consai2r2_vision_wrapper', node_executable='vision_wrapper', - output='screen', parameters=[config_path]), - Node( - package='consai2r2_referee_wrapper', node_executable='referee_wrapper', - output='screen', parameters=[config_path]), - ]) From 174b7aa3901e6a8e1249824c7768c370ace4e22a Mon Sep 17 00:00:00 2001 From: Mirai Hattori <17918740+future731@users.noreply.github.com> Date: Fri, 27 Dec 2019 15:35:00 +0900 Subject: [PATCH 02/16] [README.md] fix typo --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index cedba6e..553b70a 100644 --- a/README.md +++ b/README.md @@ -99,11 +99,11 @@ GitHubのProjects機能で開発方針に合わせたタスク管理をしてい - [2nd step - SSL Game Example](https://github.com/SSL-Roots/consai2r2/projects/3) - [3rd step - use ROS2 effectively](https://github.com/SSL-Roots/consai2r2/projects/2) -# Controbution +# Contribution issue, pull request 大歓迎です。 -[CONTORIBUTING.md](./CONTRIBUTING.md)を見てくれると嬉しいです。 +[CONTIRIBUTING.md](./CONTRIBUTING.md)を見てくれると嬉しいです。 # Author & Contributors From 02def9bc778cf0568e38918b04b86cf4ac6d1605 Mon Sep 17 00:00:00 2001 From: Mirai Hattori Date: Fri, 27 Dec 2019 16:58:05 +0900 Subject: [PATCH 03/16] add grsim port and addr parameter file --- consai2r2_sender/CMakeLists.txt | 10 +++++ consai2r2_sender/README.md | 53 ++++++++++++++++++++++++ consai2r2_sender/config/grsim.yaml | 4 ++ consai2r2_sender/launch/sender.launch.py | 43 +++++++++++++++++++ consai2r2_sender/package.xml | 2 + 5 files changed, 112 insertions(+) create mode 100644 consai2r2_sender/README.md create mode 100644 consai2r2_sender/config/grsim.yaml create mode 100644 consai2r2_sender/launch/sender.launch.py diff --git a/consai2r2_sender/CMakeLists.txt b/consai2r2_sender/CMakeLists.txt index b211072..25813de 100644 --- a/consai2r2_sender/CMakeLists.txt +++ b/consai2r2_sender/CMakeLists.txt @@ -49,6 +49,16 @@ install(TARGETS sim_sender EXPORT export_${PROJECT_NAME} DESTINATION lib/${PROJECT_NAME}) +install(DIRECTORY + config + DESTINATION share/${PROJECT_NAME}/ +) + +install(DIRECTORY + launch + DESTINATION share/${PROJECT_NAME}/ +) + if(BUILD_TESTING) find_package(ament_lint_auto REQUIRED) # the following line skips the linter which checks for copyrights diff --git a/consai2r2_sender/README.md b/consai2r2_sender/README.md new file mode 100644 index 0000000..6054eba --- /dev/null +++ b/consai2r2_sender/README.md @@ -0,0 +1,53 @@ +# consai2_sender + +ロボット(grSim)へ動作司令を送信するパッケージです。 + + + +## ノードの起動方法 + +次のコマンドでsenderが起動します。 + +```sh +ros2 launch consai2r2_sender sender.launch.py +``` + + + + + + + +## 参考ページ +### Google proto files --> +- grSim + - https://github.com/RoboCup-SSL/grSim/tree/master/src/proto diff --git a/consai2r2_sender/config/grsim.yaml b/consai2r2_sender/config/grsim.yaml new file mode 100644 index 0000000..f99734a --- /dev/null +++ b/consai2r2_sender/config/grsim.yaml @@ -0,0 +1,4 @@ +consai2r2_sender: + ros__parameters: + grsim_addr: '127.0.0.1' + grsim_port: 20011 diff --git a/consai2r2_sender/launch/sender.launch.py b/consai2r2_sender/launch/sender.launch.py new file mode 100644 index 0000000..f3c5c08 --- /dev/null +++ b/consai2r2_sender/launch/sender.launch.py @@ -0,0 +1,43 @@ +# Copyright (c) 2019 SSL-Roots +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +import os +from ament_index_python.packages import get_package_share_directory +from launch import LaunchDescription +from launch.substitutions import LaunchConfiguration +from launch_ros.actions import Node + + +def generate_launch_description(): + + # sim = LaunchConfiguration('sim') # TODO : 現在未使用 シミュレータの切り替え用 + + start_sender_cmd = Node( + package='consai2r2_sender', node_executable='sim_sender', + output='screen', + parameters=[os.path.join(get_package_share_directory( + 'consai2r2_sender'), 'config', 'grsim.yaml')] + ) + + ld = LaunchDescription() + + ld.add_action(start_sender_cmd) + + return ld diff --git a/consai2r2_sender/package.xml b/consai2r2_sender/package.xml index bf2df8d..9e935f0 100644 --- a/consai2r2_sender/package.xml +++ b/consai2r2_sender/package.xml @@ -8,6 +8,7 @@ MIT ament_cmake + python_cmake_module rclcpp std_msgs @@ -15,6 +16,7 @@ protobuf-dev boost + launch_ros ament_lint_auto ament_lint_common From 91f1c39a83febe1ae6e71541dbe262d23459ae9a Mon Sep 17 00:00:00 2001 From: Mirai Hattori Date: Sun, 29 Dec 2019 00:11:21 +0900 Subject: [PATCH 04/16] remove unnecessary import form sender.launch --- consai2r2_sender/launch/sender.launch.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/consai2r2_sender/launch/sender.launch.py b/consai2r2_sender/launch/sender.launch.py index f3c5c08..2b86d28 100644 --- a/consai2r2_sender/launch/sender.launch.py +++ b/consai2r2_sender/launch/sender.launch.py @@ -21,14 +21,10 @@ import os from ament_index_python.packages import get_package_share_directory from launch import LaunchDescription -from launch.substitutions import LaunchConfiguration from launch_ros.actions import Node def generate_launch_description(): - - # sim = LaunchConfiguration('sim') # TODO : 現在未使用 シミュレータの切り替え用 - start_sender_cmd = Node( package='consai2r2_sender', node_executable='sim_sender', output='screen', From 6bec70e3bc443c500dfbab2809a0734ce04763e8 Mon Sep 17 00:00:00 2001 From: Mirai Hattori Date: Tue, 31 Dec 2019 09:38:17 +0900 Subject: [PATCH 05/16] [consai2r2_sender] add parameters client --- consai2r2_sender/src/sim_sender.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/consai2r2_sender/src/sim_sender.cpp b/consai2r2_sender/src/sim_sender.cpp index 2590b09..3a67683 100644 --- a/consai2r2_sender/src/sim_sender.cpp +++ b/consai2r2_sender/src/sim_sender.cpp @@ -32,6 +32,7 @@ #include "grSim_Replacement.pb.h" using std::placeholders::_1; +using namespace std::chrono_literals; namespace asio = boost::asio; @@ -69,8 +70,17 @@ class SimSender : public rclcpp::Node this->declare_parameter("grsim_addr", "127.0.0.1"); this->declare_parameter("grsim_port", 20011); - this->get_parameter("grsim_addr", host); - this->get_parameter("grsim_port", port); + auto parameters_client = std::make_shared(this); + while (!parameters_client->wait_for_service(1s)) { + if (!rclcpp::ok()) { + RCLCPP_ERROR(this->get_logger(), "Interrupted while waiting for the service. Exiting."); + rclcpp::shutdown(); + } + RCLCPP_INFO(this->get_logger(), "service not available, waiting again..."); + } + + parameters_client->get_parameter("grsim_addr", host); + parameters_client->get_parameter("grsim_port", port); sub_commands_ = this->create_subscription( "robot_commands", 10, std::bind(&SimSender::send_commands, this, std::placeholders::_1)); From 8a12f73f612fb68bfaab8525d9f2a3f0bf5c528c Mon Sep 17 00:00:00 2001 From: ShotaAk Date: Tue, 31 Dec 2019 16:53:16 +0900 Subject: [PATCH 06/16] Add gameviewer plugin that displays HelloWorld text --- consai2r2_gameviewer/CMakeLists.txt | 23 +++++++ consai2r2_gameviewer/package.xml | 24 +++++++ consai2r2_gameviewer/plugin.xml | 17 +++++ .../resource/gameviewer_widget.ui | 19 ++++++ .../scripts/consai2r2_gameviewer | 8 +++ .../src/consai2r2_gameviewer/__init__.py | 0 .../src/consai2r2_gameviewer/gameviewer.py | 62 +++++++++++++++++++ .../consai2r2_gameviewer/gameviewer_widget.py | 57 +++++++++++++++++ 8 files changed, 210 insertions(+) create mode 100644 consai2r2_gameviewer/CMakeLists.txt create mode 100644 consai2r2_gameviewer/package.xml create mode 100644 consai2r2_gameviewer/plugin.xml create mode 100644 consai2r2_gameviewer/resource/gameviewer_widget.ui create mode 100644 consai2r2_gameviewer/scripts/consai2r2_gameviewer create mode 100644 consai2r2_gameviewer/src/consai2r2_gameviewer/__init__.py create mode 100644 consai2r2_gameviewer/src/consai2r2_gameviewer/gameviewer.py create mode 100644 consai2r2_gameviewer/src/consai2r2_gameviewer/gameviewer_widget.py diff --git a/consai2r2_gameviewer/CMakeLists.txt b/consai2r2_gameviewer/CMakeLists.txt new file mode 100644 index 0000000..a0d30db --- /dev/null +++ b/consai2r2_gameviewer/CMakeLists.txt @@ -0,0 +1,23 @@ +cmake_minimum_required(VERSION 3.5) +project(consai2r2_gameviewer) + +# Load ament and all dependencies required for this package +find_package(ament_cmake REQUIRED) +find_package(ament_cmake_python REQUIRED) + +ament_python_install_package(${PROJECT_NAME} + PACKAGE_DIR src/${PROJECT_NAME}) + +install(FILES plugin.xml + DESTINATION share/${PROJECT_NAME} +) + +install(DIRECTORY resource + DESTINATION share/${PROJECT_NAME} +) + +install(PROGRAMS scripts/consai2r2_gameviewer + DESTINATION lib/${PROJECT_NAME} +) + +ament_package() diff --git a/consai2r2_gameviewer/package.xml b/consai2r2_gameviewer/package.xml new file mode 100644 index 0000000..3da52a4 --- /dev/null +++ b/consai2r2_gameviewer/package.xml @@ -0,0 +1,24 @@ + + + + consai2r2_gameviewer + 0.0.0 + consai2r2_gameviewer provides a GUI plugin for displaying vision and referee messages. + akshota + MIT + + ament_cmake + + ament_index_python + python_qt_binding + rclpy + rqt_gui + rqt_gui_py + rqt_py_common + + + + + ament_cmake + + diff --git a/consai2r2_gameviewer/plugin.xml b/consai2r2_gameviewer/plugin.xml new file mode 100644 index 0000000..8217d8d --- /dev/null +++ b/consai2r2_gameviewer/plugin.xml @@ -0,0 +1,17 @@ + + + + A Python GUI plugin for displaying vision and referee messages. + + + + + folder + Plugins related to visualization. + + + image-x-generic + A Python GUI plugin for displaying vision and referee messages. + + + diff --git a/consai2r2_gameviewer/resource/gameviewer_widget.ui b/consai2r2_gameviewer/resource/gameviewer_widget.ui new file mode 100644 index 0000000..1f346fa --- /dev/null +++ b/consai2r2_gameviewer/resource/gameviewer_widget.ui @@ -0,0 +1,19 @@ + + + GameViewerWidget + + + + 0 + 0 + 400 + 300 + + + + GameViewer + + + + + diff --git a/consai2r2_gameviewer/scripts/consai2r2_gameviewer b/consai2r2_gameviewer/scripts/consai2r2_gameviewer new file mode 100644 index 0000000..bcb9058 --- /dev/null +++ b/consai2r2_gameviewer/scripts/consai2r2_gameviewer @@ -0,0 +1,8 @@ +#!/usr/bin/env python3 + +import sys + +from rqt_gui.main import Main + +main = Main() +sys.exit(main.main(sys.argv, standalone='consai2r2_gameviewer.gameviewer.GameViewer')) diff --git a/consai2r2_gameviewer/src/consai2r2_gameviewer/__init__.py b/consai2r2_gameviewer/src/consai2r2_gameviewer/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/consai2r2_gameviewer/src/consai2r2_gameviewer/gameviewer.py b/consai2r2_gameviewer/src/consai2r2_gameviewer/gameviewer.py new file mode 100644 index 0000000..62826ec --- /dev/null +++ b/consai2r2_gameviewer/src/consai2r2_gameviewer/gameviewer.py @@ -0,0 +1,62 @@ +# Copyright (c) 2019 SSL-Roots +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +from qt_gui.plugin import Plugin +from python_qt_binding.QtCore import QTimer + +from consai2r2_gameviewer.gameviewer_widget import GameViewerWidget + + +class GameViewer(Plugin): + + """ + consai2r2_gameviwer plugin's main class. + """ + + def __init__(self, context): + """ + :param context: plugin context hook to enable adding widgets as a ROS_GUI pane, + ''PluginContext'' + """ + super(GameViewer, self).__init__(context) + self.setObjectName('GameViewer') + + self._context = context + + self._widget = GameViewerWidget() + if context.serial_number() > 1: + self._widget.setWindowTitle( + self._widget.windowTitle() + (' (%d)' % context.serial_number())) + context.add_widget(self._widget) + + self._timer = QTimer() + self._timer.timeout.connect(self._widget.update) + self._timer.start(16) # the argument is msec interval + + def shutdown_plugin(self): + self._timer.stop() + pass + + def save_settings(self, plugin_settings, instance_settings): + pass + + def restore_settings(self, plugin_settings, instance_settings): + pass + diff --git a/consai2r2_gameviewer/src/consai2r2_gameviewer/gameviewer_widget.py b/consai2r2_gameviewer/src/consai2r2_gameviewer/gameviewer_widget.py new file mode 100644 index 0000000..78ede74 --- /dev/null +++ b/consai2r2_gameviewer/src/consai2r2_gameviewer/gameviewer_widget.py @@ -0,0 +1,57 @@ +# Copyright (c) 2019 SSL-Roots +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +import os + +from ament_index_python.resources import get_resource + +from python_qt_binding import loadUi +from python_qt_binding.QtWidgets import QWidget +from python_qt_binding.QtGui import QPainter +from python_qt_binding.QtCore import Qt + +class GameViewerWidget(QWidget): + + """ + Primary widget for the consai2r2_gameviewer plugin. + """ + + def __init__(self): + super(GameViewerWidget, self).__init__() + + pkg_name = 'consai2r2_gameviewer' + _, package_path = get_resource('packages', pkg_name) + ui_file = os.path.join( + package_path, 'share', pkg_name, 'resource', 'gameviewer_widget.ui') + loadUi(ui_file, self) + + self.setObjectName('GameViewerWidget') + + + def paintEvent(self, event): + painter = QPainter(self) + + # Hello world + painter.setBrush(Qt.green) + painter.setPen(Qt.black) + painter.drawRect(self.rect()) + + painter.drawText(self.rect().width()*0.5, self.rect().height()*0.5, "Hello world!") + From 39bf0d094c00f34c1c170c8b893bb17effc5c623 Mon Sep 17 00:00:00 2001 From: Mirai Hattori Date: Wed, 1 Jan 2020 21:04:57 +0900 Subject: [PATCH 07/16] fix typo of fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 553b70a..cd823cf 100644 --- a/README.md +++ b/README.md @@ -103,7 +103,7 @@ GitHubのProjects機能で開発方針に合わせたタスク管理をしてい issue, pull request 大歓迎です。 -[CONTIRIBUTING.md](./CONTRIBUTING.md)を見てくれると嬉しいです。 +[CONTRIBUTING.md](./CONTRIBUTING.md)を見てくれると嬉しいです。 # Author & Contributors From 3cb6f7cfc930016e249b64fe7552b3b9812199ec Mon Sep 17 00:00:00 2001 From: Mirai Hattori Date: Wed, 1 Jan 2020 23:33:12 +0900 Subject: [PATCH 08/16] fix unnecessary parameter client --- consai2r2_sender/config/grsim.yaml | 2 +- consai2r2_sender/src/sim_sender.cpp | 19 +++---------------- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/consai2r2_sender/config/grsim.yaml b/consai2r2_sender/config/grsim.yaml index f99734a..551b227 100644 --- a/consai2r2_sender/config/grsim.yaml +++ b/consai2r2_sender/config/grsim.yaml @@ -1,4 +1,4 @@ -consai2r2_sender: +sim_sender: ros__parameters: grsim_addr: '127.0.0.1' grsim_port: 20011 diff --git a/consai2r2_sender/src/sim_sender.cpp b/consai2r2_sender/src/sim_sender.cpp index 3a67683..b2cb04a 100644 --- a/consai2r2_sender/src/sim_sender.cpp +++ b/consai2r2_sender/src/sim_sender.cpp @@ -62,25 +62,12 @@ class SimSender : public rclcpp::Node { public: SimSender() - : Node("consai2r2_sim_sender") + : Node("sim_sender_node") { - std::string host; - int port; - this->declare_parameter("grsim_addr", "127.0.0.1"); this->declare_parameter("grsim_port", 20011); - - auto parameters_client = std::make_shared(this); - while (!parameters_client->wait_for_service(1s)) { - if (!rclcpp::ok()) { - RCLCPP_ERROR(this->get_logger(), "Interrupted while waiting for the service. Exiting."); - rclcpp::shutdown(); - } - RCLCPP_INFO(this->get_logger(), "service not available, waiting again..."); - } - - parameters_client->get_parameter("grsim_addr", host); - parameters_client->get_parameter("grsim_port", port); + auto host = this->get_parameter("grsim_addr").as_string(); + auto port = this->get_parameter("grsim_port").as_int(); sub_commands_ = this->create_subscription( "robot_commands", 10, std::bind(&SimSender::send_commands, this, std::placeholders::_1)); From c275c6f6961a09b2bbb2a5c282e57476a9ee0968 Mon Sep 17 00:00:00 2001 From: Mirai Hattori Date: Wed, 1 Jan 2020 23:55:02 +0900 Subject: [PATCH 09/16] fix node name; add ament_index_python to package.xml --- consai2r2_examples/launch/joystick_example.launch.py | 6 +++++- consai2r2_examples/package.xml | 1 + consai2r2_sender/package.xml | 1 + consai2r2_sender/src/sim_sender.cpp | 2 +- 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/consai2r2_examples/launch/joystick_example.launch.py b/consai2r2_examples/launch/joystick_example.launch.py index e033011..396bdd1 100644 --- a/consai2r2_examples/launch/joystick_example.launch.py +++ b/consai2r2_examples/launch/joystick_example.launch.py @@ -18,6 +18,8 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. +import os +from ament_index_python.packages import get_package_share_directory from launch import LaunchDescription from launch.actions import DeclareLaunchArgument from launch.substitutions import LaunchConfiguration @@ -49,7 +51,9 @@ def generate_launch_description(): start_sender_cmd = Node( package='consai2r2_sender', node_executable='sim_sender', - output='screen' + output='screen', + parameters=[os.path.join(get_package_share_directory( + 'consai2r2_sender'), 'config', 'grsim.yaml')] ) ld = LaunchDescription() diff --git a/consai2r2_examples/package.xml b/consai2r2_examples/package.xml index 2f79e57..5af456e 100644 --- a/consai2r2_examples/package.xml +++ b/consai2r2_examples/package.xml @@ -9,6 +9,7 @@ ament_cmake launch_ros + ament_index_python joy ament_lint_auto ament_lint_common diff --git a/consai2r2_sender/package.xml b/consai2r2_sender/package.xml index 9e935f0..bb3a767 100644 --- a/consai2r2_sender/package.xml +++ b/consai2r2_sender/package.xml @@ -16,6 +16,7 @@ protobuf-dev boost + ament_index_python launch_ros ament_lint_auto ament_lint_common diff --git a/consai2r2_sender/src/sim_sender.cpp b/consai2r2_sender/src/sim_sender.cpp index b2cb04a..61e35f3 100644 --- a/consai2r2_sender/src/sim_sender.cpp +++ b/consai2r2_sender/src/sim_sender.cpp @@ -62,7 +62,7 @@ class SimSender : public rclcpp::Node { public: SimSender() - : Node("sim_sender_node") + : Node("sim_sender") { this->declare_parameter("grsim_addr", "127.0.0.1"); this->declare_parameter("grsim_port", 20011); From 85a47ee2cfc9aa754be12ae6b9af2c6b5b8f8dca Mon Sep 17 00:00:00 2001 From: Mirai Hattori Date: Thu, 2 Jan 2020 00:01:57 +0900 Subject: [PATCH 10/16] [consai2r2_sender] change node name sim_sender->consai2r2_sim_sender --- consai2r2_sender/config/grsim.yaml | 2 +- consai2r2_sender/src/sim_sender.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/consai2r2_sender/config/grsim.yaml b/consai2r2_sender/config/grsim.yaml index 551b227..0c57296 100644 --- a/consai2r2_sender/config/grsim.yaml +++ b/consai2r2_sender/config/grsim.yaml @@ -1,4 +1,4 @@ -sim_sender: +consai2r2_sim_sender: ros__parameters: grsim_addr: '127.0.0.1' grsim_port: 20011 diff --git a/consai2r2_sender/src/sim_sender.cpp b/consai2r2_sender/src/sim_sender.cpp index 61e35f3..61bb96f 100644 --- a/consai2r2_sender/src/sim_sender.cpp +++ b/consai2r2_sender/src/sim_sender.cpp @@ -62,7 +62,7 @@ class SimSender : public rclcpp::Node { public: SimSender() - : Node("sim_sender") + : Node("consai2r2_sim_sender") { this->declare_parameter("grsim_addr", "127.0.0.1"); this->declare_parameter("grsim_port", 20011); From df746c71d5148e9acc259c3589fa32da8748a92f Mon Sep 17 00:00:00 2001 From: Kentaro Tanaka Date: Thu, 2 Jan 2020 22:01:32 +0900 Subject: [PATCH 11/16] set timeout_sec as method parameter --- consai2r2_description/consai2r2_description/__init__.py | 6 +++--- consai2r2_description/consai2r2_description/parameter.py | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/consai2r2_description/consai2r2_description/__init__.py b/consai2r2_description/consai2r2_description/__init__.py index 5fdfdf3..4c15d64 100755 --- a/consai2r2_description/consai2r2_description/__init__.py +++ b/consai2r2_description/consai2r2_description/__init__.py @@ -23,8 +23,8 @@ class consai2r2_parameters(): - def __init__(self, node): - param_names = consai2r2_description.parameter.list_parameters(node) - params = consai2r2_description.parameter.get_parameters(node, param_names) + def __init__(self, node, timeout_sec=10.0): + param_names = consai2r2_description.parameter.list_parameters(node, timeout_sec) + params = consai2r2_description.parameter.get_parameters(node, param_names, timeout_sec) for param_name, param_value in params.items(): setattr(self, param_name, param_value) diff --git a/consai2r2_description/consai2r2_description/parameter.py b/consai2r2_description/consai2r2_description/parameter.py index fef2bfc..9ced844 100755 --- a/consai2r2_description/consai2r2_description/parameter.py +++ b/consai2r2_description/consai2r2_description/parameter.py @@ -20,14 +20,14 @@ # https://github.com/ros2/ros2cli/blob/master/ros2param/ros2param/api/__init__.py#L174 -def list_parameters(node): +def list_parameters(node, timeout_sec=10.0): # create client client = node.create_client( ListParameters, 'consai2r2_description/list_parameters') # call as soon as ready - ready = client.wait_for_service(timeout_sec=5.0) + ready = client.wait_for_service(timeout_sec) if not ready: raise RuntimeError('Wait for service timed out') @@ -44,14 +44,14 @@ def list_parameters(node): # https://github.com/ros2/ros2cli/blob/master/ros2param/ros2param/api/__init__.py#L54 -def get_parameters(node, parameter_names): +def get_parameters(node, parameter_names, timeout_sec=10.0): # create client client = node.create_client( GetParameters, 'consai2r2_description/get_parameters') # call as soon as ready - ready = client.wait_for_service(timeout_sec=5.0) + ready = client.wait_for_service(timeout_sec) if not ready: raise RuntimeError('Wait for service timed out') From 2644080f8a8764a6442e65ebe3f25e1e63ff46b5 Mon Sep 17 00:00:00 2001 From: Mirai Hattori Date: Fri, 3 Jan 2020 20:38:34 +0900 Subject: [PATCH 12/16] [README.md] consai2->consai2r2 && remove unnecessary -->, [consai2r2_sender/package.xml] remove python_cmake_module, [consai2r2_sender] remove using chrono literals --- consai2r2_sender/README.md | 4 ++-- consai2r2_sender/package.xml | 1 - consai2r2_sender/src/sim_sender.cpp | 1 - 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/consai2r2_sender/README.md b/consai2r2_sender/README.md index 6054eba..d83eabd 100644 --- a/consai2r2_sender/README.md +++ b/consai2r2_sender/README.md @@ -1,4 +1,4 @@ -# consai2_sender +# consai2r2_sender ロボット(grSim)へ動作司令を送信するパッケージです。 @@ -48,6 +48,6 @@ roslaunch consai2_sender sender.launch sim:=true --> ## 参考ページ -### Google proto files --> +### Google proto files - grSim - https://github.com/RoboCup-SSL/grSim/tree/master/src/proto diff --git a/consai2r2_sender/package.xml b/consai2r2_sender/package.xml index bb3a767..9ebd0d8 100644 --- a/consai2r2_sender/package.xml +++ b/consai2r2_sender/package.xml @@ -8,7 +8,6 @@ MIT ament_cmake - python_cmake_module rclcpp std_msgs diff --git a/consai2r2_sender/src/sim_sender.cpp b/consai2r2_sender/src/sim_sender.cpp index 61bb96f..3145d96 100644 --- a/consai2r2_sender/src/sim_sender.cpp +++ b/consai2r2_sender/src/sim_sender.cpp @@ -32,7 +32,6 @@ #include "grSim_Replacement.pb.h" using std::placeholders::_1; -using namespace std::chrono_literals; namespace asio = boost::asio; From d034ae94ede848064271ac173b2fcbe832a5f581 Mon Sep 17 00:00:00 2001 From: Kentaro Tanaka Date: Mon, 6 Jan 2020 19:03:50 +0900 Subject: [PATCH 13/16] delete unneeded lines --- consai2r2_description/CMakeLists.txt | 8 -------- 1 file changed, 8 deletions(-) diff --git a/consai2r2_description/CMakeLists.txt b/consai2r2_description/CMakeLists.txt index 36a78e1..ea4d9da 100644 --- a/consai2r2_description/CMakeLists.txt +++ b/consai2r2_description/CMakeLists.txt @@ -13,13 +13,6 @@ endif() # find dependencies find_package(ament_cmake REQUIRED) find_package(rclcpp REQUIRED) -find_package(python_cmake_module REQUIRED) - -set(_PYTHON_EXECUTABLE "${PYTHON_EXECUTABLE}") - -if(WIN32 AND CMAKE_BUILD_TYPE STREQUAL "Debug") - set(PYTHON_EXECUTABLE "${PYTHON_EXECUTABLE_DEBUG}") -endif() ament_python_install_package(${PROJECT_NAME}) @@ -30,7 +23,6 @@ add_executable(${PROJECT_NAME}_node ament_target_dependencies( ${PROJECT_NAME}_node "rclcpp" - "launch_ros" ) From afdfe483ab5d0a9c69009d0cb18422a786c4feec Mon Sep 17 00:00:00 2001 From: Kentaro Tanaka Date: Mon, 6 Jan 2020 19:03:58 +0900 Subject: [PATCH 14/16] fix comments --- consai2r2_description/consai2r2_description/parameter.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/consai2r2_description/consai2r2_description/parameter.py b/consai2r2_description/consai2r2_description/parameter.py index 9ced844..e074344 100755 --- a/consai2r2_description/consai2r2_description/parameter.py +++ b/consai2r2_description/consai2r2_description/parameter.py @@ -19,7 +19,7 @@ import rclpy -# https://github.com/ros2/ros2cli/blob/master/ros2param/ros2param/api/__init__.py#L174 +# https://github.com/ros2/ros2cli/blob/780923c046f8e537e884d18bef33a2338f2d409c/ros2param/ros2param/api/__init__.py#L174 def list_parameters(node, timeout_sec=10.0): # create client client = node.create_client( @@ -43,7 +43,7 @@ def list_parameters(node, timeout_sec=10.0): return response.result.names -# https://github.com/ros2/ros2cli/blob/master/ros2param/ros2param/api/__init__.py#L54 +# https://github.com/ros2/ros2cli/blob/780923c046f8e537e884d18bef33a2338f2d409c/ros2param/ros2param/api/__init__.py#L54 def get_parameters(node, parameter_names, timeout_sec=10.0): # create client client = node.create_client( From dbd3b5613cbce7d8fa41524f7642d94e7628d731 Mon Sep 17 00:00:00 2001 From: Kentaro Tanaka Date: Mon, 6 Jan 2020 19:10:23 +0900 Subject: [PATCH 15/16] add PYTHON_EXECUTABLE for colcon test --- consai2r2_description/CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/consai2r2_description/CMakeLists.txt b/consai2r2_description/CMakeLists.txt index ea4d9da..0e51968 100644 --- a/consai2r2_description/CMakeLists.txt +++ b/consai2r2_description/CMakeLists.txt @@ -14,6 +14,12 @@ endif() find_package(ament_cmake REQUIRED) find_package(rclcpp REQUIRED) +set(_PYTHON_EXECUTABLE "${PYTHON_EXECUTABLE}") + +if(WIN32 AND CMAKE_BUILD_TYPE STREQUAL "Debug") + set(PYTHON_EXECUTABLE "${PYTHON_EXECUTABLE_DEBUG}") +endif() + ament_python_install_package(${PROJECT_NAME}) include_directories(include ${CMAKE_CURRENT_BINARY_DIR}) From 9c178b72b15a96117a1c21d292f92eb3b7280406 Mon Sep 17 00:00:00 2001 From: Kentaro Tanaka Date: Mon, 6 Jan 2020 19:14:25 +0900 Subject: [PATCH 16/16] fix comment --- consai2r2_description/consai2r2_description/parameter.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/consai2r2_description/consai2r2_description/parameter.py b/consai2r2_description/consai2r2_description/parameter.py index e074344..4149d73 100755 --- a/consai2r2_description/consai2r2_description/parameter.py +++ b/consai2r2_description/consai2r2_description/parameter.py @@ -43,7 +43,7 @@ def list_parameters(node, timeout_sec=10.0): return response.result.names -# https://github.com/ros2/ros2cli/blob/780923c046f8e537e884d18bef33a2338f2d409c/ros2param/ros2param/api/__init__.py#L54 +# https://github.com/ros2/ros2cli/blob/780923c046f8e537e884d18bef33a2338f2d409c/ros2param/ros2param/api/__init__.py#L122 def get_parameters(node, parameter_names, timeout_sec=10.0): # create client client = node.create_client( @@ -68,6 +68,7 @@ def get_parameters(node, parameter_names, timeout_sec=10.0): return_values = {} + # https://github.com/ros2/ros2cli/blob/780923c046f8e537e884d18bef33a2338f2d409c/ros2param/ros2param/api/__init__.py#L54 for i, pvalue in enumerate(response.values): if pvalue.type == ParameterType.PARAMETER_BOOL: value = pvalue.bool_value