def __init__(self,
                 picturePath,
                 picturesToTake=1,
                 pause=0.5,
                 objectName="",
                 angles=0,
                 objectAltitude=None,
                 startingAngle=0):

        self.pictureManager = PictureManager(picturePath)
        self.picturesToTake = picturesToTake
        self.pause = pause
        self.objectName = objectName
        self.angles = angles
        self.objectAltitude = objectAltitude
        self.startingAngle = startingAngle

        # describes the nth time this class has been called in the state machine
        self.captureRound = 1
        # describes the # of times pictures have been taken for this state call
        self.picturesTaken = 1
        self.lastTaken = time.clock()
        self.shownInitMessage = False

        # stores the images in the form of a tuple (image, filename)
        self.imageCache = []
Beispiel #2
0
    def __init__(self):

        # getting access to elements in DroneVideo and FlightstatsReciever
        super(DroneMaster, self).__init__()

        self.objectName = "Test Object"
        self.startingAngle = 0
        self.circleRadius = 1  #meters
        self.circlePoints = 8  #numbers of points equally spaced along circle
        self.startTime = 0
        # backpack: 120/-55/95
        # +100 for big objects, +50 for shorter objects. (Modifies how close drone is to object; smaller # > closer)
        # +10 for very small objects.
        self.yOffset = 0
        # -30 for big objects, -15 for shorter objects. (Modifies how close drone is to object; larger # > closer)
        self.ySizeOffset = -30
        # +75 for tall objects or using cube, 0 for shorter objects. (Modifies how high the drone should fly; smaller # > lower
        self.zOffset = 25

        # Seting up a timestamped folder inside Flight_Info that will have the pictures & log of this flight
        self.droneRecordPath = (
            expanduser("~") +
            "/drone_ws/src/SVCL_ardrone_automation/src/Flight_Info/" +
            self.objectName + "_Flight_" +
            datetime.datetime.now().strftime("%m-%d-%Y__%H:%M:%S, %A") + "/")
        if not os.path.exists(self.droneRecordPath):
            os.makedirs(self.droneRecordPath)
        #self.logger = Logger(self.droneRecordPath, "AR Drone Flight")
        #self.logger.Start()

        #import PID and color constants
        self.settingsPath = expanduser(
            "~"
        ) + "/drone_ws/src/SVCL_ardrone_automation/src/resources/calibrater_settings.txt"

        # initalizing the state machine that will handle which algorithms to run at which time;
        # the results of the algorithms will be used to control the drone
        self.stateMachine = StateMachine()

        # drone starts without any machine loaded, so that it can be controlled using the keyboard
        self.currMachine = None

        # i1nitalizing helper objects
        self.pictureManager = PictureManager(self.droneRecordPath)
        self.controller = BasicDroneController("TraceCircle")
        self.startTimer = time.clock()
        # max height of drone, in mm; any higher and the drone will auto-land
        self.maxHeight = 2530
        self.emergency = False
        self.captureRound = 0.5
        self.oldBattery = -1
        self.photoDirective = CapturePhotoDirective(self.droneRecordPath, 30,
                                                    0.014, self.objectName,
                                                    self.circlePoints, 1000, 0)
        self.keySub = rospy.Subscriber('/controller/keyboard', ROSString,
                                       self.keyPress)