test-hrpsysconf.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 PKG = 'hrpsys'
00004 NAME = 'test-hrpsys-config'
00005 
00006 import imp  ## for rosbuild
00007 try:
00008     imp.find_module(PKG)
00009 except:
00010     import roslib; roslib.load_manifest(PKG)
00011 
00012 from hrpsys.hrpsys_config import *
00013 from hrpsys import rtm
00014 import OpenHRP
00015 
00016 import argparse,unittest,rostest
00017 
00018 import unittest, sys
00019 
00020 class SampleHrpsysConfigurator(HrpsysConfigurator):
00021     def init(self, robotname="SampleRobot(Robot)0", url=""):
00022          HrpsysConfigurator.init(self, robotname=robotname, url=url)
00023 
00024 class TestHrpsysConfig(unittest.TestCase):
00025     global h
00026     rh = None
00027     seq = None
00028 
00029     def test_import_waitinput(self):
00030         # https://github.com/start-jsk/rtmros_hironx/blob/groovy-devel/hironx_ros_bridge/src/hironx_ros_bridge/hironx_client.py
00031         from waitInput import waitInputConfirm, waitInputSelect
00032         self.assertTrue(True)
00033 
00034     def test_createcomp(self):
00035         global h
00036         self.seq = h.createComp("SequencePlayer",'seq')[0]
00037 
00038     def test_connectcomp(self):
00039         global h
00040         if self.seq == None or self.rh == None:
00041             self.test_createcomp()
00042         connectPorts(self.rh.port("q"), self.seq.port("qInit"))
00043         # check number of connection
00044         assert(len(self.seq.port("qInit").get_connector_profiles()) == 1)
00045         # check do not connect again if already connected for https://github.com/fkanehiro/hrpsys-base/issues/979
00046         connectPorts(self.rh.port("q"), self.seq.port("qInit"))
00047         assert(len(self.seq.port("qInit").get_connector_profiles()) == 1)
00048 
00049     def test_findcomp(self):
00050         global h
00051         h.findComps()
00052 
00053     def setUp(self):
00054         global h
00055         parser = argparse.ArgumentParser(description='hrpsys command line interpreters')
00056         parser.add_argument('--host', help='corba name server hostname')
00057         parser.add_argument('--port', help='corba name server port number')
00058         args, unknown = parser.parse_known_args()
00059 
00060         if args.host:
00061             rtm.nshost = args.host
00062         if args.port:
00063             rtm.nsport = args.port
00064         h = SampleHrpsysConfigurator()
00065 
00066         h.waitForRTCManager()
00067         # look for name
00068         for c in h.ms.get_components():
00069             if '(Robot)' in c.name() or 'RobotHardware' in c.name():
00070                 h.waitForRobotHardware(c.name())  # get robot hardware name
00071                 break;
00072         self.rh = h.rh
00073 
00074 #unittest.main()
00075 if __name__ == '__main__':
00076     import rostest
00077     rostest.run(PKG, NAME, TestHrpsysConfig, sys.argv)


hrpsys
Author(s): AIST, Fumio Kanehiro
autogenerated on Wed May 15 2019 05:02:19