Package mbdyn :: Package bindings :: Module joints
[hide private]

Source Code for Module mbdyn.bindings.joints

 1  #!/usr/bin/env python 
 2  # -*- coding: utf-8 -*- 
 3  # 
 4  # This file is part of MBDyn sim suite. 
 5  # Copyright (C) 2007 André ESPAZE, as part of a Master thesis supervised by 
 6  # Martin O.L.Hansen (DTU) and Nicolas Chauvat (Logilab) 
 7   
 8  # MBDyn sim suite is free software; you can redistribute it and/or modify 
 9  # it under the terms of the GNU General Public License as published by 
10  # the Free Software Foundation; either version 2 of the License, or 
11  # (at your option) any later version. 
12  # 
13  # This program is distributed in the hope that it will be useful, 
14  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
15  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
16  # GNU General Public License for more details. 
17  # 
18  # You should have received a copy of the GNU General Public License 
19  # along with this program; if not, write to the Free Software 
20  # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 
21  # 
22  """The classes implemented in the joint group. 
23  Currently, the only available class is 
24  L{BindingsHingeJoint<mbdyn.bindings.joints.BindingsHingeJoint>}, 
25  that allows to set an angle value at each time step. 
26   
27  All the classes are contained into L{JOINT_CLASS}, then used 
28  by L{mbdyn.bindings.groups}. 
29  """ 
30  import numpy as N 
31  from mbdyn.bindings.elements import Joint 
32   
33 -class DriveHingeJoint(Joint):
34 """The interface of the C{DriveHingeJoint} class. 35 Currently not implemented""" 36 pass
37
38 -class BindingsHingeJoint(DriveHingeJoint):
39 """A drive hinge joint on which the angle value 40 can be set at every time step""" 41
42 - def __init__(self, c_inst=None):
43 DriveHingeJoint.__init__(self, c_inst) 44 self.value = N.zeros((3, 1))
45
46 - def get_value(self):
47 """Return the angle vector 48 49 @rtype: a Numpy array 50 @return: vector of size 3x1""" 51 return self.value.copy()
52
53 - def set_value(self, array):
54 """Set the angle vector on the drive hinge joint. 55 56 @type array: a Numpy array 57 @param array: a vector of size 3x1""" 58 for idx in range(3): 59 self.value[idx] = array[idx] 60 self.c_inst.ThetaVec.set_value(idx, float(array[idx]))
61 62 63 JOINT_CLASS = {} 64 65 JOINT_CLASS["general"] = Joint 66 JOINT_CLASS["DriveHingeJoint"] = DriveHingeJoint 67 JOINT_CLASS["BindingsHingeJoint"] = BindingsHingeJoint 68