-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[jsk_robot_startup] add personal use app in jsk_robot_startup #1295
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
jsk_robot_common/jsk_robot_startup/apps/personal_use/personal_use.app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
display: Personal Use | ||
platform: all | ||
launch: jsk_robot_startup/personal_use.xml | ||
interface: jsk_robot_startup/personal_use.interface | ||
icon: jsk_robot_startup/personal_use.png | ||
2 changes: 2 additions & 0 deletions
2
jsk_robot_common/jsk_robot_startup/apps/personal_use/personal_use.interface
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
published_topics: {} | ||
subscribed_topics: {} |
Binary file added
BIN
+45.9 KB
jsk_robot_common/jsk_robot_startup/apps/personal_use/personal_use.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
110 changes: 110 additions & 0 deletions
110
jsk_robot_common/jsk_robot_startup/apps/personal_use/personal_use.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
import actionlib | ||
import rospy | ||
|
||
from sound_play.msg import SoundRequestAction | ||
from sound_play.msg import SoundRequestGoal | ||
|
||
|
||
class PersonalUse(object): | ||
def __init__(self): | ||
duration = rospy.get_param('~duration', 10.0) | ||
self.warning = rospy.get_param('~warning', True) | ||
warning_duration = rospy.get_param( | ||
'~warning_duration', 60.0 * 15) | ||
self.client_jp = actionlib.SimpleActionClient( | ||
'/robotsound_jp', SoundRequestAction) | ||
self.timer = rospy.Timer( | ||
rospy.Duration(duration), self._timer_cb) | ||
|
||
self.user_name = rospy.get_param( | ||
'/app_manager/running_user_name', None) | ||
self.robot_name = rospy.get_param('/robot/name', None) | ||
|
||
self.warning_limit = warning_duration / duration | ||
self.warning_count = 0 | ||
|
||
if self.user_name: | ||
rospy.loginfo( | ||
"{} is running personal use app.".format(self.user_name)) | ||
sentence = "{}に{}が実行ユーザとして登録されました.".format( | ||
self.robot_name, self.user_name) | ||
sentence += "{}が{}の使用を開始しました.".format( | ||
self.user_name, self.robot_name) | ||
else: | ||
rospy.logerr("failed to get /app_manager/running_user_name param") | ||
sentence = "実行ユーザ登録に失敗しました." | ||
self._speak(self.client_jp, sentence, 'jp') | ||
|
||
def _timer_cb(self, event): | ||
user_name = rospy.get_param('/app_manager/running_user_name', None) | ||
self.warning_count = self.warning_count + 1 | ||
if self.user_name: | ||
# overwriting user | ||
if user_name and self.user_name != user_name: | ||
rospy.logerr( | ||
'running user has changed: {} -> {}' | ||
.format(self.user_name, user_name)) | ||
rospy.logerr( | ||
'overwrite running user: {} -> {}' | ||
.format(user_name, self.user_name)) | ||
rospy.set_param( | ||
'/app_manager/running_user_name', self.user_name) | ||
sentence = "{}に{}が実行ユーザとして上書き登録されました.".format( | ||
self.robot_name, user_name) | ||
sentence += "{}に{}を再度実行ユーザとして上書き登録しました.".format( | ||
self.robot_name, self.user_name) | ||
self._speak(self.client_jp, sentence, 'jp') | ||
# deleting user | ||
elif not user_name: | ||
rospy.logerr( | ||
'running user has removed: {}'.format(self.user_name)) | ||
rospy.logerr( | ||
'set running user: {}'.format(self.user_name)) | ||
sentence = "{}から{}の実行ユーザ登録が削除されました.".format( | ||
self.robot_name, self.user_name) | ||
sentence += "{}に{}を再度実行ユーザとして登録しました.".format( | ||
self.robot_name, self.user_name) | ||
rospy.set_param( | ||
'/app_manager/running_user_name', self.user_name) | ||
self._speak(self.client_jp, sentence, 'jp') | ||
|
||
if self.warning and self.warning_count >= self.warning_limit: | ||
rospy.loginfo( | ||
"{} is running personal use app.".format(self.user_name)) | ||
sentence = "{}が{}を使用しています.".format( | ||
self.user_name, self.robot_name) | ||
self._speak(self.client_jp, sentence, 'jp') | ||
else: | ||
rospy.logerr('/app_manager/running_user_name is not set') | ||
sentence = "実行ユーザが登録されていません." | ||
if user_name: | ||
self.user_name = user_name | ||
rospy.set_param( | ||
'/app_manager/running_user_name', self.user_name) | ||
rospy.logerr( | ||
'set running user: {}'.format(self.user_name)) | ||
sentence += "{}を実行ユーザとして登録しました.".format(self.user_name) | ||
self._speak(self.client_jp, sentence, 'jp') | ||
self.warning_count = self.warning_count % self.warning_limit | ||
|
||
def _speak(self, client, speech_text, lang=None): | ||
client.wait_for_server(timeout=rospy.Duration(1.0)) | ||
sound_goal = SoundRequestGoal() | ||
sound_goal.sound_request.sound = -3 | ||
sound_goal.sound_request.command = 1 | ||
sound_goal.sound_request.volume = 1.0 | ||
if lang is not None: | ||
sound_goal.sound_request.arg2 = lang | ||
sound_goal.sound_request.arg = speech_text | ||
client.send_goal(sound_goal) | ||
client.wait_for_result() | ||
return client.get_result() | ||
|
||
|
||
if __name__ == '__main__': | ||
rospy.init_node('personal_use') | ||
app = PersonalUse() | ||
rospy.spin() |
3 changes: 3 additions & 0 deletions
3
jsk_robot_common/jsk_robot_startup/apps/personal_use/personal_use.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<launch> | ||
<node name="personal_use" pkg="jsk_robot_startup" type="personal_use.py" output="screen"/> | ||
</launch> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
apps: | ||
- app: jsk_robot_startup/personal_use | ||
display: Personal use |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@a-ichikura @MiyabiTane please update personal_use.png