Skip to content
This repository was archived by the owner on Jan 28, 2023. It is now read-only.

Commit 6056775

Browse files
committed
Merge branch 'master' into dev/protobuf-package
2 parents 5fe0d68 + fb1edeb commit 6056775

22 files changed

Lines changed: 467 additions & 13 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,11 @@ GitHubのProjects機能で開発方針に合わせたタスク管理をしてい
9999
- [2nd step - SSL Game Example](https://github.com/SSL-Roots/consai2r2/projects/3)
100100
- [3rd step - use ROS2 effectively](https://github.com/SSL-Roots/consai2r2/projects/2)
101101

102-
# Controbution
102+
# Contribution
103103

104104
issue, pull request 大歓迎です。
105105

106-
[CONTORIBUTING.md](./CONTRIBUTING.md)を見てくれると嬉しいです。
106+
[CONTRIBUTING.md](./CONTRIBUTING.md)を見てくれると嬉しいです。
107107

108108
# Author & Contributors
109109

consai2r2_description/CMakeLists.txt

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,21 @@ endif()
1414
find_package(ament_cmake REQUIRED)
1515
find_package(rclcpp REQUIRED)
1616

17+
set(_PYTHON_EXECUTABLE "${PYTHON_EXECUTABLE}")
18+
19+
if(WIN32 AND CMAKE_BUILD_TYPE STREQUAL "Debug")
20+
set(PYTHON_EXECUTABLE "${PYTHON_EXECUTABLE_DEBUG}")
21+
endif()
22+
23+
ament_python_install_package(${PROJECT_NAME})
24+
1725
include_directories(include ${CMAKE_CURRENT_BINARY_DIR})
1826
add_executable(${PROJECT_NAME}_node
1927
src/${PROJECT_NAME}_node.cpp
2028
)
2129
ament_target_dependencies(
2230
${PROJECT_NAME}_node
2331
"rclcpp"
24-
"launch_ros"
2532
)
2633

2734

@@ -39,8 +46,6 @@ install(DIRECTORY
3946
DESTINATION share/${PROJECT_NAME}/
4047
)
4148

42-
43-
4449
if(BUILD_TESTING)
4550
find_package(ament_lint_auto REQUIRED)
4651
# the following line skips the linter which checks for copyrights
@@ -52,4 +57,6 @@ if(BUILD_TESTING)
5257
ament_lint_auto_find_test_dependencies()
5358
endif()
5459

60+
set(PYTHON_EXECUTABLE "${_PYTHON_EXECUTABLE}")
61+
5562
ament_package()
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Copyright (c) 2019 SSL-Roots
2+
#
3+
# Permission is hereby granted, free of charge, to any person obtaining a copy
4+
# of this software and associated documentation files (the "Software"), to deal
5+
# in the Software without restriction, including without limitation the rights
6+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
# copies of the Software, and to permit persons to whom the Software is
8+
# furnished to do so, subject to the following conditions:
9+
#
10+
# The above copyright notice and this permission notice shall be included in
11+
# all copies or substantial portions of the Software.
12+
#
13+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16+
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
# THE SOFTWARE.
20+
21+
import consai2r2_description.parameter
22+
23+
24+
class consai2r2_parameters():
25+
26+
def __init__(self, node, timeout_sec=10.0):
27+
param_names = consai2r2_description.parameter.list_parameters(node, timeout_sec)
28+
params = consai2r2_description.parameter.get_parameters(node, param_names, timeout_sec)
29+
for param_name, param_value in params.items():
30+
setattr(self, param_name, param_value)
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# Copyright 2018 Open Source Robotics Foundation, Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
from rcl_interfaces.msg import ParameterType
16+
from rcl_interfaces.srv import GetParameters
17+
from rcl_interfaces.srv import ListParameters
18+
19+
import rclpy
20+
21+
22+
# https://github.com/ros2/ros2cli/blob/780923c046f8e537e884d18bef33a2338f2d409c/ros2param/ros2param/api/__init__.py#L174
23+
def list_parameters(node, timeout_sec=10.0):
24+
# create client
25+
client = node.create_client(
26+
ListParameters,
27+
'consai2r2_description/list_parameters')
28+
29+
# call as soon as ready
30+
ready = client.wait_for_service(timeout_sec)
31+
if not ready:
32+
raise RuntimeError('Wait for service timed out')
33+
34+
request = ListParameters.Request()
35+
future = client.call_async(request)
36+
rclpy.spin_until_future_complete(node, future)
37+
38+
# handle response
39+
response = future.result()
40+
if response is None:
41+
raise RuntimeError("Failed to get the list of parameters'")
42+
43+
return response.result.names
44+
45+
46+
# https://github.com/ros2/ros2cli/blob/780923c046f8e537e884d18bef33a2338f2d409c/ros2param/ros2param/api/__init__.py#L122
47+
def get_parameters(node, parameter_names, timeout_sec=10.0):
48+
# create client
49+
client = node.create_client(
50+
GetParameters,
51+
'consai2r2_description/get_parameters')
52+
53+
# call as soon as ready
54+
ready = client.wait_for_service(timeout_sec)
55+
if not ready:
56+
raise RuntimeError('Wait for service timed out')
57+
58+
request = GetParameters.Request()
59+
request.names = parameter_names
60+
future = client.call_async(request)
61+
rclpy.spin_until_future_complete(node, future)
62+
63+
# handle response
64+
response = future.result()
65+
if response is None:
66+
e = future.exception()
67+
raise RuntimeError("Failed to get parameters form node 'consai2r2_description'")
68+
69+
return_values = {}
70+
71+
# https://github.com/ros2/ros2cli/blob/780923c046f8e537e884d18bef33a2338f2d409c/ros2param/ros2param/api/__init__.py#L54
72+
for i, pvalue in enumerate(response.values):
73+
if pvalue.type == ParameterType.PARAMETER_BOOL:
74+
value = pvalue.bool_value
75+
elif pvalue.type == ParameterType.PARAMETER_INTEGER:
76+
value = pvalue.integer_value
77+
elif pvalue.type == ParameterType.PARAMETER_DOUBLE:
78+
value = pvalue.double_value
79+
elif pvalue.type == ParameterType.PARAMETER_STRING:
80+
value = pvalue.string_value
81+
elif pvalue.type == ParameterType.PARAMETER_BYTE_ARRAY:
82+
value = pvalue.byte_array_value
83+
elif pvalue.type == ParameterType.PARAMETER_BOOL_ARRAY:
84+
value = pvalue.bool_array_value
85+
elif pvalue.type == ParameterType.PARAMETER_INTEGER_ARRAY:
86+
value = pvalue.integer_array_value
87+
elif pvalue.type == ParameterType.PARAMETER_DOUBLE_ARRAY:
88+
value = pvalue.double_array_value
89+
elif pvalue.type == ParameterType.PARAMETER_STRING_ARRAY:
90+
value = pvalue.string_array_value
91+
elif pvalue.type == ParameterType.PARAMETER_NOT_SET:
92+
value = None
93+
else:
94+
raise RuntimeError("Unknown parameter type '{pvalue.type}'".format_map(locals()))
95+
return_values[parameter_names[i]] = value
96+
97+
return return_values

consai2r2_description/launch/config.launch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020

2121
import os
2222

23+
from ament_index_python.packages import get_package_share_directory
2324
from launch import LaunchDescription
2425
from launch_ros.actions import Node
25-
from ament_index_python.packages import get_package_share_directory
2626

2727

2828
def generate_launch_description():

consai2r2_description/package.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<license>MIT</license>
99

1010
<buildtool_depend>ament_cmake</buildtool_depend>
11+
<buildtool_depend>python_cmake_module</buildtool_depend>
1112

1213
<depend>rclcpp</depend>
1314
<depend>launch_ros</depend>

consai2r2_examples/launch/joystick_example.launch.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1919
# THE SOFTWARE.
2020

21+
import os
22+
from ament_index_python.packages import get_package_share_directory
2123
from launch import LaunchDescription
2224
from launch.actions import DeclareLaunchArgument
2325
from launch.substitutions import LaunchConfiguration
@@ -49,7 +51,9 @@ def generate_launch_description():
4951

5052
start_sender_cmd = Node(
5153
package='consai2r2_sender', node_executable='sim_sender',
52-
output='screen'
54+
output='screen',
55+
parameters=[os.path.join(get_package_share_directory(
56+
'consai2r2_sender'), 'config', 'grsim.yaml')]
5357
)
5458

5559
ld = LaunchDescription()

consai2r2_examples/package.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
<buildtool_depend>ament_cmake</buildtool_depend>
1111
<exec_depend>launch_ros</exec_depend>
12+
<exec_depend>ament_index_python</exec_depend>
1213
<exec_depend>joy</exec_depend>
1314
<test_depend>ament_lint_auto</test_depend>
1415
<test_depend>ament_lint_common</test_depend>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
cmake_minimum_required(VERSION 3.5)
2+
project(consai2r2_gameviewer)
3+
4+
# Load ament and all dependencies required for this package
5+
find_package(ament_cmake REQUIRED)
6+
find_package(ament_cmake_python REQUIRED)
7+
8+
ament_python_install_package(${PROJECT_NAME}
9+
PACKAGE_DIR src/${PROJECT_NAME})
10+
11+
install(FILES plugin.xml
12+
DESTINATION share/${PROJECT_NAME}
13+
)
14+
15+
install(DIRECTORY resource
16+
DESTINATION share/${PROJECT_NAME}
17+
)
18+
19+
install(PROGRAMS scripts/consai2r2_gameviewer
20+
DESTINATION lib/${PROJECT_NAME}
21+
)
22+
23+
ament_package()

consai2r2_gameviewer/package.xml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0"?>
2+
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
3+
<package format="3">
4+
<name>consai2r2_gameviewer</name>
5+
<version>0.0.0</version>
6+
<description>consai2r2_gameviewer provides a GUI plugin for displaying vision and referee messages.</description>
7+
<maintainer email="macakasit@gmail.com">akshota</maintainer>
8+
<license>MIT</license>
9+
10+
<buildtool_depend>ament_cmake</buildtool_depend>
11+
12+
<exec_depend>ament_index_python</exec_depend>
13+
<exec_depend version_gte="0.2.19">python_qt_binding</exec_depend>
14+
<exec_depend>rclpy</exec_depend>
15+
<exec_depend>rqt_gui</exec_depend>
16+
<exec_depend>rqt_gui_py</exec_depend>
17+
<exec_depend>rqt_py_common</exec_depend>
18+
19+
<export>
20+
<!-- <architecture_independent/> -->
21+
<rqt_gui plugin="${prefix}/plugin.xml"/>
22+
<build_type>ament_cmake</build_type>
23+
</export>
24+
</package>

0 commit comments

Comments
 (0)