Exemplo n.º 1
0
class TestGeoParams(unittest.TestCase):
    """Unit test for GeoParams class."""
    def setUp(self):
        # setup an instance of GeoParams
        self.data_revol = GeoParams(22, {'sigma': 0})
        self.data_prism = GeoParams(20, {'sigma': 1})
        self.data_fixed = GeoParams(10, {'sigma': 2})
        # setup data to compare against
        self.frame = 33
        # setup values to compare against
        self.revol_theta = var('pi')
        self.prism_r = 5
        self.data_revol.theta = self.revol_theta
        self.data_prism.r = self.prism_r
        # setup params to compare against
        self.param_sigma = 0
        self.param_gamma = var('XX20')
        self.param_alpha = var('YY20')
        self.param_theta = var('ZZ20')
        self.params = {
            'sigma': self.param_sigma,
            'gamma': self.param_gamma,
            'alpha': self.param_alpha,
            'theta': self.param_theta
        }
        self.wrong_param = {'rand': 'some-value'}

    def test_init(self):
        """Test constructor"""
        # test instance type
        self.assertIsInstance(GeoParams(self.frame), GeoParams)

    def test_update_params(self):
        """Test update_params()"""
        # NOTE: the state of TransformationMatrix instance is not tested
        # here.
        # test raise AttributeError
        self.assertRaises(
            AttributeError, self.data_fixed.update_params,
            self.wrong_param
        )
        # test update values
        self.data_prism.update_params(self.params)
        self.assertEqual(self.data_prism.sigma, self.param_sigma)
        self.assertEqual(self.data_prism.gamma, self.param_gamma)
        self.assertEqual(self.data_prism.alpha, self.param_alpha)
        self.assertEqual(self.data_prism.theta, self.param_theta)

    def test_q(self):
        """Test get of q()"""
        self.assertEqual(self.data_revol.q, self.revol_theta)
        self.assertEqual(self.data_prism.q, self.prism_r)
        self.assertEqual(self.data_fixed.q, 0)
Exemplo n.º 2
0
class TestGeoParams(unittest.TestCase):
    """Unit test for GeoParams class."""
    def setUp(self):
        # setup an instance of GeoParams
        self.data_revol = GeoParams(22, {'sigma': 0})
        self.data_prism = GeoParams(20, {'sigma': 1})
        self.data_fixed = GeoParams(10, {'sigma': 2})
        # setup data to compare against
        self.frame = 33
        # setup values to compare against
        self.revol_theta = var('pi')
        self.prism_r = 5
        self.data_revol.theta = self.revol_theta
        self.data_prism.r = self.prism_r
        # setup params to compare against
        self.param_sigma = 0
        self.param_gamma = var('XX20')
        self.param_alpha = var('YY20')
        self.param_theta = var('ZZ20')
        self.params = {
            'sigma': self.param_sigma,
            'gamma': self.param_gamma,
            'alpha': self.param_alpha,
            'theta': self.param_theta
        }
        self.wrong_param = {'rand': 'some-value'}

    def test_init(self):
        """Test constructor"""
        # test instance type
        self.assertIsInstance(GeoParams(self.frame), GeoParams)

    def test_update_params(self):
        """Test update_params()"""
        # NOTE: the state of TransformationMatrix instance is not tested
        # here.
        # test raise AttributeError
        self.assertRaises(AttributeError, self.data_fixed.update_params,
                          self.wrong_param)
        # test update values
        self.data_prism.update_params(self.params)
        self.assertEqual(self.data_prism.sigma, self.param_sigma)
        self.assertEqual(self.data_prism.gamma, self.param_gamma)
        self.assertEqual(self.data_prism.alpha, self.param_alpha)
        self.assertEqual(self.data_prism.theta, self.param_theta)

    def test_q(self):
        """Test get of q()"""
        self.assertEqual(self.data_revol.q, self.revol_theta)
        self.assertEqual(self.data_prism.q, self.prism_r)
        self.assertEqual(self.data_fixed.q, 0)
