35 from angles
import normalize_angle_positive, normalize_angle, shortest_angular_distance, two_pi_complement, shortest_angular_distance_with_limits, shortest_angular_distance_with_large_limits
36 from angles
import _find_min_max_delta
39 from math
import pi, fabs
45 self.assertFalse(result)
48 self.assertFalse(result)
51 self.assertTrue(result)
52 self.assertAlmostEqual(shortest_angle, -2*pi+1.0)
55 self.assertTrue(result)
56 self.assertAlmostEqual(shortest_angle, 0)
59 self.assertFalse(result)
60 self.assertAlmostEqual(shortest_angle, -0.5)
63 self.assertFalse(result)
64 self.assertAlmostEqual(shortest_angle, 0.5)
67 self.assertFalse(result)
68 self.assertAlmostEqual(shortest_angle, -2*pi+0.4)
71 self.assertFalse(result)
72 self.assertAlmostEqual(shortest_angle,2*pi-0.4)
75 self.assertFalse(result)
76 self.assertAlmostEqual(shortest_angle,2*pi-0.2)
79 self.assertFalse(result)
80 self.assertAlmostEqual(shortest_angle,-2*pi+0.2)
83 self.assertTrue(result)
84 self.assertAlmostEqual(shortest_angle,-0.25)
87 self.assertTrue(result)
88 self.assertAlmostEqual(shortest_angle,-2*pi+0.75)
91 self.assertTrue(result)
92 self.assertAlmostEqual(shortest_angle,-2*pi+0.5+0.2500001)
95 self.assertFalse(result)
98 self.assertFalse(result)
101 self.assertFalse(result)
104 self.assertFalse(result)
107 self.assertTrue(result)
108 self.assertAlmostEqual(shortest_angle,0.0)
113 self.assertTrue(result)
114 self.assertAlmostEqual(shortest_angle, 0.5*pi)
118 self.assertTrue(result)
119 self.assertAlmostEqual(shortest_angle, -1.5*pi)
123 self.assertFalse(result)
127 self.assertFalse(result)
131 self.assertFalse(result)
135 self.assertTrue(result)
136 self.assertAlmostEqual(shortest_angle, 0.000493)
228 self.assertTrue(flag)
229 self.assertAlmostEqual(min_delta, -pi)
230 self.assertAlmostEqual(max_delta, pi)
234 self.assertTrue(flag)
235 self.assertAlmostEqual(min_delta, -3*pi/2)
236 self.assertAlmostEqual(max_delta, pi/2)
240 self.assertTrue(flag)
241 self.assertAlmostEqual(min_delta, -pi/2)
242 self.assertAlmostEqual(max_delta, 3*pi/2)
246 self.assertTrue(flag)
247 self.assertAlmostEqual(min_delta, -pi/2)
248 self.assertAlmostEqual(max_delta, pi/2)
252 self.assertTrue(flag)
253 self.assertAlmostEqual(min_delta, -3*pi/4)
254 self.assertAlmostEqual(max_delta, pi/4)
258 self.assertTrue(flag)
259 self.assertAlmostEqual(min_delta, -pi/4)
260 self.assertAlmostEqual(max_delta, 3*pi/4)
264 self.assertTrue(flag)
265 self.assertTrue((fabs(min_delta) <= epsilon
and fabs(max_delta - 2*pi) <= epsilon)
or (fabs(min_delta+2*pi) <= epsilon
and fabs(max_delta) <= epsilon))
266 self.assertAlmostEqual(min_delta, 0.0)
267 self.assertAlmostEqual(max_delta, 2*pi)
270 self.assertTrue(flag)
271 self.assertAlmostEqual(min_delta, -2*pi+0.5)
272 self.assertAlmostEqual(max_delta, 0.0)
276 self.assertTrue(flag)
278 self.assertAlmostEqual(min_delta, -2*pi+epsilon)
279 self.assertAlmostEqual(max_delta, epsilon)
283 self.assertTrue(flag)
284 self.assertAlmostEqual(min_delta, 0)
285 self.assertAlmostEqual(max_delta, 2*pi)
289 self.assertTrue(flag)
290 self.assertAlmostEqual(min_delta, 0.0)
291 self.assertAlmostEqual(max_delta, pi)
295 self.assertFalse(flag)
298 self.assertFalse(flag)
302 self.assertTrue(flag)
303 self.assertAlmostEqual(min_delta, -pi/4)
304 self.assertAlmostEqual(max_delta, 3*pi/4)
306 if __name__ ==
'__main__':
308 rosunit.unitrun(
'angles',
'test_python_angles', TestAngles)
static bool shortest_angular_distance_with_limits(double from, double to, double left_limit, double right_limit, double &shortest_angle)
Returns the delta from "from_angle" to "to_angle" making sure it does not violate limits specified by...
def test_shortest_angular_distance(self)
static double shortest_angular_distance(double from, double to)
shortest_angular_distance
def test_shortestDistanceWithLimits(self)
static double normalize_angle(double angle)
normalize
static bool shortest_angular_distance_with_large_limits(double from, double to, double left_limit, double right_limit, double &shortest_angle)
Returns the delta from from_angle to to_angle, making sure it does not violate limits specified by le...
def test_two_pi_complement(self)
static double normalize_angle_positive(double angle)
normalize_angle_positive
def test_normalize_angle(self)
static double two_pi_complement(double angle)
returns the angle in [-2*M_PI, 2*M_PI] going the other way along the unit circle. ...
def test_shortestDistanceWithLargeLimits(self)
def test_find_min_max_delta(self)
def _find_min_max_delta(from_angle, left_limit, right_limit)
def test_normalize_angle_positive(self)
A sample python unit test.