test-jointangle.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 PKG = 'hrpsys'
4 NAME = 'test-hostname'
5 
6 import imp ## for rosbuild
7 try:
8  imp.find_module(PKG)
9 except:
10  import roslib; roslib.load_manifest(PKG)
11 
12 
13 import os
14 import sys
15 import time
16 import unittest
17 import yaml
18 
19 import rostest
20 from hrpsys import rtm
21 from hrpsys.hrpsys_config import *
22 import OpenHRP
23 
24 rtm.nsport = 2809
25 
26 class PA10(HrpsysConfigurator):
27  def getRTCList(self):
28  return [
29  ['seq', "SequencePlayer"],
30  ['sh', "StateHolder"],
31  ['fk', "ForwardKinematics"],
32  ['log', "DataLogger"],
33  ]
34 
35 
36 
37 class TestJointAngle(unittest.TestCase):
38 
39  @classmethod
40  def setUpClass(self):
41  h = PA10()
42  h.init(robotname="PA10Controller(Robot)0")
43 
45  h = PA10()
46  h.findComps()
47  print >>sys.stderr, "log=",h.log, "log_svc=",h.log_svc
48  self.assertTrue(h.log)
49  self.assertTrue(h.log_svc)
50 
52  h = PA10()
53  h.findComps()
54  print >>sys.stderr, h.getJointAngles()
55  self.assertEqual(len(h.getJointAngles()), int(9))
56 
58  h = PA10()
59  h.findComps()
60  self.assertTrue(h.setJointAngles(h.getJointAngles(),1))
61  self.assertEqual(h.waitInterpolation(), None)
62 
63  import random
64  a = [(360*random.random()-180) for i in xrange(len(h.getJointAngles()))]
65  self.assertTrue(h.setJointAngles(a,2))
66  self.assertEqual(h.waitInterpolation(), None)
67 
68  a = [0 for i in xrange(len(h.getJointAngles()))]
69  self.assertTrue(h.setJointAngles(a,2))
70  self.assertEqual(h.waitInterpolation(), None)
71 
72 #unittest.main()
73 if __name__ == '__main__':
74  rostest.run(PKG, NAME, TestJointAngle, sys.argv)
75 
76 


hrpsys
Author(s): AIST, Fumio Kanehiro
autogenerated on Thu May 6 2021 02:41:51