pa10-test.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 PKG = 'hrpsys_tutorials'
00004 import roslib; roslib.load_manifest(PKG)
00005 import rospkg
00006 
00007 import numpy
00008 import unittest
00009 
00010 import sys; sys.path.insert (0, roslib.packages.get_pkg_dir('hrpsys')+'/scripts'); ## add python
00011 from hrpsys import HrpsysConfigurator
00012 
00013 class TestPA10(unittest.TestCase):
00014 
00015     @classmethod
00016     def setUpClass(self):
00017         self.robot = HrpsysConfigurator()
00018         self.robot.init("PA10Controller(Robot)0", rospkg.RosPack().get_path("openhrp3")+"/share/OpenHRP-3.1/sample/model/PA10/pa10.main.wrl")
00019 
00020     def test_ik(self):
00021         self.robot.seq_svc.addJointGroup("ARM", ["J1", "J2", "J3", "J4", "J5", "J6"])
00022         lav = [60,0,0,-90,0,0]
00023         for av in [[60, 0, 0, -80, 0, 0],[30, 30, 0,-80, 0, 0],
00024                    [40,40,20, -20, 0, 0],[30, 30,20,-80,20,20]]:
00025             self.robot.setJointAnglesOfGroup("ARM", av, 5)
00026             self.robot.waitInterpolationOfGroup("ARM")
00027             pos1 = self.robot.getReferencePosition("J6")
00028             rpy1 = self.robot.getReferenceRPY("J6")
00029             self.robot.setJointAnglesOfGroup("ARM", lav, 5)
00030             self.robot.waitInterpolationOfGroup("ARM")
00031             self.assertTrue(self.robot.setTargetPose("ARM", pos1, rpy1, 10))
00032             self.robot.waitInterpolationOfGroup("ARM")
00033             pos2 = self.robot.getReferencePosition("J6")
00034             rpy2 = self.robot.getReferenceRPY("J6")
00035             print "pos", pos1, pos2, numpy.linalg.norm(numpy.array(pos1)-numpy.array(pos2))
00036             print "rpy", rpy1, rpy2, numpy.linalg.norm(numpy.array(rpy1)-numpy.array(rpy2))
00037             self.assertTrue(numpy.linalg.norm(numpy.array(pos1)-numpy.array(pos2))<5.0e-3)
00038             self.assertTrue(numpy.linalg.norm(numpy.array(rpy1)-numpy.array(rpy2))<5.0e-3)
00039             lav = av
00040 
00041 
00042 
00043 if __name__ == '__main__':
00044     import rostest
00045     rostest.rosrun(PKG, 'test_pa10', TestPA10) 
00046 
00047 
00048 
00049 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Friends


hrpsys_tutorials
Author(s): AIST, ROS package is maintained by Kei Okada
autogenerated on Tue Jul 23 2013 11:50:52