def wtf_check(ctx): """Check implementation function for roswtf""" from roswtf.rules import warning_rule, error_rule for r in warnings: warning_rule(r, r[0](ctx), ctx) for r in errors: error_rule(r, r[0](ctx), ctx)
def wtf_check_online(ctx): _load_online_ctx(ctx) if not ctx.roslaunch_uris: return for r in online_roslaunch_warnings: warning_rule(r, r[0](ctx), ctx) for r in online_roslaunch_errors: error_rule(r, r[0](ctx), ctx)
def wtf_check(ctx): # no package in context to verify if not ctx.pkgs: return for r in warnings: warning_rule(r, r[0](ctx), ctx) for r in errors: error_rule(r, r[0](ctx), ctx)
def wtf_check_graph(ctx, names=None): master_uri = ctx.ros_master_uri #TODO: master rules # - check for stale master state # TODO: get the type for each topic from each publisher and see if they match up master = rosgraph.Master('/roswtf') try: master.getPid() except rospkg.MasterException: warning_rule( (True, "Cannot communicate with master, ignoring online checks"), True, ctx) return # fill in ctx info so we only have to compute once print("analyzing graph...") _compute_online_context(ctx) print("... done analyzing graph") if names: check_topics = [t for t in names if t in ctx.topics] check_services = [t for t in names if t in ctx.services] check_nodes = [t for t in names if t in ctx.nodes] unknown = [ t for t in names if t not in check_topics + check_services + check_nodes ] if unknown: raise WtfException( "The following names were not found in the list of nodes, topics, or services:\n%s" % (''.join([" * %s\n" % t for t in unknown]))) for t in check_topics: for r in topic_warnings: warning_rule(r, r[0](ctx, t), ctx) for r in topic_errors: error_rule(r, r[0](ctx, t), ctx) for s in check_services: for r in service_warnings: warning_rule(r, r[0](ctx, s), ctx) for r in service_errors: error_rule(r, r[0](ctx, s), ctx) for n in check_nodes: for r in node_warnings: warning_rule(r, r[0](ctx, n), ctx) for r in node_errors: error_rule(r, r[0](ctx, n), ctx) print("running graph rules...") for r in graph_warnings: warning_rule(r, r[0](ctx), ctx) for r in graph_errors: error_rule(r, r[0](ctx), ctx) print("... done running graph rules")
def wtf_check_static(ctx): if not ctx.launch_files: return #NOTE: roslaunch files are already loaded separately into context #TODO: check each machine name #TODO: bidirectional ping for each machine for r in static_roslaunch_warnings: warning_rule(r, r[0](ctx), ctx) for r in static_roslaunch_errors: error_rule(r, r[0](ctx), ctx)
def wtf_check_graph(ctx, names=None): master_uri = ctx.ros_master_uri #TODO: master rules # - check for stale master state # TODO: get the type for each topic from each publisher and see if they match up master = rosgraph.Master('/roswtf') try: master.getPid() except rospkg.MasterException: warning_rule((True, "Cannot communicate with master, ignoring online checks"), True, ctx) return # fill in ctx info so we only have to compute once print "analyzing graph..." _compute_online_context(ctx) print "... done analyzing graph" if names: check_topics = [t for t in names if t in ctx.topics] check_services = [t for t in names if t in ctx.services] check_nodes = [t for t in names if t in ctx.nodes] unknown = [t for t in names if t not in check_topics + check_services + check_nodes] if unknown: raise WtfException("The following names were not found in the list of nodes, topics, or services:\n%s"%(''.join([" * %s\n"%t for t in unknown]))) for t in check_topics: for r in topic_warnings: warning_rule(r, r[0](ctx, t), ctx) for r in topic_errors: error_rule(r, r[0](ctx, t), ctx) for s in check_services: for r in service_warnings: warning_rule(r, r[0](ctx, s), ctx) for r in service_errors: error_rule(r, r[0](ctx, s), ctx) for n in check_nodes: for r in node_warnings: warning_rule(r, r[0](ctx, n), ctx) for r in node_errors: error_rule(r, r[0](ctx, n), ctx) print "running graph rules..." for r in graph_warnings: warning_rule(r, r[0](ctx), ctx) for r in graph_errors: error_rule(r, r[0](ctx), ctx) print "... done running graph rules"
def roswtf_plugin_online(ctx): # don't run plugin if tf isn't active as these checks take awhile if not is_tf_active(): return print("running tf checks, this will take a second...") sub1 = rospy.Subscriber('/tf', tf.msg.tfMessage, _tf_handle) time.sleep(1.0) sub1.unregister() print("... tf checks complete") for r in tf_warnings: warning_rule(r, r[0](ctx), ctx) for r in tf_errors: error_rule(r, r[0](ctx), ctx)
def roswtf_plugin_online(ctx): # don't run plugin if tf isn't active as these checks take awhile if not is_tf_active(): return print "running tf checks, this will take a second..." sub1 = rospy.Subscriber('/tf', tf.msg.tfMessage, _tf_handle) time.sleep(1.0) sub1.unregister() print "... tf checks complete" for r in tf_warnings: warning_rule(r, r[0](ctx), ctx) for r in tf_errors: error_rule(r, r[0](ctx), ctx)
def wtf_check_online(ctx): _load_online_ctx(ctx) for r in online_roslaunch_warnings: warning_rule(r, r[0](ctx), ctx) for r in online_roslaunch_errors: error_rule(r, r[0](ctx), ctx)
def wtf_check_environment(ctx): # TODO: check ROS_BOOST_ROOT for r in environment_warnings: warning_rule(r, r[0](ctx), ctx) for r in environment_errors: error_rule(r, r[0](ctx), ctx)
def wtf_check(ctx): for r in warnings: warning_rule(r, r[0](ctx), ctx) for r in errors: error_rule(r, r[0](ctx), ctx)
def roswtf_plugin_static(ctx): for r in app_warnings_static: warning_rule(r, r[0](ctx), ctx) for r in app_errors_static: error_rule(r, r[0](ctx), ctx)
def roswtf_plugin_online(ctx): for r in app_warnings_online: warning_rule(r, r[0](ctx), ctx) for r in app_errors_online: error_rule(r, r[0](ctx), ctx)
def wtf_check_environment(ctx): #TODO: check ROS_BOOST_ROOT for r in environment_warnings: warning_rule(r, r[0](ctx), ctx) for r in environment_errors: error_rule(r, r[0](ctx), ctx)