from classes.Cellule import Cellule from classes.StationRecharge import StationRecharge from classes.LieuMission import LieuMission from classes.Robot import Robot from classes.Carte import Carte from random import * from tkinter import * carte = Carte("a") carte.creationCartes(5,5) rob = Robot("HAllo",carte.cellule(0,0), carte) print(carte)
def ajouterRobot(self, nom, color, cellule, carte, simulation) -> Robot: robot = Robot(nom, color, cellule, carte, simulation, self) self.robots.append(robot) return robot
else: robot.setSpeed(-BACKTRACK_VELOCITY, 0) time.sleep(MOVEMENT_TIME) distance = robot.getObstacleDistance() # Returns whether our is at the lefth position or not return coordinatesOur[0] > coordinatesOther[0] if __name__ == "__main__": try: # Initialize Odometry. Default value will be 0,0,0 robot = Robot() # start odometry robot.startOdometry() time.sleep(5) # 1. image_R2D2 = cv2.flip( cv2.imread("images/R2-D2_s.png", cv2.IMREAD_COLOR), -1) image_BB8 = cv2.flip(cv2.imread("images/BB8_s.png", cv2.IMREAD_COLOR), -1) our, other = (image_R2D2, image_BB8) if not Cfg.bb8 else (image_BB8, image_R2D2) # 2. print("Press ESC to quit")
from classes import Cfg from classes.Map import GRID from classes.MapLib import Map2D from classes.Robot import Robot matplotlib.use( "TkAgg" ) # sudo apt-get install tcl-dev tk-dev python-tk python3-tk if TkAgg is not available robot = None if __name__ == "__main__": try: # load map myMap = Map2D(Cfg.FOLDER_MAPS + 'mapa0.txt') myMap.sizeCell = GRID # hardcoded because it should not be in the file!!!! # init Robot robot = Robot([*myMap._cell2pos(1, 7), np.deg2rad(0)]) robot.startOdometry() # spin and wait robot.setSpeed(0, np.deg2rad(-30)) time.sleep(12) finally: # wrap up and close stuff before exiting if robot is not None: robot.stopOdometry()
import matplotlib import numpy as np from classes import Cfg from classes.Map import GRID from classes.MapLib import Map2D from classes.Robot import Robot matplotlib.use( "TkAgg" ) # sudo apt-get install tcl-dev tk-dev python-tk python3-tk if TkAgg is not available robot = None if __name__ == "__main__": try: # load map myMap = Map2D(Cfg.FOLDER_MAPS + 'mapa0.txt') myMap.sizeCell = GRID # hardcoded because it should not be in the file!!!! # init Robot robot = Robot([*myMap._cell2pos(1, 7), np.deg2rad(0)]) robot.startOdometry() # spin and wait robot.updateThOnWall() finally: # wrap up and close stuff before exiting if robot is not None: robot.stopOdometry()
from classes.Robot import Robot from functions.get_image_match import match_images Cfg.add_argument("-bb8", "--bb8", help="detect bb8", action="store_true") Cfg.add_argument("--use_image", help="use the given image instead of capturing picamera", default=None) robot = None # if __name__ == "__main__": try: # Initialize Odometry. Default value will be 0,0,0 robot = Robot() # 1. image_R2D2 = cv2.flip( cv2.imread("images/R2-D2_s.png", cv2.IMREAD_COLOR), -1) image_BB8 = cv2.flip(cv2.imread("images/BB8_s.png", cv2.IMREAD_COLOR), -1) our, other = (image_R2D2, image_BB8) if not Cfg.bb8 else (image_BB8, image_R2D2) capture = None if not Cfg.use_image else cv2.flip( cv2.imread(Cfg.use_image, cv2.IMREAD_COLOR), -1) # 2. print("Press ESC to quit")
try: # check map file mapFile = Cfg.FOLDER_MAPS + Cfg.mapfile os.makedirs(os.path.dirname(mapFile), exist_ok=True) if not os.path.isfile(mapFile): print('Map file %s does not exist' % Cfg.mapfile) exit(1) # 1. load map myMap = Map2D(mapFile) myMap.sizeCell = GRID # hardcoded because it should not be in the file!!!! initial_position = [Cfg.startCell[0] % myMap.sizeX, Cfg.startCell[1] % myMap.sizeY] target_position = [Cfg.endCell[0] % myMap.sizeX, Cfg.endCell[1] % myMap.sizeY] # 2. init Robot and launch updateOdometry thread() robot = Robot([*myMap._cell2pos(*initial_position), 0]) robot.startOdometry() time.sleep(3) # 3. perform trajectory traverseLabyrinth(target_position, myMap, robot) robot.setSpeed(0, 0) myMap.drawMapWithRobotLocations([robot.readOdometry()]) finally: # wrap up and close stuff before exiting if robot is not None: robot.stopOdometry()
IMAGE_BB8 = cv2.flip(cv2.imread("images/BB8_s.png", cv2.IMREAD_COLOR), -1) IMAGE_OUR, IMAGE_OTHER = (IMAGE_R2D2, IMAGE_BB8) if not Cfg.bb8 else (IMAGE_BB8, IMAGE_R2D2) robot = None if __name__ == "__main__": try: # load map myMap = Map2D(Cfg.FOLDER_MAPS + 'mapa0.txt') myMap.sizeCell = GRID # hardcoded because it should not be in the file!!!! # init Robot robot = Robot([*myMap._cell2pos(1, 7), np.deg2rad(-90)]) def go(x, y): """ alias to move the robot to cell (x,y) """ robot.go(*myMap._cell2pos(x, y)) def lookAt(x, y): """ alias to make the robot look at cell (x,y) """ robot.lookAt(*myMap._cell2pos(x, y)) # press button to start robot.waitButtonPress() # start odometry robot.startOdometry()