35 from angles
import normalize_angle_positive, normalize_angle, shortest_angular_distance, two_pi_complement, shortest_angular_distance_with_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)
200 self.assertTrue(flag)
201 self.assertAlmostEqual(min_delta, -pi)
202 self.assertAlmostEqual(max_delta, pi)
206 self.assertTrue(flag)
207 self.assertAlmostEqual(min_delta, -3*pi/2)
208 self.assertAlmostEqual(max_delta, pi/2)
212 self.assertTrue(flag)
213 self.assertAlmostEqual(min_delta, -pi/2)
214 self.assertAlmostEqual(max_delta, 3*pi/2)
218 self.assertTrue(flag)
219 self.assertAlmostEqual(min_delta, -pi/2)
220 self.assertAlmostEqual(max_delta, pi/2)
224 self.assertTrue(flag)
225 self.assertAlmostEqual(min_delta, -3*pi/4)
226 self.assertAlmostEqual(max_delta, pi/4)
230 self.assertTrue(flag)
231 self.assertAlmostEqual(min_delta, -pi/4)
232 self.assertAlmostEqual(max_delta, 3*pi/4)
236 self.assertTrue(flag)
237 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))
238 self.assertAlmostEqual(min_delta, 0.0)
239 self.assertAlmostEqual(max_delta, 2*pi)
242 self.assertTrue(flag)
243 self.assertAlmostEqual(min_delta, -2*pi+0.5)
244 self.assertAlmostEqual(max_delta, 0.0)
248 self.assertTrue(flag)
250 self.assertAlmostEqual(min_delta, -2*pi+epsilon)
251 self.assertAlmostEqual(max_delta, epsilon)
255 self.assertTrue(flag)
256 self.assertAlmostEqual(min_delta, 0)
257 self.assertAlmostEqual(max_delta, 2*pi)
261 self.assertTrue(flag)
262 self.assertAlmostEqual(min_delta, 0.0)
263 self.assertAlmostEqual(max_delta, pi)
267 self.assertFalse(flag)
270 self.assertFalse(flag)
274 self.assertTrue(flag)
275 self.assertAlmostEqual(min_delta, -pi/4)
276 self.assertAlmostEqual(max_delta, 3*pi/4)
278 if __name__ ==
'__main__':
280 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
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_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.