From 3bc6c67bba130a9d51d40309334b6af273a8a249 Mon Sep 17 00:00:00 2001 From: saho Date: Sun, 21 Jul 2024 11:54:24 +0900 Subject: [PATCH 01/13] create_node_pi_led --- device/pi_led/package.xml | 18 ++++++++++++ device/pi_led/pi_led/__init__.py | 0 device/pi_led/pi_led/pi_led.py | 41 ++++++++++++++++++++++++++++ device/pi_led/resource/pi_led | 0 device/pi_led/setup.cfg | 4 +++ device/pi_led/setup.py | 22 +++++++++++++++ device/pi_led/test/test_copyright.py | 25 +++++++++++++++++ device/pi_led/test/test_flake8.py | 25 +++++++++++++++++ device/pi_led/test/test_pep257.py | 23 ++++++++++++++++ device/rpi-bno055 | 2 +- 10 files changed, 159 insertions(+), 1 deletion(-) create mode 100644 device/pi_led/package.xml create mode 100644 device/pi_led/pi_led/__init__.py create mode 100644 device/pi_led/pi_led/pi_led.py create mode 100644 device/pi_led/resource/pi_led create mode 100644 device/pi_led/setup.cfg create mode 100644 device/pi_led/setup.py create mode 100644 device/pi_led/test/test_copyright.py create mode 100644 device/pi_led/test/test_flake8.py create mode 100644 device/pi_led/test/test_pep257.py diff --git a/device/pi_led/package.xml b/device/pi_led/package.xml new file mode 100644 index 0000000..9e84d4b --- /dev/null +++ b/device/pi_led/package.xml @@ -0,0 +1,18 @@ + + + + pi_led + 0.0.0 + LEDを光らせる + saho + MIT + + rclpy + packet_interfaces + python3-gpiozero + + + + ament_python + + diff --git a/device/pi_led/pi_led/__init__.py b/device/pi_led/pi_led/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/device/pi_led/pi_led/pi_led.py b/device/pi_led/pi_led/pi_led.py new file mode 100644 index 0000000..b3d1c82 --- /dev/null +++ b/device/pi_led/pi_led/pi_led.py @@ -0,0 +1,41 @@ +import rclpy +from gpiozero import LED +from packet_interfaces.msg import LedColor +from rclpy.node import Node + + +class Led(Node): + def __init__(self): + super().__init__("led") + self._led_subscription = self.create_subscription( + LedColor, "led_color", self.led_callback, 10 + ) + self.led_r = LED(17) # parameter? + self.led_g = LED(27) + self.led_b = LED(22) + + def led_callback(self, light: LedColor): + self.led_light(self.led_r, light.red) + self.led_light(self.led_g, light.green) + self.led_light(self.led_b, light.blue) + self.get_logger().info( + 'R is "%d",G is "%d",B is "%d"' % (self.led_R, self.led_G, self.led_B) + ) + + def led_light(led, light): + if light: + led.on() + else: + led.off() + + +def main(args=None): + rclpy.init(args=args) + led_subscriber = Led() + rclpy.spin(led_subscriber) + led_subscriber.destroy_node() + rclpy.shutdown() + + +if __name__ == "__main__": + main() diff --git a/device/pi_led/resource/pi_led b/device/pi_led/resource/pi_led new file mode 100644 index 0000000..e69de29 diff --git a/device/pi_led/setup.cfg b/device/pi_led/setup.cfg new file mode 100644 index 0000000..288e58c --- /dev/null +++ b/device/pi_led/setup.cfg @@ -0,0 +1,4 @@ +[develop] +script_dir=$base/lib/pi_led +[install] +install_scripts=$base/lib/pi_led diff --git a/device/pi_led/setup.py b/device/pi_led/setup.py new file mode 100644 index 0000000..0a5ce75 --- /dev/null +++ b/device/pi_led/setup.py @@ -0,0 +1,22 @@ +from setuptools import find_packages, setup + +package_name = "pi_led" + +setup( + name=package_name, + version="0.0.0", + packages=find_packages(exclude=["test"]), + data_files=[ + ("share/ament_index/resource_index/packages", ["resource/" + package_name]), + ("share/" + package_name, ["package.xml"]), + ], + install_requires=["setuptools"], + zip_safe=True, + maintainer="saho", + maintainer_email="sahonorth@gmail.com", + description="LEDを光らせる", + license="MIT", + entry_points={ + "console_scripts": [], + }, +) diff --git a/device/pi_led/test/test_copyright.py b/device/pi_led/test/test_copyright.py new file mode 100644 index 0000000..97a3919 --- /dev/null +++ b/device/pi_led/test/test_copyright.py @@ -0,0 +1,25 @@ +# Copyright 2015 Open Source Robotics Foundation, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from ament_copyright.main import main +import pytest + + +# Remove the `skip` decorator once the source file(s) have a copyright header +@pytest.mark.skip(reason='No copyright header has been placed in the generated source file.') +@pytest.mark.copyright +@pytest.mark.linter +def test_copyright(): + rc = main(argv=['.', 'test']) + assert rc == 0, 'Found errors' diff --git a/device/pi_led/test/test_flake8.py b/device/pi_led/test/test_flake8.py new file mode 100644 index 0000000..27ee107 --- /dev/null +++ b/device/pi_led/test/test_flake8.py @@ -0,0 +1,25 @@ +# Copyright 2017 Open Source Robotics Foundation, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from ament_flake8.main import main_with_errors +import pytest + + +@pytest.mark.flake8 +@pytest.mark.linter +def test_flake8(): + rc, errors = main_with_errors(argv=[]) + assert rc == 0, \ + 'Found %d code style errors / warnings:\n' % len(errors) + \ + '\n'.join(errors) diff --git a/device/pi_led/test/test_pep257.py b/device/pi_led/test/test_pep257.py new file mode 100644 index 0000000..b234a38 --- /dev/null +++ b/device/pi_led/test/test_pep257.py @@ -0,0 +1,23 @@ +# Copyright 2015 Open Source Robotics Foundation, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from ament_pep257.main import main +import pytest + + +@pytest.mark.linter +@pytest.mark.pep257 +def test_pep257(): + rc = main(argv=['.', 'test']) + assert rc == 0, 'Found code style errors / warnings' diff --git a/device/rpi-bno055 b/device/rpi-bno055 index 3109919..c6516b1 160000 --- a/device/rpi-bno055 +++ b/device/rpi-bno055 @@ -1 +1 @@ -Subproject commit 310991948c40350f8e27ff96ac55d34889c9392f +Subproject commit c6516b1920a9d31582977eb1c31f03e68bcf6a5e From 6cf957926524ebaf58c4bffc712d734d1dc8869c Mon Sep 17 00:00:00 2001 From: saho Date: Mon, 22 Jul 2024 13:05:00 +0900 Subject: [PATCH 02/13] gpio, self, rgb, test --- device/pi_led/pi_led/pi_led.py | 10 +++++----- device/pi_led/test/test_copyright.py | 25 ------------------------- device/pi_led/test/test_flake8.py | 25 ------------------------- device/pi_led/test/test_pep257.py | 23 ----------------------- 4 files changed, 5 insertions(+), 78 deletions(-) delete mode 100644 device/pi_led/test/test_copyright.py delete mode 100644 device/pi_led/test/test_flake8.py delete mode 100644 device/pi_led/test/test_pep257.py diff --git a/device/pi_led/pi_led/pi_led.py b/device/pi_led/pi_led/pi_led.py index b3d1c82..9a6a5d0 100644 --- a/device/pi_led/pi_led/pi_led.py +++ b/device/pi_led/pi_led/pi_led.py @@ -10,19 +10,19 @@ def __init__(self): self._led_subscription = self.create_subscription( LedColor, "led_color", self.led_callback, 10 ) - self.led_r = LED(17) # parameter? - self.led_g = LED(27) - self.led_b = LED(22) + self.led_r = LED("GPIO17") + self.led_g = LED("GPIO27") + self.led_b = LED("GPIO22") def led_callback(self, light: LedColor): self.led_light(self.led_r, light.red) self.led_light(self.led_g, light.green) self.led_light(self.led_b, light.blue) self.get_logger().info( - 'R is "%d",G is "%d",B is "%d"' % (self.led_R, self.led_G, self.led_B) + 'R is "%d",G is "%d",B is "%d"' % (self.led_r, self.led_g, self.led_b) ) - def led_light(led, light): + def led_light(self, led, light): if light: led.on() else: diff --git a/device/pi_led/test/test_copyright.py b/device/pi_led/test/test_copyright.py deleted file mode 100644 index 97a3919..0000000 --- a/device/pi_led/test/test_copyright.py +++ /dev/null @@ -1,25 +0,0 @@ -# Copyright 2015 Open Source Robotics Foundation, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from ament_copyright.main import main -import pytest - - -# Remove the `skip` decorator once the source file(s) have a copyright header -@pytest.mark.skip(reason='No copyright header has been placed in the generated source file.') -@pytest.mark.copyright -@pytest.mark.linter -def test_copyright(): - rc = main(argv=['.', 'test']) - assert rc == 0, 'Found errors' diff --git a/device/pi_led/test/test_flake8.py b/device/pi_led/test/test_flake8.py deleted file mode 100644 index 27ee107..0000000 --- a/device/pi_led/test/test_flake8.py +++ /dev/null @@ -1,25 +0,0 @@ -# Copyright 2017 Open Source Robotics Foundation, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from ament_flake8.main import main_with_errors -import pytest - - -@pytest.mark.flake8 -@pytest.mark.linter -def test_flake8(): - rc, errors = main_with_errors(argv=[]) - assert rc == 0, \ - 'Found %d code style errors / warnings:\n' % len(errors) + \ - '\n'.join(errors) diff --git a/device/pi_led/test/test_pep257.py b/device/pi_led/test/test_pep257.py deleted file mode 100644 index b234a38..0000000 --- a/device/pi_led/test/test_pep257.py +++ /dev/null @@ -1,23 +0,0 @@ -# Copyright 2015 Open Source Robotics Foundation, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from ament_pep257.main import main -import pytest - - -@pytest.mark.linter -@pytest.mark.pep257 -def test_pep257(): - rc = main(argv=['.', 'test']) - assert rc == 0, 'Found code style errors / warnings' From 4dadbbcc8bf37f22d4cd48246f86a647e7987b95 Mon Sep 17 00:00:00 2001 From: H1rono Date: Tue, 23 Jul 2024 14:53:38 +0900 Subject: [PATCH 03/13] Fix submodule --- device/rpi-bno055 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/device/rpi-bno055 b/device/rpi-bno055 index c6516b1..3109919 160000 --- a/device/rpi-bno055 +++ b/device/rpi-bno055 @@ -1 +1 @@ -Subproject commit c6516b1920a9d31582977eb1c31f03e68bcf6a5e +Subproject commit 310991948c40350f8e27ff96ac55d34889c9392f From c82b48f56445bb22e84bbe4edb81412adbf0358a Mon Sep 17 00:00:00 2001 From: 23-saho <136442436+23-saho@users.noreply.github.com> Date: Fri, 26 Jul 2024 15:37:55 +0900 Subject: [PATCH 04/13] delete % Co-authored-by: H1rono_K <54711422+H1rono@users.noreply.github.com> --- device/pi_led/pi_led/pi_led.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/device/pi_led/pi_led/pi_led.py b/device/pi_led/pi_led/pi_led.py index 9a6a5d0..08a0800 100644 --- a/device/pi_led/pi_led/pi_led.py +++ b/device/pi_led/pi_led/pi_led.py @@ -19,7 +19,7 @@ def led_callback(self, light: LedColor): self.led_light(self.led_g, light.green) self.led_light(self.led_b, light.blue) self.get_logger().info( - 'R is "%d",G is "%d",B is "%d"' % (self.led_r, self.led_g, self.led_b) + f'R is "{int(light.red)}",G is "{int(light.green)}",B is "{int(light.blue)}"' ) def led_light(self, led, light): From 98103d083477f6e0c24126c69d5bc1b86b512c1e Mon Sep 17 00:00:00 2001 From: saho Date: Fri, 26 Jul 2024 15:44:02 +0900 Subject: [PATCH 05/13] entry_points --- device/pi_led/setup.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/device/pi_led/setup.py b/device/pi_led/setup.py index 0a5ce75..712e89f 100644 --- a/device/pi_led/setup.py +++ b/device/pi_led/setup.py @@ -17,6 +17,8 @@ description="LEDを光らせる", license="MIT", entry_points={ - "console_scripts": [], + "console_scripts": [ + "pi_led = pi_led.py_led:main", + ], }, ) From e618b2027a4f28338342be7a80167654df22f74b Mon Sep 17 00:00:00 2001 From: saho Date: Fri, 26 Jul 2024 17:35:05 +0900 Subject: [PATCH 06/13] param_led.py --- device/pi_led/pi_led/pi_led.py | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/device/pi_led/pi_led/pi_led.py b/device/pi_led/pi_led/pi_led.py index 08a0800..6643eae 100644 --- a/device/pi_led/pi_led/pi_led.py +++ b/device/pi_led/pi_led/pi_led.py @@ -10,9 +10,29 @@ def __init__(self): self._led_subscription = self.create_subscription( LedColor, "led_color", self.led_callback, 10 ) - self.led_r = LED("GPIO17") - self.led_g = LED("GPIO27") - self.led_b = LED("GPIO22") + param_r = self.declare_parameter("led_pin_r", "") + param_g = self.declare_parameter("led_pin_g", "") + param_b = self.declare_parameter("led_pin_b", "") + + pin_r = ( + self.get_parameter_or(param_r.name, param_r) + .get_parameter_value() + .integer_string + ) + pin_g = ( + self.get_parameter_or(param_g.name, param_g) + .get_parameter_value() + .integer_string + ) + pin_b = ( + self.get_parameter_or(param_b.name, param_b) + .get_parameter_value() + .integer_string + ) + + self.led_r = LED(pin_r) + self.led_g = LED(pin_g) + self.led_b = LED(pin_b) def led_callback(self, light: LedColor): self.led_light(self.led_r, light.red) From a756372b674910ab92a883eeacbd8ffde7cf8a9e Mon Sep 17 00:00:00 2001 From: saho Date: Fri, 26 Jul 2024 17:44:10 +0900 Subject: [PATCH 07/13] fix_pi.led --- device/pi_led/pi_led/pi_led.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/device/pi_led/pi_led/pi_led.py b/device/pi_led/pi_led/pi_led.py index 6643eae..1eec4ca 100644 --- a/device/pi_led/pi_led/pi_led.py +++ b/device/pi_led/pi_led/pi_led.py @@ -17,17 +17,17 @@ def __init__(self): pin_r = ( self.get_parameter_or(param_r.name, param_r) .get_parameter_value() - .integer_string + .string_value ) pin_g = ( self.get_parameter_or(param_g.name, param_g) .get_parameter_value() - .integer_string + .string_value ) pin_b = ( self.get_parameter_or(param_b.name, param_b) .get_parameter_value() - .integer_string + .string_value ) self.led_r = LED(pin_r) From 7d582b6ea1c825817d023378ed37ad32c8c0fa41 Mon Sep 17 00:00:00 2001 From: saho Date: Fri, 26 Jul 2024 18:28:30 +0900 Subject: [PATCH 08/13] fix --- device/pi_led/pi_led/pi_led.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/device/pi_led/pi_led/pi_led.py b/device/pi_led/pi_led/pi_led.py index 1eec4ca..a81282b 100644 --- a/device/pi_led/pi_led/pi_led.py +++ b/device/pi_led/pi_led/pi_led.py @@ -14,25 +14,25 @@ def __init__(self): param_g = self.declare_parameter("led_pin_g", "") param_b = self.declare_parameter("led_pin_b", "") - pin_r = ( + led_pin_r = ( self.get_parameter_or(param_r.name, param_r) .get_parameter_value() .string_value ) - pin_g = ( + led_pin_g = ( self.get_parameter_or(param_g.name, param_g) .get_parameter_value() .string_value ) - pin_b = ( + led_pin_b = ( self.get_parameter_or(param_b.name, param_b) .get_parameter_value() .string_value ) - self.led_r = LED(pin_r) - self.led_g = LED(pin_g) - self.led_b = LED(pin_b) + self.led_r = LED(led_pin_r) + self.led_g = LED(led_pin_g) + self.led_b = LED(led_pin_b) def led_callback(self, light: LedColor): self.led_light(self.led_r, light.red) From f7821b19fdd392eef880ba7dbf80d260f601c076 Mon Sep 17 00:00:00 2001 From: 23-saho Date: Fri, 26 Jul 2024 20:17:37 +0900 Subject: [PATCH 09/13] change_user name --- device/pi_led/package.xml | 2 +- device/pi_led/setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/device/pi_led/package.xml b/device/pi_led/package.xml index 9e84d4b..e34774b 100644 --- a/device/pi_led/package.xml +++ b/device/pi_led/package.xml @@ -4,7 +4,7 @@ pi_led 0.0.0 LEDを光らせる - saho + 23-saho MIT rclpy diff --git a/device/pi_led/setup.py b/device/pi_led/setup.py index 712e89f..8088438 100644 --- a/device/pi_led/setup.py +++ b/device/pi_led/setup.py @@ -12,7 +12,7 @@ ], install_requires=["setuptools"], zip_safe=True, - maintainer="saho", + maintainer="23-saho", maintainer_email="sahonorth@gmail.com", description="LEDを光らせる", license="MIT", From 1693bd64a4aabfd126e96f08d4a5beada63f91f6 Mon Sep 17 00:00:00 2001 From: 23-saho Date: Sat, 27 Jul 2024 11:11:22 +0900 Subject: [PATCH 10/13] launch file --- device/pi_led/launch/led_launch.py | 12 ++++++++++++ device/pi_led/pi_led/pi_led.py | 6 +++--- device/pi_led/setup.py | 7 +++++++ 3 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 device/pi_led/launch/led_launch.py diff --git a/device/pi_led/launch/led_launch.py b/device/pi_led/launch/led_launch.py new file mode 100644 index 0000000..da96464 --- /dev/null +++ b/device/pi_led/launch/led_launch.py @@ -0,0 +1,12 @@ +from launch import LaunchDescription +from launch_ros.actions import Node + + +def generate_launch_description() -> LaunchDescription: + led = Node( + package="pi_led", + excutable="pi_led", + namespace="device", + parameters=[], + ) + return LaunchDescription([led]) diff --git a/device/pi_led/pi_led/pi_led.py b/device/pi_led/pi_led/pi_led.py index a81282b..b30acbe 100644 --- a/device/pi_led/pi_led/pi_led.py +++ b/device/pi_led/pi_led/pi_led.py @@ -10,9 +10,9 @@ def __init__(self): self._led_subscription = self.create_subscription( LedColor, "led_color", self.led_callback, 10 ) - param_r = self.declare_parameter("led_pin_r", "") - param_g = self.declare_parameter("led_pin_g", "") - param_b = self.declare_parameter("led_pin_b", "") + param_r = self.declare_parameter("led_pin_r", "GPIO 17") + param_g = self.declare_parameter("led_pin_g", "GPIO 27") + param_b = self.declare_parameter("led_pin_b", "GPIO 22") led_pin_r = ( self.get_parameter_or(param_r.name, param_r) diff --git a/device/pi_led/setup.py b/device/pi_led/setup.py index 8088438..975661a 100644 --- a/device/pi_led/setup.py +++ b/device/pi_led/setup.py @@ -1,3 +1,6 @@ +import os +from glob import glob + from setuptools import find_packages, setup package_name = "pi_led" @@ -9,6 +12,10 @@ data_files=[ ("share/ament_index/resource_index/packages", ["resource/" + package_name]), ("share/" + package_name, ["package.xml"]), + ( + os.path.join("share", package_name, "launch"), + glob(os.path.join("launch", "*")), + ), ], install_requires=["setuptools"], zip_safe=True, From a0c4128b559eec8cc9e434acdf9e0b6352c2e840 Mon Sep 17 00:00:00 2001 From: 23-saho Date: Sun, 28 Jul 2024 00:37:34 +0900 Subject: [PATCH 11/13] parameter --- device/pi_led/config/default_param.yml | 6 ++++++ device/pi_led/launch/led_launch.py | 10 +++++++++- device/pi_led/setup.py | 4 ++++ 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 device/pi_led/config/default_param.yml diff --git a/device/pi_led/config/default_param.yml b/device/pi_led/config/default_param.yml new file mode 100644 index 0000000..4137262 --- /dev/null +++ b/device/pi_led/config/default_param.yml @@ -0,0 +1,6 @@ +/**: + ros__parameters: + #right + led_pin_r: "GPIO17" + led_pin_g: "GPIO27" + led_pin_b: "GPIO22" \ No newline at end of file diff --git a/device/pi_led/launch/led_launch.py b/device/pi_led/launch/led_launch.py index da96464..3c802e5 100644 --- a/device/pi_led/launch/led_launch.py +++ b/device/pi_led/launch/led_launch.py @@ -1,12 +1,20 @@ +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() -> LaunchDescription: + config = os.path.join( + get_package_share_directory("pi_led"), + "config", + "default_param.yml", + ) led = Node( package="pi_led", excutable="pi_led", namespace="device", - parameters=[], + parameters=[config], ) return LaunchDescription([led]) diff --git a/device/pi_led/setup.py b/device/pi_led/setup.py index 975661a..07ddc4e 100644 --- a/device/pi_led/setup.py +++ b/device/pi_led/setup.py @@ -16,6 +16,10 @@ os.path.join("share", package_name, "launch"), glob(os.path.join("launch", "*")), ), + ( + os.path.join("share", package_name, "config"), + glob(os.path.join("config", "*")), + ), ], install_requires=["setuptools"], zip_safe=True, From db4eb6f455a793aedcc94c26ac93217170816d90 Mon Sep 17 00:00:00 2001 From: 23-saho <136442436+23-saho@users.noreply.github.com> Date: Sun, 28 Jul 2024 00:40:07 +0900 Subject: [PATCH 12/13] delete space Co-authored-by: H1rono_K <54711422+H1rono@users.noreply.github.com> --- device/pi_led/pi_led/pi_led.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/device/pi_led/pi_led/pi_led.py b/device/pi_led/pi_led/pi_led.py index b30acbe..e5acedd 100644 --- a/device/pi_led/pi_led/pi_led.py +++ b/device/pi_led/pi_led/pi_led.py @@ -10,9 +10,9 @@ def __init__(self): self._led_subscription = self.create_subscription( LedColor, "led_color", self.led_callback, 10 ) - param_r = self.declare_parameter("led_pin_r", "GPIO 17") - param_g = self.declare_parameter("led_pin_g", "GPIO 27") - param_b = self.declare_parameter("led_pin_b", "GPIO 22") + param_r = self.declare_parameter("led_pin_r", "GPIO17") + param_g = self.declare_parameter("led_pin_g", "GPIO27") + param_b = self.declare_parameter("led_pin_b", "GPIO22") led_pin_r = ( self.get_parameter_or(param_r.name, param_r) From ececcf9474414ab5de5d0593a7f8ddcf4e92e405 Mon Sep 17 00:00:00 2001 From: 23-saho Date: Sun, 28 Jul 2024 01:09:39 +0900 Subject: [PATCH 13/13] parameter_left --- device/pi_led/config/left_param.yml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 device/pi_led/config/left_param.yml diff --git a/device/pi_led/config/left_param.yml b/device/pi_led/config/left_param.yml new file mode 100644 index 0000000..708e75f --- /dev/null +++ b/device/pi_led/config/left_param.yml @@ -0,0 +1,5 @@ +/**: + ros__parameters: + led_pin_r: "GPIO10" + led_pin_g: "GPIO9" + led_pin_b: "GPIO11" \ No newline at end of file