1- __author__ = 'Thomas Rueckstiess, ruecksti@in.tum.de'
1+ # -*- coding: utf-8 -*-
22
33import ode , xode #@UnresolvedImport
44from pybrain .utilities import Named
55import sys , warnings
66
7+ __author__ = 'Thomas Rueckstiess, ruecksti@in.tum.de'
8+
9+
710class Actuator (Named ):
811 """The base Actuator class. Every actuator has a name, and a list of values (even if it is
912 only one value) with numValues entries. They can be added to the ODEEnvironment with
@@ -27,13 +30,14 @@ def getNumValues(self):
2730 return self ._numValues
2831
2932
30-
3133class JointActuator (Actuator ):
32- ''' This actuator parses the xode root node for all joints and applies a torque
33- to the angles of each of them. Different joints have a different number of values (e.g.
34- a hinge2 joints has two degrees of freedom, whereas a slider joint has only one).
35- However, calling the function getValues(), will return a flat list of all the
36- degrees of freedom of all joints.'''
34+ """
35+ This actuator parses the xode root node for all joints and applies a torque
36+ to the angles of each of them. Different joints have a different number of values (e.g.
37+ a hinge2 joints has two degrees of freedom, whereas a slider joint has only one).
38+ However, calling the function getValues(), will return a flat list of all the
39+ degrees of freedom of all joints.
40+ """
3741
3842 def __init__ (self , name = 'JointActuator' ):
3943 Actuator .__init__ (self , name , 0 )
@@ -45,6 +49,7 @@ def _parseJoints(self, node):
4549 joint = node .getODEObject ()
4650 joint .name = node .getName ()
4751 self ._joints .append (joint )
52+
4853 # recursive call for children
4954 for c in node .getChildren ():
5055 self ._parseJoints (c )
@@ -77,7 +82,9 @@ def _countValues(self):
7782 return num
7883
7984 def _update (self , action ):
80- assert (len (action ) == self ._numValues )
85+ if len (action ) != self ._numValues :
86+ raise Exception ("{} not equal to {}" .format (str (len (action )), str (self ._numValues )))
87+
8188 for j in self ._joints :
8289 if type (j ) == ode .BallJoint :
8390 # ball joints can't be controlled yet
@@ -112,7 +119,9 @@ def _update(self, action):
112119
113120
114121class SpecificJointActuator (JointActuator ):
115- ''' This sensor takes a list of joint names, and controlls only their values. '''
122+ """
123+ This sensor takes a list of joint names, and controlls only their values.
124+ """
116125
117126 def __init__ (self , jointNames , name = None ):
118127 Actuator .__init__ (self , name , 0 )
@@ -140,8 +149,10 @@ def _connect(self, world):
140149
141150
142151class CopyJointActuator (JointActuator ):
143- ''' This sensor takes a list of joint names and controls all joints at once (one single value,
144- even for multiple hinges/amotors) '''
152+ """
153+ This sensor takes a list of joint names and controls all joints at once (one single value,
154+ even for multiple hinges/amotors)
155+ """
145156
146157 def __init__ (self , jointNames , name = None ):
147158 Actuator .__init__ (self , name , 0 )
@@ -197,4 +208,3 @@ def _update(self, action):
197208 # therefore, you can (must) set a torque but it is not applied
198209 # to the joint.
199210 pass
200-
0 commit comments