Skip to content

Commit

Permalink
(naoqieus) Move warnings for invalid :volume :lang parameters in :spe…
Browse files Browse the repository at this point in the history
…ak to :set-master-volume and :set-language
  • Loading branch information
kochigami committed Aug 22, 2022
1 parent 4d95818 commit a385730
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions jsk_naoqi_robot/naoqieus/naoqi-interface.l
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a385730

Please sign in to comment.