37 Integration test node that checks if the rviz are working.
40 <test name="rviz_config_check"
41 test-name="rviz_config_check"
42 pkg="jsk_rviz_plugins" type="rviz_config_check.py">
46 - name: another topic name
47 timeout: timeout for the topic
51 Author: Kei Okada <kei.okada@gmail.com>
65 PKG =
'jsk_rviz_plugins'
66 NAME =
'rviz_config_check'
71 super(self.__class__, self).
__init__(*args)
78 params = rospy.get_param(
'~topics', [])
80 if 'name' not in param:
81 self.fail(
"'name' field in rosparam is required but not specified.")
82 topic = {
'timeout': 10,
'type':
None}
84 self.
topics[topic[
'name']] = topic
88 use_sim_time = rospy.get_param(
'/use_sim_time',
False)
90 while not rospy.is_shutdown()
and \
91 use_sim_time
and (rospy.Time.now() == rospy.Time(0)):
92 rospy.logwarn_throttle(
93 1,
'/use_sim_time is specified and rostime is 0, /clock is published?')
94 if time.time() - t_start > 10:
95 self.fail(
'Timed out (10s) of /clock publication.')
100 rviz_service_names = []
101 while not rospy.is_shutdown()
and len(rviz_service_names) == 0:
102 rviz_service_names = rosservice.rosservice_find(
'rviz/SendFilePath')
103 if len(rviz_service_names) == 0:
104 rospy.logwarn(
"[{}] Waiting rviz service (rviz/SendFilePath) for {:.3f} sec".format(rospy.get_name(), time.time() - t_start))
106 if os.environ[
'ROS_DISTRO'] <
'melodic':
107 rviz_service_names = rosservice.rosservice_find(
'std_srvs/Empty')
111 rospy.logwarn(
"[{}] Found rviz service names {}".format(rospy.get_name(), rviz_service_names))
112 rviz_node_names = set(map(rosservice.get_service_node, rviz_service_names))
113 rospy.logwarn(
"[{}] Found rviz node names {}".format(rospy.get_name(), rviz_node_names))
114 if len(rviz_node_names) == 0:
115 rospy.logerr(
"[{}] Could not find rviz nodes".format(rospy.get_name()))
121 rospy.logwarn(
"[{}] Check rviz node exists {}".format(rospy.get_name(), self.
rviz_node_name))
123 t_start = time.time()
124 while not rospy.is_shutdown():
126 t_elapsed = t_now - t_start
131 node_api = rosnode.rosnode_ping(self.
rviz_node_name, max_count=1, skip_cache=
True)
133 rospy.logerr(
"[{}] Could not find rviz node api on rosmaster".format(rospy.get_name()))
136 rospy.logwarn(
"[{}] {:.3f} Rviz node found at {}".format(rospy.get_name(), t_elapsed, node_api))
139 master = rosgraph.Master(
'/rosnode')
141 state = master.getSystemState()
142 subs.extend(sorted([t
for t, l
in state[1]
if self.
rviz_node_name in l]))
143 subs = list(set(subs))
144 rospy.logwarn(
'[{}] rviz subscribes {}'.format(rospy.get_name(), subs))
149 rospy.logwarn(
'[{}] rviz subscribes {}'.format(rospy.get_name(), topic))
151 rospy.logerr(
'[{}] rviz did not subscribes {}'.format(rospy.get_name(), topic))
154 rospy.logwarn(
"[{}] rviz keep alive for {}[sec] and found {}".format(rospy.get_name(), self.
test_duration, self.
topics))
155 self.assertTrue(
True,
"check {}/rviz alives".format(rospy.get_name()))
158 if __name__ ==
'__main__':
160 rostest.run(PKG, NAME, RvizConfigCheck, sys.argv)