Exemplo n.º 1
0
 def test_helper(angle_1, angle_2, expected_angle):
     a1 = geometry.Angle(angle_1)
     a2 = geometry.Angle(angle_2)
     s1 = a1 + a2
     s2 = a2 + a1
     self.assertAlmostEqual(s1.in_degrees(), s2.in_degrees())
     self.assertAlmostEqual(s1.in_degrees(), expected_angle)
Exemplo n.º 2
0
 def test_change(self):
     a = geometry.Angle(5)
     a.change(10)
     self.assertAlmostEqual(a.angle, 15)
     a.change(-35)
     self.assertAlmostEqual(a.angle, -20)
     a.change(100)
     self.assertAlmostEqual(a.angle, 80)
Exemplo n.º 3
0
    def __init__(self,
                 data_queue: queue.Queue,
                 socket: socket.socket,
                 view_angle: int = 360,
                 precision: int = 20,
                 safety_distance: float = 10.0):
        super().__init__(data_queue, view_angle, precision)
        self.socket = socket
        self.safety_distance = safety_distance

        # Rotate sensor to starting position
        starting_orientation = view_angle // 2
        self.socket.send(f"ROTATESENSOR {starting_orientation}")
        self.orientation = geometry.Angle(0)
        self.rotate(starting_orientation)
        time.sleep(2)  # Wait until physical sensor is actually turned
Exemplo n.º 4
0
 def __init__(self, x, y, angle, path_id: int = None):
     c = (0.9, 0.2, 0.1, 0.3)
     super().__init__(x, y, color=c, path_id=path_id)
     self.angle = geometry.Angle(angle)
Exemplo n.º 5
0
 def test_in_radians_negative(self):
     a = geometry.Angle(-165)
     r = a.in_radians()
     self.assertAlmostEqual(r, np.radians(-165))
Exemplo n.º 6
0
 def test_in_radians(self):
     a = geometry.Angle(5)
     r = a.in_radians()
     self.assertAlmostEqual(r, np.radians(5))
Exemplo n.º 7
0
 def test_in_degrees(self):
     a = geometry.Angle(5)
     d = a.in_degrees()
     self.assertAlmostEqual(d, 5)
Exemplo n.º 8
0
 def test_helper(angle_1, angle_2, expected_angle):
     a1 = geometry.Angle(angle_1)
     a2 = geometry.Angle(angle_2)
     s = a1 - a2
     self.assertAlmostEqual(s.in_degrees(), expected_angle)
Exemplo n.º 9
0
 def test_str(self):
     a = geometry.Angle(5)
     self.assertEqual(str(a), "5.00°")
Exemplo n.º 10
0
 def test_creation(self):
     a = geometry.Angle(5)
     self.assertAlmostEqual(a.angle, 5)