check_camera_transforms_publish_tf.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 """
3 @file check_camera_transforms_publish_tf.py
4 """
5 import os
6 import sys
7 import unittest
8 import time
9 import rospy
10 import rostest
11 from rs_general.rs_general import get_camera_params_and_values, \
12  is_log_contains_keyword, LOGFILE, shell_cmd_timeout
13 
14 PKG = "realsense_camera"
15 NAME = "test_camera_transforms_publish_tf"
16 
17 
18 class CheckCameraTransformsPublishTf(unittest.TestCase):
19  """
20  @class CheckCameraTransformsPublishTf: check whether message exist
21  or not based on disable/enable publish tf
22  """
24  """
25  @fn test_camera_transforms_publish_tf
26  @param self
27  @return
28  """
29  rospy.init_node(NAME, anonymous=True, log_level=rospy.DEBUG)
30  time.sleep(10)
31  messages = expected_message.split(',')
32  indicator = 0
33  cmd = "rm ~/.ros/test_rostopic.log >/dev/null 2>&1"
34  os.system(cmd)
35  cmd = "rostopic echo /tf_static > ~/.ros/test_rostopic.log"
36  shell_cmd_timeout(cmd, 5)
37  for message in messages:
38  if is_log_contains_keyword("~/.ros/test_rostopic.log", message):
39  indicator = indicator + 1
40  rospy.loginfo("***transforms publish info***: " + str(indicator))
41  if indicator == len(messages) and is_log_contains_keyword(LOGFILE, publish_info):
42  self.assertEqual('true', expected)
43  elif indicator == 0 and not is_log_contains_keyword(LOGFILE, publish_info):
44  self.assertEqual('false', expected)
45  else:
46  self.assertTrue(False)
47 
48 if __name__ == '__main__':
49  param_dict = get_camera_params_and_values(sys.argv)
50  expected_message = param_dict['expected_messages']
51  expected = param_dict['expected']
52  publish_info = param_dict['info'].replace('*', ' ')
53  rostest.rosrun(PKG, NAME, CheckCameraTransformsPublishTf, sys.argv)
def shell_cmd_timeout(cmd, timeout=0)
Definition: rs_general.py:75
def is_log_contains_keyword(log_file, keyword)
Definition: rs_general.py:60
def get_camera_params_and_values(args)
Definition: rs_general.py:38


realsense_camera
Author(s): Rajvi Jingar , Reagan Lopez , Matt Hansen , Mark Horn
autogenerated on Mon Jun 10 2019 14:40:37