Skip to content
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_topic_tools] check /run_id param to know roscore is restarted or… #1059

Merged
merged 1 commit into from
Aug 3, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions jsk_topic_tools/src/jsk_topic_tools/master_util.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,32 @@
import rospy
import re
import os

previous_run_id = None

def isMasterAlive():
"""
return True if master alive and return False if
master is not alive
"""
global previous_run_id
try:
# first check the host is available
master = rospy.get_master()
master_host = re.search('http://([a-zA-Z0-9\-_]*):', master.getUri()[2]).groups(1)[0]
response = os.system("ping -W 10 -c 1 " + master_host + " > /dev/null")
if response != 0:
print "master machine looks down"
return False
master.getSystemState()
run_id = rospy.get_param("/run_id")

if not previous_run_id:
previous_run_id = run_id
if run_id != previous_run_id:
print "run_id is not same"
previous_run_id = run_id
return False
return True
except Exception, e:
return False