From 4d95818ede8d6282634fea226f404ac0ed1382ec Mon Sep 17 00:00:00 2001 From: Kanae Kochigami Date: Mon, 22 Aug 2022 18:17:58 +0900 Subject: [PATCH 1/3] (naoqieus) Add warnings for invalid :volume parameters in :speak --- jsk_naoqi_robot/naoqieus/naoqi-interface.l | 2 ++ 1 file changed, 2 insertions(+) diff --git a/jsk_naoqi_robot/naoqieus/naoqi-interface.l b/jsk_naoqi_robot/naoqieus/naoqi-interface.l index 0d79f568b9..5d7c89ad71 100644 --- a/jsk_naoqi_robot/naoqieus/naoqi-interface.l +++ b/jsk_naoqi_robot/naoqieus/naoqi-interface.l @@ -254,6 +254,8 @@ (setq wait t)) ;; set volume and language (when volume + (if (or (> volume 1.0) (< volume 0.0)) + (ros::ros-error ":speak :volume ~A must be between 0.0 and 1.0." volume)) (send self :set-master-volume (round (* volume 100)))) (when lang (unless (send self :set-language lang) From a38573010a6771feb8c17f7e5b49b6be988ddb8a Mon Sep 17 00:00:00 2001 From: Kanae Kochigami Date: Mon, 22 Aug 2022 19:13:12 +0900 Subject: [PATCH 2/3] (naoqieus) Move warnings for invalid :volume :lang parameters in :speak to :set-master-volume and :set-language --- jsk_naoqi_robot/naoqieus/naoqi-interface.l | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/jsk_naoqi_robot/naoqieus/naoqi-interface.l b/jsk_naoqi_robot/naoqieus/naoqi-interface.l index 5d7c89ad71..d33a99bf8d 100644 --- a/jsk_naoqi_robot/naoqieus/naoqi-interface.l +++ b/jsk_naoqi_robot/naoqieus/naoqi-interface.l @@ -254,12 +254,9 @@ (setq wait t)) ;; set volume and language (when volume - (if (or (> volume 1.0) (< volume 0.0)) - (ros::ros-error ":speak :volume ~A must be between 0.0 and 1.0." volume)) (send self :set-master-volume (round (* volume 100)))) (when lang - (unless (send self :set-language lang) - (ros::ros-error ":speak :lang ~A must be English or Japanese" lang))) + (send self :set-language lang)) ;; send speech request (send speech_msg :data str) (ros::publish (format nil "~A/speech" group-namespace) speech_msg) @@ -347,10 +344,15 @@ (:set-master-volume (volume) (let ((ret (instance nao_interaction_msgs::SetAudioMasterVolumeRequest :init))) - (ros::wait-for-service (format nil "~A/naoqi_driver/set_volume" group-namespace)) - (send ret :master_volume :data volume) - (ros::service-call (format nil "~A/naoqi_driver/set_volume" group-namespace) ret) - )) + (if (<= 0 volume 100) + (progn + (ros::wait-for-service (format nil "~A/naoqi_driver/set_volume" group-namespace)) + (send ret :master_volume :data volume) + (ros::service-call (format nil "~A/naoqi_driver/set_volume" group-namespace) ret) + t) + (progn + (ros::ros-error ":set-master-volume ~A must be between 0 and 100." volume) + nil)))) (:get-master-volume () (let ((ret (instance nao_interaction_msgs::GetAudioMasterVolumeRequest :init)) @@ -434,6 +436,8 @@ (ros::wait-for-service (format nil "~A/naoqi_driver/set_language" group-namespace)) (send ret :data language) (setq res (ros::service-call (format nil "~A/naoqi_driver/set_language" group-namespace) ret)) + (if (not (send res :success)) + (ros::ros-error ":speak :lang ~A must be English or Japanese" language)) (send res :success)) ) (:get-language From f6224fc93840961a7e1c4a521149118059da61c5 Mon Sep 17 00:00:00 2001 From: Kanae Kochigami Date: Mon, 22 Aug 2022 19:36:02 +0900 Subject: [PATCH 3/3] (naoqieus) Get errors for invalid :volume :lang parameters in :speak --- jsk_naoqi_robot/naoqieus/naoqi-interface.l | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/jsk_naoqi_robot/naoqieus/naoqi-interface.l b/jsk_naoqi_robot/naoqieus/naoqi-interface.l index d33a99bf8d..cf5cb57405 100644 --- a/jsk_naoqi_robot/naoqieus/naoqi-interface.l +++ b/jsk_naoqi_robot/naoqieus/naoqi-interface.l @@ -254,9 +254,11 @@ (setq wait t)) ;; set volume and language (when volume - (send self :set-master-volume (round (* volume 100)))) + (unless (send self :set-master-volume (round (* volume 100))) + (error "Invalid volume argument"))) (when lang - (send self :set-language lang)) + (unless (send self :set-language lang) + (error "Invalid language argument"))) ;; send speech request (send speech_msg :data str) (ros::publish (format nil "~A/speech" group-namespace) speech_msg) @@ -437,7 +439,7 @@ (send ret :data language) (setq res (ros::service-call (format nil "~A/naoqi_driver/set_language" group-namespace) ret)) (if (not (send res :success)) - (ros::ros-error ":speak :lang ~A must be English or Japanese" language)) + (ros::ros-error ":speak :lang ~A must be English or Japanese" language)) (send res :success)) ) (:get-language