55from math import pi
66
77from compas .base import Base
8- from compas .robots .model .joint import Joint
98
109__all__ = [
1110 'Configuration' ,
1211 'FixedLengthList' ,
1312]
1413
14+ # These joint types known to configuration are a match
15+ # to the ones defined in `Joint` class, but we redefine here
16+ # to avoid a circular dependency
17+ _JOINT_REVOLUTE = 0
18+ _JOINT_CONTINUOUS = 1
19+ _JOINT_PRISMATIC = 2
20+ _JOINT_PLANAR = 5
21+
1522
1623def joint_names_validator (joint_names , key = None , value = None ):
1724 new_joint_names = list (joint_names )
@@ -266,7 +273,7 @@ def from_revolute_values(cls, values, joint_names=None):
266273 """
267274 values = list (values )
268275 joint_names = list (joint_names or [])
269- return cls .from_data ({'joint_values' : values , 'joint_types' : [Joint . REVOLUTE ] * len (values ), 'joint_names' : joint_names })
276+ return cls .from_data ({'joint_values' : values , 'joint_types' : [_JOINT_REVOLUTE ] * len (values ), 'joint_names' : joint_names })
270277
271278 @classmethod
272279 def from_prismatic_and_revolute_values (cls , prismatic_values , revolute_values , joint_names = None ):
@@ -291,8 +298,8 @@ def from_prismatic_and_revolute_values(cls, prismatic_values, revolute_values, j
291298 revolute_values = list (revolute_values )
292299 joint_names = list (joint_names or [])
293300 values = prismatic_values + revolute_values
294- joint_types = [Joint . PRISMATIC ] * \
295- len (prismatic_values ) + [Joint . REVOLUTE ] * len (revolute_values )
301+ joint_types = [_JOINT_PRISMATIC ] * \
302+ len (prismatic_values ) + [_JOINT_REVOLUTE ] * len (revolute_values )
296303 return cls .from_data ({'joint_values' : values , 'joint_types' : joint_types , 'joint_names' : joint_names })
297304
298305 @classmethod
@@ -353,12 +360,12 @@ def prismatic_values(self):
353360
354361 E.g. positions on the external axis system.
355362 """
356- return [v for i , v in enumerate (self .joint_values ) if self .joint_types [i ] == Joint . PRISMATIC ]
363+ return [v for i , v in enumerate (self .joint_values ) if self .joint_types [i ] == _JOINT_PRISMATIC ]
357364
358365 @property
359366 def revolute_values (self ):
360367 """:obj:`list` of :obj:`float` : Revolute joint values in radians."""
361- return [v for i , v in enumerate (self .joint_values ) if self .joint_types [i ] == Joint . REVOLUTE ]
368+ return [v for i , v in enumerate (self .joint_values ) if self .joint_types [i ] == _JOINT_REVOLUTE ]
362369
363370 def copy (self ):
364371 """Create a copy of this :class:`Configuration`.
@@ -388,7 +395,7 @@ def scale(self, scale_factor):
388395 values_scaled = []
389396
390397 for value , joint_type in zip (self .joint_values , self .joint_types ):
391- if joint_type in (Joint . PLANAR , Joint . PRISMATIC ):
398+ if joint_type in (_JOINT_PLANAR , _JOINT_PRISMATIC ):
392399 value *= scale_factor
393400 values_scaled .append (value )
394401
@@ -457,7 +464,7 @@ def iter_differences(self, other):
457464
458465 for i , (v1 , v2 ) in enumerate (value_pairs ):
459466 diff = v1 - v2
460- if self .joint_types [i ] in [Joint . REVOLUTE , Joint . CONTINUOUS ]:
467+ if self .joint_types [i ] in [_JOINT_REVOLUTE , _JOINT_CONTINUOUS ]:
461468 d1 = diff % (2 * pi )
462469 d1 = d1 if diff >= 0 else d1 - 2 * pi
463470 d2 = d1 - 2 * pi if diff >= 0 else d1 + 2 * pi
0 commit comments