From 2316a6f874d8d2c8d26fabb6ba4923471d44c72c Mon Sep 17 00:00:00 2001 From: Kah Hooi Tan <41041286+tkhmy@users.noreply.github.com> Date: Fri, 29 Mar 2024 09:51:59 +0900 Subject: [PATCH] update service for trigger external signage (#97) * update service for trigger external signage Signed-off-by: tkhmy * fix new external node (#98) * fix launch and depend --------- Signed-off-by: tkhmy Co-authored-by: yabuta --- .../launch/external_signage.launch.xml | 4 ++ src/external_signage/package.xml | 26 ++++++++++ .../resource/external_signage | 0 .../resource/td5_file/automatic_128x16.td5 | Bin 0 -> 2048 bytes .../resource/td5_file/automatic_80x24.td5 | Bin 0 -> 2560 bytes .../resource/td5_file/automonus.td5 | Bin 0 -> 2048 bytes .../resource/td5_file/null_128x16.td5 | Bin 0 -> 2560 bytes .../resource/td5_file/null_80x24.td5 | Bin 0 -> 2560 bytes src/external_signage/setup.cfg | 4 ++ src/external_signage/setup.py | 47 ++++++++++++++++++ .../src/external_signage/__init__.py | 4 ++ .../src/external_signage/external_signage.py | 23 +++++++++ .../external_signage_core.py} | 28 +++++------ .../src/external_signage}/packet_tools.py | 0 src/signage/launch/signage.launch.xml | 1 + src/signage/package.xml | 2 + .../src/signage/ros_service_interface.py | 9 +++- src/signage/src/signage/route_handler.py | 8 ++- src/signage/src/signage/signage.py | 3 -- 19 files changed, 136 insertions(+), 23 deletions(-) create mode 100755 src/external_signage/launch/external_signage.launch.xml create mode 100644 src/external_signage/package.xml create mode 100644 src/external_signage/resource/external_signage create mode 100644 src/external_signage/resource/td5_file/automatic_128x16.td5 create mode 100644 src/external_signage/resource/td5_file/automatic_80x24.td5 create mode 100644 src/external_signage/resource/td5_file/automonus.td5 create mode 100644 src/external_signage/resource/td5_file/null_128x16.td5 create mode 100644 src/external_signage/resource/td5_file/null_80x24.td5 create mode 100644 src/external_signage/setup.cfg create mode 100644 src/external_signage/setup.py create mode 100644 src/external_signage/src/external_signage/__init__.py create mode 100644 src/external_signage/src/external_signage/external_signage.py rename src/{signage/src/signage/external_signage.py => external_signage/src/external_signage/external_signage_core.py} (90%) rename src/{signage/src/signage => external_signage/src/external_signage}/packet_tools.py (100%) diff --git a/src/external_signage/launch/external_signage.launch.xml b/src/external_signage/launch/external_signage.launch.xml new file mode 100755 index 0000000..867b598 --- /dev/null +++ b/src/external_signage/launch/external_signage.launch.xml @@ -0,0 +1,4 @@ + + + + diff --git a/src/external_signage/package.xml b/src/external_signage/package.xml new file mode 100644 index 0000000..5e0ffa9 --- /dev/null +++ b/src/external_signage/package.xml @@ -0,0 +1,26 @@ + + + external_signage + 0.1.0 + The signage package + + yabuta + + Apache License 2.0 + ament_index_python + signage_version + + autoware_auto_system_msgs + diagnostic_updater + python-pulsectl-pip + rclpy + std_srvs + tier4_api_msgs + tier4_debug_msgs + tier4_external_api_msgs + tier4_hmi_msgs + + + ament_python + + diff --git a/src/external_signage/resource/external_signage b/src/external_signage/resource/external_signage new file mode 100644 index 0000000..e69de29 diff --git a/src/external_signage/resource/td5_file/automatic_128x16.td5 b/src/external_signage/resource/td5_file/automatic_128x16.td5 new file mode 100644 index 0000000000000000000000000000000000000000..0297cef88094588d8243c29a50e294708e76c739 GIT binary patch literal 2048 zcmdn__}bmGE4I8pyXV5W^Y;&J4>Q#>VBlb2FfukYG%z$YGB7tb_>Tk_8IU+Yrhot{ zpHyCAX-R%=Vo7GQ0t7HHF)$$80TqT*=;p&Epo~#@)DR#PJ`5}jXfcYaf0Q@8LjXPh zq4Uwx4+9$m!#76MG{XP{$e{$|qtnQ0M%jZS1e_DXX4gQXl#!8!9ANtynVIZ?DIbo39{j_?!UD(W9%irM_|H-A34|Q=9Q+m! z1q1{p)C+=vpOo9koH8){V*&xNMx@*d0FLP_F8}}l literal 0 HcmV?d00001 diff --git a/src/external_signage/resource/td5_file/automatic_80x24.td5 b/src/external_signage/resource/td5_file/automatic_80x24.td5 new file mode 100644 index 0000000000000000000000000000000000000000..4d5077f313c39d94e9c6a553c2d697f2efc223cb GIT binary patch literal 2560 zcmdn__}bmGE4I8pyXV5W^Y;&J4>Q#>VBlh4FfukYG%z$YGB7tb_>Tk_8IU+cFeSL~ zYe+0D$KVjm0KLq{@{F?-X z0{;Z$3J=4?K{@E3l9IBLl2Ve>u@+gFIK%l24R!|hC+aHd3i=5b`r+dLn4JDP{Bil? z`p4m)1H(UiCMqbv#2Nm8SpNi|pa3S$1O)$^K;S=!3CxoS@P`Ei Rz#74VgCi}Dx`O^8002aYB?tfj literal 0 HcmV?d00001 diff --git a/src/external_signage/resource/td5_file/automonus.td5 b/src/external_signage/resource/td5_file/automonus.td5 new file mode 100644 index 0000000000000000000000000000000000000000..1926e4a135a0b95d00c8ee945ae6eb654a569ab3 GIT binary patch literal 2048 zcmdn__}bmGE4I8pyXV5W^Y;&J4>Q#>VBlb2FfuVPGB7kWGB7tb_>Tk_8IU+Yrhot{ zpHyCAX-R%=eqL#@0t7HHF)$$80TqT*=;p&Epo~#@)DR#PJ`5}jXfcYaf0Q@8LjXPh zq4Uwx4+9$m!!<_KG{XP{$e{$|qtnQ0M%jZS1e{MkJYEBdQbtBbhE-y~xaARG-~z>+ zfB-XyVqid~6d;073L;N^a-i)8`k9G|362E}6#fG}iNK5uhaDUp4>~$J9CUDSI4tu) z;h*9k6(CgjqhR~E4JhXD#{~?IwDfRTFr=G^Ff%ZJ5*88`5I4v;&hVd6@t?v!B_LGz zufXu1iOHTxUPuUpfGj2^2L1;O2OQ#$xVRkQdBMRg$I!sQz|L}ng@uK^p`qb`g8&c! Wt6n$>ihu{;toi`NM9Gc#(-{B+BU_^Y literal 0 HcmV?d00001 diff --git a/src/external_signage/resource/td5_file/null_128x16.td5 b/src/external_signage/resource/td5_file/null_128x16.td5 new file mode 100644 index 0000000000000000000000000000000000000000..1cf7414dbf2c27ad1147181f46d72f2da573d956 GIT binary patch literal 2560 zcmdn__}bmGE4I8pyXV5W^Y;&J4>Q#>VBlh4FfuVPGB7kWGB7tb_>Tk_8IU+Yrhot{ zpHyC6X-03ezfL@_WR fQwk74CQ#>VBlh4FfuVPGB7kWGB7tb_>Tk_8IU+cFeSL~ zE6OX)$x%Q83``6R$aWw}ftl#0jmo2j0IA`_z`{UcjH25x${)%hfS&)*`KYN&K>_4f z1|UH8Gcuonje&s;n1_+oA + diff --git a/src/signage/package.xml b/src/signage/package.xml index d31d720..da4a857 100644 --- a/src/signage/package.xml +++ b/src/signage/package.xml @@ -14,10 +14,12 @@ diagnostic_updater python-pulsectl-pip rclpy + std_srvs tier4_api_msgs tier4_debug_msgs tier4_external_api_msgs tier4_hmi_msgs + external_signage ament_python diff --git a/src/signage/src/signage/ros_service_interface.py b/src/signage/src/signage/ros_service_interface.py index d8f7dc1..193e6ec 100644 --- a/src/signage/src/signage/ros_service_interface.py +++ b/src/signage/src/signage/ros_service_interface.py @@ -16,7 +16,7 @@ import rclpy import time import threading - +from std_srvs.srv import SetBool from autoware_adapi_v1_msgs.srv import AcceptStart from std_srvs.srv import Trigger @@ -31,6 +31,7 @@ def __init__(self, node, parameter_interface): self._parameter = parameter_interface.parameter if self._parameter.signage_stand_alone: self._cli_accept_start = self.__create_client(AcceptStart, "/api/motion/accept_start") + self._cli_trigger_external = self.__create_client(SetBool, "/signage/trigger_external") # service call function def accept_start(self): @@ -38,6 +39,12 @@ def accept_start(self): request = AcceptStart.Request() self.__service_call(self._cli_accept_start, request, True) + # service call function + def trigger_external_signage(self, on): + request = SetBool.Request() + request.data = on + self.__service_call(self._cli_trigger_external, request, True) + # common denominator def __create_client(self, service_type, service_name): client = self._node.create_client(service_type, service_name) diff --git a/src/signage/src/signage/route_handler.py b/src/signage/src/signage/route_handler.py index 465b1ae..c254e74 100644 --- a/src/signage/src/signage/route_handler.py +++ b/src/signage/src/signage/route_handler.py @@ -26,7 +26,6 @@ def __init__( autoware_interface, parameter_interface, ros_service_interface, - external_signage, ): self._node = node self._viewController = viewController @@ -34,7 +33,6 @@ def __init__( self._autoware = autoware_interface self._parameter = parameter_interface.parameter self._service_interface = ros_service_interface - self._external_signage = external_signage self.AUTOWARE_IP = os.getenv("AUTOWARE_IP", "localhost") self._fms_payload = { "method": "get", @@ -145,7 +143,7 @@ def announce_engage_when_starting(self): self._parameter.accept_start, ): self._announce_interface.send_announce("restart_engage") - self._external_signage.trigger() + self._service_interface.trigger_external_signage(True) self._trigger_external_signage = True self._engage_trigger_time = self._node.get_clock().now() @@ -281,7 +279,7 @@ def route_checker_callback(self): self._is_stopping = False if not self._announce_engage and self._parameter.signage_stand_alone: self._announce_interface.send_announce("engage") - self._external_signage.trigger() + self._service_interface.trigger_external_signage(True) self._trigger_external_signage = True self._announce_engage = True elif self._autoware.information.route_state == RouteState.ARRIVED: @@ -295,7 +293,7 @@ def route_checker_callback(self): self._autoware.information.operation_mode != OperationModeState.AUTONOMOUS and self._trigger_external_signage ): - self._external_signage.close() + self._service_interface.trigger_external_signage(False) self._trigger_external_signage = False if self._prev_route_state != RouteState.SET: diff --git a/src/signage/src/signage/signage.py b/src/signage/src/signage/signage.py index 4020678..71f427a 100644 --- a/src/signage/src/signage/signage.py +++ b/src/signage/src/signage/signage.py @@ -14,7 +14,6 @@ from signage.parameter_interface import ParameterInterface from signage.route_handler import RouteHandler from signage.ros_service_interface import RosServiceInterface -from signage.external_signage import ExternalSignage from ament_index_python.packages import get_package_share_directory @@ -34,7 +33,6 @@ def main(args=None): ros_service_interface = RosServiceInterface(node, parameter_interface) viewController = ViewControllerProperty(node, parameter_interface) announceController = AnnounceControllerProperty(node, autoware_interface, parameter_interface) - external_signage = ExternalSignage(node) route_handler = RouteHandler( node, viewController, @@ -42,7 +40,6 @@ def main(args=None): autoware_interface, parameter_interface, ros_service_interface, - external_signage, ) ctx = engine.rootContext()