36
36
EPSILON = 0.001
37
37
38
38
39
- def wrap_to_interval (angles , lower = - pi ):
40
- """
41
- Wraps an angle into a semi-closed interval of width 2*pi.
42
-
43
- By default, this interval is `[-pi, pi)`. However, the lower bound of the
44
- interval can be specified to wrap to the interval `[lower, lower + 2*pi)`.
45
-
46
- If `lower` is an array the same length as angles, the bounds will be
47
- applied element-wise to each angle in `angles`.
48
-
49
- See: http://stackoverflow.com/a/32266181
50
-
51
- @param angles an angle or 1D array of angles to wrap
52
- @type angles float or numpy.array
53
- @param lower optional lower bound on wrapping interval
54
- @type lower float or numpy.array
55
- """
56
- return (angles - lower ) % (2 * pi ) + lower
57
-
58
-
59
39
class TSR (object ):
60
40
""" A Task-Space-Region (TSR) represents a motion constraint. """
61
41
def __init__ (self , T0_w = None , Tw_e = None , Bw = None ,
@@ -82,6 +62,7 @@ def __init__(self, T0_w=None, Tw_e=None, Bw=None,
82
62
Bw_interval = Bw_cont [3 :6 , 1 ] - Bw_cont [3 :6 , 0 ]
83
63
Bw_interval = numpy .minimum (Bw_interval , 2 * pi )
84
64
65
+ from prpy .util import wrap_to_interval
85
66
Bw_cont [3 :6 , 0 ] = wrap_to_interval (Bw_cont [3 :6 , 0 ])
86
67
Bw_cont [3 :6 , 1 ] = Bw_cont [3 :6 , 0 ] + Bw_interval
87
68
@@ -200,6 +181,7 @@ def rpy_within_bounds(rpy, Bw):
200
181
@return check a (3,) vector of True if within and False if outside
201
182
"""
202
183
# Unwrap rpy to Bw_cont.
184
+ from prpy .util import wrap_to_interval
203
185
rpy = wrap_to_interval (rpy , lower = Bw [:, 0 ])
204
186
205
187
# Check bounds condition on RPY component.
@@ -398,6 +380,7 @@ def sample_xyzrpy(self, xyzrpy=NANBW):
398
380
if numpy .isnan (x ) else x
399
381
for i , x in enumerate (xyzrpy )])
400
382
# Unwrap rpy to [-pi, pi]
383
+ from prpy .util import wrap_to_interval
401
384
Bw_sample [3 :6 ] = wrap_to_interval (Bw_sample [3 :6 ])
402
385
return Bw_sample
403
386
0 commit comments