Skip to content

Commit

Permalink
add check_use_sim_time app
Browse files Browse the repository at this point in the history
  • Loading branch information
knorth55 committed Sep 17, 2021
1 parent deab596 commit ba26c88
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
display: Check /use_sim_time param
platform: all
launch: jsk_robot_startup/check_use_sim_time.xml
interface: jsk_robot_startup/check_use_sim_time.interface
icon: jsk_robot_startup/check_use_sim_time.png
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
published_topics: {}
subscribed_topics: {}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import actionlib
import rospy
import sys

from sound_play.msg import SoundRequestAction
from sound_play.msg import SoundRequestGoal


class CheckUseSimTime(object):
def __init__(self):
self.warning = rospy.get_param('~warning', True)
self.override = rospy.get_param('~override', True)
self.client_jp = actionlib.SimpleActionClient(
'/robotsound_jp', SoundRequestAction)

def run(self):
use_sim_time = rospy.get_param('/use_sim_time', None)
if use_sim_time:
if self.warning:
self._speak(
self.client_jp,
'use sim timeパラメータがTrueで設定されています',
'jp')
if self.override:
if self.warning:
self._speak(
self.client_jp,
'use sim timeパラメータをFalseに上書きます',
'jp')
rospy.set_param('/use_sim_time', False)

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('check_use_sim_time')
app = CheckUseSimTime()
app.run()
sys.exit(0)
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<launch>
<node name="check_use_sim_time" pkg="jsk_robot_startup" type="check_use_sim_time.py" output="screen"/>
</launch>
2 changes: 2 additions & 0 deletions jsk_robot_common/jsk_robot_startup/apps/robot_apps.installed
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
apps:
- app: jsk_robot_startup/personal_use
display: Personal use
- app: jsk_robot_startup/check_use_sim_time
display: Check /use_sim_time param

0 comments on commit ba26c88

Please sign in to comment.