Exemplo n.º 3
0
 def setUp(self):
     # setup an instance of GeoParams
     self.data_revol = GeoParams(22, {'sigma': 0})
     self.data_prism = GeoParams(20, {'sigma': 1})
     self.data_fixed = GeoParams(10, {'sigma': 2})
     # setup data to compare against
     self.frame = 33
     # setup values to compare against
     self.revol_theta = var('pi')
     self.prism_r = 5
     self.data_revol.theta = self.revol_theta
     self.data_prism.r = self.prism_r
     # setup params to compare against
     self.param_sigma = 0
     self.param_gamma = var('XX20')
     self.param_alpha = var('YY20')
     self.param_theta = var('ZZ20')
     self.params = {
         'sigma': self.param_sigma,
         'gamma': self.param_gamma,
         'alpha': self.param_alpha,
         'theta': self.param_theta
     }
     self.wrong_param = {'rand': 'some-value'}
Exemplo n.º 4
0
 def setUp(self):
     # setup an instance of GeoParams
     self.data_revol = GeoParams(22, {'sigma': 0})
     self.data_prism = GeoParams(20, {'sigma': 1})
     self.data_fixed = GeoParams(10, {'sigma': 2})
     # setup data to compare against
     self.frame = 33
     # setup values to compare against
     self.revol_theta = var('pi')
     self.prism_r = 5
     self.data_revol.theta = self.revol_theta
     self.data_prism.r = self.prism_r
     # setup params to compare against
     self.param_sigma = 0
     self.param_gamma = var('XX20')
     self.param_alpha = var('YY20')
     self.param_theta = var('ZZ20')
     self.params = {
         'sigma': self.param_sigma,
         'gamma': self.param_gamma,
         'alpha': self.param_alpha,
         'theta': self.param_theta
     }
     self.wrong_param = {'rand': 'some-value'}
Exemplo n.º 5
0
 def test_init(self):
     """Test constructor"""
     # test instance type
     self.assertIsInstance(GeoParams(self.frame), GeoParams)
Exemplo n.º 6
0
    def __init__(
        self, name, links=0, joints=0, frames=0,
        is_floating=True, structure=tools.TREE, is_mobile=False,
        is_symbolic=True
    ):
        """
        Constructor period.

        Usage:
        """
        """Name of the robot."""
        self.name = name
        """Folder to store the files related to the robot."""
        self.directory = filemgr.get_folder_path(name)
        """Total number of links in the robot."""
        self.num_links = links
        """Total number of joints in the robot."""
        self.num_joints = joints
        """Total number of frames in the robot."""
        self.num_frames = frames
        """To indicate if the base is floating or not."""
        self.is_floating = is_floating
        """Type of the robot structure - simple, tree, closed-loop"""
        self.structure = structure
        """To indicate if the robot is a wheeled mobile robot"""
        self.is_mobile = is_mobile
        """To indicate if computation should be symbolic or numeric"""
        self.is_symbolic = is_symbolic
        # properties dependent on number of links
        """
        List to hold the dynamic parameters. The indices of the list
        start with 0 and it corresponds to parameters of link 0 (virtual
        link of the base).
        """
        self.dyns = [DynParams(j) for j in self.link_nums]
        # properties dependent on number of joints
        """
        To indicate if a joint is rigid or flexible. 0 for rigid and 1
        for flexible. The indices of the list start with 0 and
        corresponds to a virtual joint of the base. This joint is
        usually rigid.
        """
        self.etas = [0 for j in self.joint_nums]
        """Joint stiffness usually indicated by k."""
        self.stiffness = [0 for j in self.joint_nums]
        """Joint velocities."""
        self.qdots = [var('QP{0}'.format(j)) for j in self.joint_nums]
        """Joint accelerations."""
        self.qddots = [var('QDP{0}'.format(j)) for j in self.joint_nums]
        """Joint torques."""
        self.torques = [var('GAM{0}'.format(j)) for j in self.joint_nums]
        # properties dependent on number of frames
        """
        List to hold the geometric parameters. NOTE: This might be moved
        to a separate function.
        The indices of the list start with 0 and the first object
        corresponds to parameters of frame 0 (base) wrt its antecedent
        (some arbitary reference frame).
        """
        self.geos = [GeoParams(j) for j in self.frame_nums]
        # properties independent of number of links, joints and frames
        """Gravity vector a 3x1 Matrix."""
        self.gravity = Matrix([0, 0, var('G3')])
        # the values of properties below would be modified during
        # the computation of dynamic models.
        """Base velocity 6x1 column vector - a Screw."""
        self.base_vel = Screw()
        """Base acceleration 6x1 column vector - a Screw."""
        self.base_accel = Screw()
        """Transformation matrix of base wrt a reference frame at time 0."""
        self.base_tmat = eye(4)
        # call init methods
        self._init_maps()