Skip to content

Commit

Permalink
Fix/fms boot shutdown hash 2.3.0 (#137)
Browse files Browse the repository at this point in the history
* add fms handler

Signed-off-by: tkhmy <[email protected]>

* add handle negative goal distance (#131)

Signed-off-by: tkhmy <[email protected]>

* modify sound of emergency stop

* modify signage outlook

* update hash

Signed-off-by: tkhmy <[email protected]>

---------

Signed-off-by: tkhmy <[email protected]>
Co-authored-by: Shohei Sakai <[email protected]>
  • Loading branch information
tkhmy and saka1-s authored Nov 21, 2024
1 parent 5f153f0 commit 8eb8237
Show file tree
Hide file tree
Showing 20 changed files with 210 additions and 43 deletions.
10 changes: 5 additions & 5 deletions signage.repos
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ repositories:
src/tier4_autoware_msgs:
type: git
url: https://github.com/tier4/tier4_autoware_msgs.git
version: tier4/universe
version: f605df51444092daa23fbf31a350f058284191f9
src/auto_msgs:
type: git
url: https://github.com/tier4/autoware_auto_msgs.git
version: tier4/main
version: 1e8b6d234e2690c9da386f006bb60835cdccddfd
src/autoware_msgs:
type: git
url: https://github.com/autowarefoundation/autoware_msgs.git
version: main
version: 224bd3a87fb539630f5a09409c809a81f8bb9118
src/autoware_adapi_msgs:
type: git
url: https://github.com/autowarefoundation/autoware_adapi_msgs.git
version: main
version: 12d6d7729be6b7b42612a202c29556261254ff30
src/boot_shutdown_tools:
type: git
url: https://github.com/tier4/boot_shutdown_tools.git
version: main
version: v0.1.2
4 changes: 2 additions & 2 deletions src/external_signage/setup.cfg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[develop]
script-dir=$base/lib/external_signage
script_dir=$base/lib/external_signage
[install]
install-scripts=$base/lib/external_signage
install_scripts=$base/lib/external_signage
5 changes: 3 additions & 2 deletions src/signage/config/signage_param.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ signage:
ros__parameters:
signage_stand_alone: true
ignore_emergency_stoppped: false
ignore_disconnected: false
ignore_manual_driving: false
set_goal_by_distance: false
goal_distance: 1.0 # meter
check_fms_time: 5.0 # second
check_fms_time: 2.0 # second
emergency_repeat_period: 180.0 # second
accept_start: 5.0 # second
monitor_width: 1920
Expand All @@ -19,4 +20,4 @@ signage:
thank_you: true
in_emergency: true
going_to_depart: true
going_to_arrive: true
going_to_arrive: true
6 changes: 6 additions & 0 deletions src/signage/launch/signage.launch.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
<?xml version="1.0"?>
<launch>
<arg name="signage_param" default="$(find-pkg-share signage)/config/signage_param.yaml" />
<arg name="fms_client_param" default="$(find-pkg-share signage_fms_client)/config/fms_client_param.yaml" />
<arg name="debug_mode" default="false" />
<node pkg="signage" exec="signage" output="screen">
<param from="$(var signage_param)"/>
</node>
<node pkg="external_signage" exec="external_signage" output="screen" />

<node pkg="signage_fms_client" exec="signage_fms_client" output="screen" >
<param from="$(var fms_client_param)"/>
</node>
</launch>
3 changes: 2 additions & 1 deletion src/signage/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@

<depend>autoware_auto_system_msgs</depend>
<depend>diagnostic_updater</depend>
<depend>external_signage</depend>
<depend>python-pulsectl-pip</depend>
<depend>rclpy</depend>
<depend>signage_fms_client</depend>
<depend>std_srvs</depend>
<depend>tier4_api_msgs</depend>
<depend>tier4_debug_msgs</depend>
<depend>tier4_external_api_msgs</depend>
<depend>tier4_hmi_msgs</depend>
<depend>external_signage</depend>

<export>
<build_type>ament_python</build_type>
Expand Down
8 changes: 4 additions & 4 deletions src/signage/resource/page/EmergencyStopView/EmergencyStop.qml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ Rectangle {
id: emergencyStopView
width: viewController.monitor_width
height: viewController.monitor_height
color: "#f60000"
color: "#ffffff"
Text {
id: emergencyStopText
color: "#ffffff"
text: qsTr("緊急停止中")
color: "#000000"
text: qsTr("安全のため停止中")
anchors.horizontalCenter: parent.horizontalCenter
anchors.bottom: parent.verticalCenter
horizontalAlignment: Text.AlignHCenter
Expand All @@ -21,7 +21,7 @@ Rectangle {

Text {
id: emergencyStopEnText
color: "#ffffff"
color: "#000000"
text: qsTr("Emergency Stop")
anchors.top: emergencyStopText.bottom
anchors.horizontalCenter: parent.horizontalCenter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ Rectangle {
id: emergencyStoppingView
width: viewController.monitor_width
height: viewController.monitor_height
color: "#f60000"
color: "#ffffff"
Text {
id: emergencyStoppingText
color: "#ffffff"
color: "#000000"
text: qsTr("只今オペレータ対応中です")
anchors.horizontalCenter: parent.horizontalCenter
anchors.bottom: parent.verticalCenter
Expand All @@ -21,7 +21,7 @@ Rectangle {

Text {
id: emergencyStoppingEnText
color: "#ffffff"
color: "#000000"
text: qsTr("Now the operator is working on it")
anchors.top: emergencyStoppingText.bottom
anchors.horizontalCenter: parent.horizontalCenter
Expand Down
Binary file modified src/signage/resource/sound/emergency.wav
Binary file not shown.
4 changes: 2 additions & 2 deletions src/signage/setup.cfg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[develop]
script-dir=$base/lib/signage
script_dir=$base/lib/signage
[install]
install-scripts=$base/lib/signage
install_scripts=$base/lib/signage
28 changes: 24 additions & 4 deletions src/signage/src/signage/autoware_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@
LocalizationInitializationState,
VelocityFactorArray,
)
from std_msgs.msg import String
import signage.signage_utils as utils
from tier4_debug_msgs.msg import Float64Stamped
from tier4_external_api_msgs.msg import DoorStatus

DISCONNECT_THRESHOLD = 2


@dataclass
class AutowareInformation:
autoware_control: bool = False
Expand All @@ -27,6 +29,7 @@ class AutowareInformation:
goal_distance: float = 1000.0
motion_state: int = 0
localization_init_state: int = 0
active_schedule: str = ""


class AutowareInterface:
Expand Down Expand Up @@ -90,13 +93,24 @@ def __init__(self, node):
self.sub_velocity_factors_callback,
sub_qos,
)
self._autoware_connection_time = self._node.get_clock().now()
self._node.create_timer(1, self.reset_timer)
self._sub_active_schedule = node.create_subscription(
String,
"/signage/active_schedule",
self.sub_active_schedule_callback,
sub_qos,
)
if not self._parameter.debug_mode:
self._autoware_connection_time = self._node.get_clock().now()
self._node.create_timer(1, self.reset_timer)

def reset_timer(self):
if utils.check_timeout(self._node.get_clock().now(), self._autoware_connection_time, DISCONNECT_THRESHOLD):
if utils.check_timeout(
self._node.get_clock().now(), self._autoware_connection_time, DISCONNECT_THRESHOLD
):
self.information = AutowareInformation()
self._node.get_logger().error("Autoware disconnected", throttle_duration_sec=DISCONNECT_THRESHOLD)
self._node.get_logger().error(
"Autoware disconnected", throttle_duration_sec=DISCONNECT_THRESHOLD
)
self.is_disconnected = True
else:
self.is_disconnected = False
Expand Down Expand Up @@ -151,3 +165,9 @@ def sub_velocity_factors_callback(self, msg):
self._autoware_connection_time = self._node.get_clock().now()
except Exception as e:
self._node.get_logger().error("Unable to get the velocity factors, ERROR: " + str(e))

def sub_active_schedule_callback(self, msg):
try:
self.information.active_schedule = msg.data
except Exception as e:
self._node.get_logger().error("Unable to get the active schedule, ERROR: " + str(e))
8 changes: 7 additions & 1 deletion src/signage/src/signage/parameter_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
class SignageParameter:
signage_stand_alone: bool = False
ignore_manual_driving: bool = False
ignore_disconnected: bool = False
ignore_emergency: bool = False
set_goal_by_distance: bool = False
goal_distance: float = 1.0
Expand All @@ -18,6 +19,7 @@ class SignageParameter:
monitor_width: int = 1920
monitor_height: int = 540


@dataclass
class AnnounceParameter:
emergency: bool = True
Expand All @@ -31,12 +33,14 @@ class AnnounceParameter:
going_to_depart: bool = True
going_to_arrive: bool = True


class ParameterInterface:
def __init__(self, node):
self.parameter = SignageParameter()
self.announce_settings = AnnounceParameter()

node.declare_parameter("signage_stand_alone", False)
node.declare_parameter("ignore_disconnected", False)
node.declare_parameter("ignore_manual_driving", False)
node.declare_parameter("check_fms_time", 5.0)
node.declare_parameter("accept_start", 5.0)
Expand All @@ -50,6 +54,9 @@ def __init__(self, node):
self.parameter.signage_stand_alone = (
node.get_parameter("signage_stand_alone").get_parameter_value().bool_value
)
self.parameter.ignore_disconnected = (
node.get_parameter("ignore_disconnected").get_parameter_value().bool_value
)
self.parameter.ignore_manual_driving = (
node.get_parameter("ignore_manual_driving").get_parameter_value().bool_value
)
Expand Down Expand Up @@ -96,4 +103,3 @@ def __init__(self, node):
key,
announce_prefix[key].get_parameter_value().bool_value,
)

32 changes: 13 additions & 19 deletions src/signage/src/signage/route_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import requests
import json
from datetime import datetime

import signage.signage_utils as utils
from tier4_external_api_msgs.msg import DoorStatus
from autoware_adapi_v1_msgs.msg import (
Expand Down Expand Up @@ -35,14 +36,6 @@ def __init__(
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",
"url": "https://"
+ os.getenv("FMS_URL", "fms.web.auto")
+ "/v1/projects/{project_id}/environments/{environment_id}/vehicles/{vehicle_id}/active_schedule",
"body": {},
}
self._schedule_details = utils.init_ScheduleDetails()
self._display_details = utils.init_DisplayDetails()
self._current_task_details = utils.init_CurrentTask()
Expand Down Expand Up @@ -171,15 +164,7 @@ def announce_engage_when_starting(self):

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,
)

data = json.loads(respond.text)
self._fms_check_time = self._node.get_clock().now()

data = json.loads(self._autoware.information.active_schedule)
if not data:
self._schedule_details = utils.init_ScheduleDetails()
self._display_details = utils.init_DisplayDetails()
Expand All @@ -189,6 +174,8 @@ def process_station_list_from_fms(self, force_update=False):
self._fms_check_time = self._node.get_clock().now()
raise Exception("same schedule, skip")

self._fms_check_time = self._node.get_clock().now()

self._schedule_details = utils.update_schedule_details(data)

self._display_details.route_name = utils.get_route_name(
Expand Down Expand Up @@ -365,7 +352,10 @@ def calculate_time_callback(self):
self._announce_interface.announce_going_to_depart_and_arrive("going_to_depart")
elif self._is_driving:
# handle text and announce while bus is running
if self._autoware.information.goal_distance < 100:
if (
self._autoware.information.goal_distance < 100
and self._autoware.information.goal_distance > 0
):
# display text and announce if the goal is within 100m
self._display_phrase = utils.handle_phrase("arriving")
self._announce_interface.announce_going_to_depart_and_arrive("going_to_arrive")
Expand All @@ -388,7 +378,11 @@ def view_mode_callback(self):
self._viewController.next_station_list = self._display_details.next_station_list
self._viewController.display_phrase = self._display_phrase

if self._autoware.is_disconnected:
if (
self._autoware.is_disconnected
and not self._parameter.ignore_disconnected
and not self._parameter.ignore_emergency
):
view_mode = "emergency_stopped"
elif (
not self._autoware.information.autoware_control
Expand Down
3 changes: 3 additions & 0 deletions src/signage_fms_client/config/fms_client_param.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
signage:
ros__parameters:
post_request_time: 8.0 # second
7 changes: 7 additions & 0 deletions src/signage_fms_client/launch/signage_fms_client.launch.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0"?>
<launch>
<arg name="fms_client_param" default="$(find-pkg-share signage)/config/fms_client_param.yaml" />
<node pkg="signage_fms_client" exec="signage_fms_client" output="screen" >
<param from="$(var signage_param)"/>
</node>
</launch>
17 changes: 17 additions & 0 deletions src/signage_fms_client/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0"?>
<package format="2">
<name>signage_fms_client</name>
<version>0.1.0</version>
<description>The fms client for signage</description>

<maintainer email="[email protected]">tkhmy</maintainer>

<license>Apache License 2.0</license>
<exec_depend>ament_index_python</exec_depend>

<depend>rclpy</depend>

<export>
<build_type>ament_python</build_type>
</export>
</package>
Empty file.
4 changes: 4 additions & 0 deletions src/signage_fms_client/setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[develop]
script_dir=$base/lib/signage_fms_client
[install]
install_scripts=$base/lib/signage_fms_client
Loading

0 comments on commit 8eb8237

Please sign in to comment.