From f687d10fcd3c8b2e1d6f1c438231ce3de669bcdf Mon Sep 17 00:00:00 2001 From: Naoto Tsukamoto Date: Thu, 29 Jun 2023 16:45:37 +0900 Subject: [PATCH 1/7] [jsk_fetch_startup] Add TimeSignal.cfg --- jsk_fetch_robot/jsk_fetch_startup/cfg/TimeSignal.cfg | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 jsk_fetch_robot/jsk_fetch_startup/cfg/TimeSignal.cfg diff --git a/jsk_fetch_robot/jsk_fetch_startup/cfg/TimeSignal.cfg b/jsk_fetch_robot/jsk_fetch_startup/cfg/TimeSignal.cfg new file mode 100644 index 0000000000..e22d48bc1e --- /dev/null +++ b/jsk_fetch_robot/jsk_fetch_startup/cfg/TimeSignal.cfg @@ -0,0 +1,11 @@ +#! /usr/bin/env python + + +from dynamic_reconfigure.parameter_generator_catkin import * + +PACKAGE = 'jsk_fetch_startup' + +gen = ParameterGenerator() +gen.add("volume", double_t, 0, "Volume of sound.", 1.0, 0.0, 1.0) + +exit(gen.generate(PACKAGE, PACKAGE, "TimeSignal")) From e27c250649b6a1896da1d39b746400abde8763b2 Mon Sep 17 00:00:00 2001 From: Naoto Tsukamoto Date: Thu, 29 Jun 2023 16:46:12 +0900 Subject: [PATCH 2/7] [jsk_fetch_startup] Add dynamic_reconfigure to dependency --- jsk_fetch_robot/jsk_fetch_startup/package.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/jsk_fetch_robot/jsk_fetch_startup/package.xml b/jsk_fetch_robot/jsk_fetch_startup/package.xml index 70d3f9eda9..f83da9e637 100644 --- a/jsk_fetch_robot/jsk_fetch_startup/package.xml +++ b/jsk_fetch_robot/jsk_fetch_startup/package.xml @@ -12,7 +12,9 @@ catkin fetch_teleop + dynamic_reconfigure + dynamic_reconfigure image_proc jsk_fetch_accessories jsk_fetch_diagnosis From c0038cdc55e90efd1005a43e4affdd97a2cdfdaf Mon Sep 17 00:00:00 2001 From: Naoto Tsukamoto Date: Thu, 29 Jun 2023 16:46:42 +0900 Subject: [PATCH 3/7] [jsk_fetch_startup] Enable dynamic_recongiure --- jsk_fetch_robot/jsk_fetch_startup/CMakeLists.txt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/jsk_fetch_robot/jsk_fetch_startup/CMakeLists.txt b/jsk_fetch_robot/jsk_fetch_startup/CMakeLists.txt index 96d03f10ea..41d435037b 100644 --- a/jsk_fetch_robot/jsk_fetch_startup/CMakeLists.txt +++ b/jsk_fetch_robot/jsk_fetch_startup/CMakeLists.txt @@ -11,6 +11,7 @@ endif() ## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz) ## is used, also find other catkin packages find_package(catkin REQUIRED COMPONENTS + dynamic_reconfigure roscpp std_msgs sensor_msgs @@ -24,10 +25,16 @@ find_package(catkin REQUIRED COMPONENTS ) find_package(Boost REQUIRED COMPONENTS) +generate_dynamic_reconfigure_options( + cfg/TimeSignal.cfg +) + ################################### ## catkin specific configuration ## ################################### -catkin_package() +catkin_package( + CATKIN_DEPENDS dynamic_reconfigure +) catkin_add_env_hooks(99.jsk_fetch_startup SHELLS bash zsh sh DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/env-hooks) From ec284f8d0ef62c864450e0ced4c47310687436f1 Mon Sep 17 00:00:00 2001 From: Naoto Tsukamoto Date: Thu, 29 Jun 2023 16:45:09 +0900 Subject: [PATCH 4/7] [jsk_fetch_startup] Set volume dynamically in time_signal.py --- .../jsk_fetch_startup/scripts/time_signal.py | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/jsk_fetch_robot/jsk_fetch_startup/scripts/time_signal.py b/jsk_fetch_robot/jsk_fetch_startup/scripts/time_signal.py index 321714985a..083e12c658 100755 --- a/jsk_fetch_robot/jsk_fetch_startup/scripts/time_signal.py +++ b/jsk_fetch_robot/jsk_fetch_startup/scripts/time_signal.py @@ -8,12 +8,14 @@ import sys import urllib2 +from dynamic_reconfigure.server import Server +from jsk_fetch_startup.cfg import TimeSignalConfig as Config from sound_play.msg import SoundRequestAction from sound_play.msg import SoundRequestGoal class TimeSignal(object): - def __init__(self): + def __init__(self, volume=1.0): self.client_en = actionlib.SimpleActionClient( '/sound_play', SoundRequestAction) self.client_jp = actionlib.SimpleActionClient( @@ -23,6 +25,8 @@ def __init__(self): self.now_hour = self.now_time.hour self.now_minute = self.now_time.minute self.day = self.now_time.strftime('%a') + self.volume = volume + self.srv = Server(Config, self.config_callback) reload(sys) sys.setdefaultencoding('utf-8') api_key_file = rospy.get_param( @@ -35,7 +39,7 @@ def speak(self, client, speech_text, lang=None): sound_goal = SoundRequestGoal() sound_goal.sound_request.sound = -3 sound_goal.sound_request.command = 1 - sound_goal.sound_request.volume = 1.0 + sound_goal.sound_request.volume = self.volume if lang is not None: sound_goal.sound_request.arg2 = lang sound_goal.sound_request.arg = speech_text @@ -153,6 +157,20 @@ def _get_weather_forecast(self, lang='en'): forecast_text += " The wind speed is {} meter per second.".format(wind_speed) return forecast_text + def _set_volume(self, volume): + ''' + Set speak volume between 0.0 and 1.0 + ''' + volume = min(max(0.0, volume), 1.0) + if self.volume != volume: + self.volume = volume + rospy.loginfo("time_signal's volume was set to {}".format( + self.volume)) + + def config_callback(self, config, level): + self._set_volume(config.volume) + return config + if __name__ == '__main__': rospy.init_node('time_signal') From 051c13b4f0d4392f59bc1a313c2952274d096efd Mon Sep 17 00:00:00 2001 From: Naoto Tsukamoto Date: Mon, 3 Jul 2023 11:33:39 +0900 Subject: [PATCH 5/7] [jsk_robot_startup] Add time_signal to auto speak volume control app --- .../jsk_robot_startup/lifelog/auto_speak_volume_lower.l | 1 + .../jsk_robot_startup/lifelog/auto_speak_volume_reset.l | 1 + .../jsk_robot_startup/lifelog/auto_speak_volume_zero.l | 1 + 3 files changed, 3 insertions(+) diff --git a/jsk_robot_common/jsk_robot_startup/lifelog/auto_speak_volume_lower.l b/jsk_robot_common/jsk_robot_startup/lifelog/auto_speak_volume_lower.l index 48c236a58c..6696fe3f16 100755 --- a/jsk_robot_common/jsk_robot_startup/lifelog/auto_speak_volume_lower.l +++ b/jsk_robot_common/jsk_robot_startup/lifelog/auto_speak_volume_lower.l @@ -11,4 +11,5 @@ (ros::set-dynamic-reconfigure-param "/tweet_client_uptime" "volume" :double 0.2) (ros::set-dynamic-reconfigure-param "/tweet_client_warning" "volume" :double 0.2) (ros::set-dynamic-reconfigure-param "/tweet_client_worktime" "volume" :double 0.2) +(ros::set-dynamic-reconfigure-param "/time_signal" "volume" :double 0.2) (exit) diff --git a/jsk_robot_common/jsk_robot_startup/lifelog/auto_speak_volume_reset.l b/jsk_robot_common/jsk_robot_startup/lifelog/auto_speak_volume_reset.l index a57c51c262..315e9151af 100755 --- a/jsk_robot_common/jsk_robot_startup/lifelog/auto_speak_volume_reset.l +++ b/jsk_robot_common/jsk_robot_startup/lifelog/auto_speak_volume_reset.l @@ -11,4 +11,5 @@ (ros::set-dynamic-reconfigure-param "/tweet_client_uptime" "volume" :double 1.0) (ros::set-dynamic-reconfigure-param "/tweet_client_warning" "volume" :double 1.0) (ros::set-dynamic-reconfigure-param "/tweet_client_worktime" "volume" :double 1.0) +(ros::set-dynamic-reconfigure-param "/time_signal" "volume" :double 1.0) (exit) diff --git a/jsk_robot_common/jsk_robot_startup/lifelog/auto_speak_volume_zero.l b/jsk_robot_common/jsk_robot_startup/lifelog/auto_speak_volume_zero.l index e0bb7d2c43..39c58b530e 100755 --- a/jsk_robot_common/jsk_robot_startup/lifelog/auto_speak_volume_zero.l +++ b/jsk_robot_common/jsk_robot_startup/lifelog/auto_speak_volume_zero.l @@ -11,4 +11,5 @@ (ros::set-dynamic-reconfigure-param "/tweet_client_uptime" "volume" :double 0.0) (ros::set-dynamic-reconfigure-param "/tweet_client_warning" "volume" :double 0.0) (ros::set-dynamic-reconfigure-param "/tweet_client_worktime" "volume" :double 0.0) +(ros::set-dynamic-reconfigure-param "/time_signal" "volume" :double 0.0) (exit) From 14d6bca4f4e9be5dde281673e1669393258a4251 Mon Sep 17 00:00:00 2001 From: Naoto Tsukamoto Date: Mon, 3 Jul 2023 12:06:40 +0900 Subject: [PATCH 6/7] [Fetch] Use run-name-entry-fetch15 branch in app_manager --- jsk_fetch_robot/jsk_fetch.rosinstall.melodic | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/jsk_fetch_robot/jsk_fetch.rosinstall.melodic b/jsk_fetch_robot/jsk_fetch.rosinstall.melodic index d7ca64262f..3cdd4ee529 100644 --- a/jsk_fetch_robot/jsk_fetch.rosinstall.melodic +++ b/jsk_fetch_robot/jsk_fetch.rosinstall.melodic @@ -5,10 +5,12 @@ # https://github.com/PR2/app_manager/pull/50 # In order to run multiple app_managers in one master, we need this PR # https://github.com/PR2/app_manager/pull/54 +# This PR add run_name entry to specif node name when we use run entry +# https://github.com/PR2/app_manager/pull/64 - git: local-name: PR2/app_manager - uri: https://github.com/knorth55/app_manager.git - version: fetch15 + uri: https://github.com/tkmtnt7000/app_manager.git + version: add-run-name-entry-fetch15 # we need this for proximity sensors - git: local-name: RoboticMaterials/FA-I-sensor From 9c19fddcbadc342c76bdca328955bc36709d44b5 Mon Sep 17 00:00:00 2001 From: Naoto Tsukamoto Date: Mon, 3 Jul 2023 12:07:08 +0900 Subject: [PATCH 7/7] [jsk_fetch_startup] Add run_name to time_signal.py to specify node name --- .../jsk_fetch_startup/apps/time_signal/time_signal.app | 2 ++ 1 file changed, 2 insertions(+) diff --git a/jsk_fetch_robot/jsk_fetch_startup/apps/time_signal/time_signal.app b/jsk_fetch_robot/jsk_fetch_startup/apps/time_signal/time_signal.app index 6137ee226b..e82fe5629f 100644 --- a/jsk_fetch_robot/jsk_fetch_startup/apps/time_signal/time_signal.app +++ b/jsk_fetch_robot/jsk_fetch_startup/apps/time_signal/time_signal.app @@ -1,6 +1,8 @@ display: Speak time signal platform: fetch run: jsk_fetch_startup/time_signal.py +run_name: "time_signal" +# run_name needs https://github.com/PR2/app_manager/pull/64 interface: jsk_fetch_startup/time_signal.interface icon: jsk_fetch_startup/time_signal.png timeout: 120