def __init__(self): Localisation.__init__(self) self.epsilon = 500000 self.centreCamera = 800 self.angleCamera = 22.5 self.xIndex = 0 self.yIndex = 1
def __init__(self): Localisation.__init__(self) self.minimumPerimetreRobot = 300 self.maximumPerimetreRobot = 750 self.nbreCote = 4 self.basSV_Mauve = 90 self.basSV_Orange = 130 self.hauteurTable = 180 self.hauteurRobot = 35 self.centreCameraX = 800 self.centreCameraY = 600 self.angleDemiCamera = 22.5 self.mauve = np.uint8([[[255,0,165]]]) self.orange = np.uint8([[[40,127,252]]]) self.hsv_mauve = cv2.cvtColor(self.mauve,cv2.COLOR_BGR2HSV) self.hsv_orange = cv2.cvtColor(self.orange,cv2.COLOR_BGR2HSV) self.bas_mauve = np.array([self.hsv_mauve.item(0) - self.deltaHue, self.basSV_Mauve, self.basSV_Mauve]) self.bas_orange = np.array([self.hsv_orange.item(0) - self.deltaHue, self.basSV_iles, self.basSV_Orange]) self.haut_mauve = np.array([self.hsv_mauve.item(0) + self.deltaHue, self.hautSV_iles, self.hautSV_iles]) self.haut_orange = np.array([self.hsv_orange.item(0) + self.deltaHue, self.hautSV_iles, self.hautSV_iles])
def __init__(self): Localisation.__init__(self) self.hsv_rougeMinimum = 150 self.hsv_rougeMaximum = 179 self.basSVRouge = 100 self.bleu = np.uint8([[[255,255,0]]]) self.hsv_bleu = cv2.cvtColor(self.bleu,cv2.COLOR_BGR2HSV) self.nombreCoteTriangle = 3 self.nombreCoteCarre = 4 self.nombreCotePentagone = 5 self.bas_bleu = np.array([self.hsv_bleu.item(0) - self.deltaHue, self.basSV_iles, self.basSV_iles]) self.bas_rouge = np.array([self.hsv_rougeMinimum, int(self.basSVRouge * 1.5), self.basSVRouge]) self.haut_bleu = np.array([self.hsv_bleu.item(0) + self.deltaHue, self.hautSV_iles, self.hautSV_iles]) self.haut_rouge = np.array([self.hsv_rougeMaximum, self.hautSV_iles, self.hautSV_iles])
def setUp(self): self.localisation = Localisation() self.centreX = 0 self.angle = 180 self.pointDeCroisement = (20, 20) self.positionXRobot = 0 self.positionYRobot = 0 self.origine1 = (20, 0) self.fin1 = (20, 40) self.origine2 = (10, 0) self.fin2 = (10, 40) self.origine3 = (10, 20) self.fin3 = (30, 20) self.distance = 100
class TestUnitaire_Localisation(unittest.TestCase): localisation = Localisation() centreX = 0 angle = 180 pointDeCroisement = (20, 20) positionXRobot = 0 positionYRobot = 0 origine1 = (20, 0) fin1 = (20, 40) origine2 = (10, 0) fin2 = (10, 40) origine3 = (10, 20) fin3 = (30, 20) distance = 100 def setUp(self): self.localisation = Localisation() self.centreX = 0 self.angle = 180 self.pointDeCroisement = (20, 20) self.positionXRobot = 0 self.positionYRobot = 0 self.origine1 = (20, 0) self.fin1 = (20, 40) self.origine2 = (10, 0) self.fin2 = (10, 40) self.origine3 = (10, 20) self.fin3 = (30, 20) self.distance = 100 def tearDown(self): pass def test_recupererAngleRetourneLeBonAngle(self): angleCalcule = self.localisation.recupererAngle(self.centreX) self.assertEqual(angleCalcule, -22.5) def test_recupererPositionXAvecAngleRetourneLaBonnePosition(self): positionX = self.localisation.recupererPositionXAvecAngle(self.angle, self.positionXRobot, self.distance) self.assertEqual(positionX, -100.0) def test_recupererPositionYAvecAngleRetourneLaBonnePosition(self): positionY = self.localisation.recupererPositionYAvecAngle(self.angle, self.positionYRobot, self.distance) self.assertEqual(int(round(positionY)), 0) def test_calculerDistanceDuRobotRetourneLaBonneDistance(self): distanceRobot = self.localisation.calculerDistanceDuRobot(self.pointDeCroisement, self.positionXRobot, self.positionYRobot) self.assertEqual(distanceRobot, sqrt(800)) def test_trouverCroisementEntreDeuxSegmentsParallelesRetourneFalseEtLePointOrigine(self): sontCroisees = self.localisation.trouverCroisement(self.origine1, self.fin1, self.origine2, self.fin2) self.assertEqual(sontCroisees, (False, (0, 0))) def test_trouverCroisementEntreDeuxSegmentsNonParallelesRetourneTrueEtLePointDeCroisement(self): sontCroisees = self.localisation.trouverCroisement(self.origine1, self.fin1, self.origine3, self.fin3) self.assertEqual(sontCroisees, (True, (20, 20)))
def __init__(self): Localisation.__init__(self) self.minimumPerimetreRepere = 1000 self.maximumPerimetreRepere = 4000 self.coteEnCM = 66