diff --git a/setup.sh b/setup.sh index 23d262f..80eebe5 100644 --- a/setup.sh +++ b/setup.sh @@ -5,7 +5,7 @@ # aptで必要なパッケージをインストール sudo apt update -y sudo apt -y install python3-pyqt5.qtquick qml-module-qtquick-controls qml-module-qtquick-controls2 qml-module-qtquick-shapes python3-pyqt5.qtmultimedia libasound2-dev -sudo pip3 install simpleaudio +sudo pip3 install simpleaudio aiohttp pyserial # signageのbuild colcon build diff --git a/src/signage/src/signage/route_handler.py b/src/signage/src/signage/route_handler.py index 57bd292..79cd4b1 100644 --- a/src/signage/src/signage/route_handler.py +++ b/src/signage/src/signage/route_handler.py @@ -6,6 +6,9 @@ import requests import json from datetime import datetime +import aiohttp +import asyncio + import signage.signage_utils as utils from tier4_external_api_msgs.msg import DoorStatus from autoware_adapi_v1_msgs.msg import ( @@ -65,7 +68,7 @@ def __init__( self._announced_arrive = False self._trigger_external_signage = False - self.process_station_list_from_fms() + asyncio.run(self.process_station_list_from_fms()) self._node.create_timer(0.2, self.route_checker_callback) self._node.create_timer(0.2, self.emergency_checker_callback) @@ -170,15 +173,16 @@ def announce_engage_when_starting(self): except Exception as e: self._node.get_logger().error("not able to play the announce, ERROR: {}".format(str(e))) - def process_station_list_from_fms(self, force_update=False): + async def process_station_list_from_fms(self, force_update=False): try: - respond = requests.post( - "http://{}:4711/v1/services/order".format(self.AUTOWARE_IP), - json=self._fms_payload, - timeout=5, - ) + async with aiohttp.ClientSession() as session: + async with session.post( + f"http://{self.AUTOWARE_IP}:4711/v1/services/order", + json=self._fms_payload, + timeout=5, + ) as response: + data = await response.json() - data = json.loads(respond.text) self._fms_check_time = self._node.get_clock().now() if not data: @@ -312,14 +316,14 @@ def route_checker_callback(self): if self._prev_route_state != RouteState.SET: if self._autoware.information.route_state == RouteState.SET: - self.process_station_list_from_fms(force_update=True) + asyncio.run(self.process_station_list_from_fms(force_update=True)) if not self._fms_check_time: - self.process_station_list_from_fms() + asyncio.run(self.process_station_list_from_fms()) elif utils.check_timeout( self._node.get_clock().now(), self._fms_check_time, self._parameter.check_fms_time ): - self.process_station_list_from_fms() + asyncio.run(self.process_station_list_from_fms()) if self._in_emergency_state: return