-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1059 from garaemon/check-run-id
[jsk_topic_tools] check /run_id param to know roscore is restarted or…
- Loading branch information
Showing
1 changed file
with
13 additions
and
0 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -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 |