Esempio n. 1
0
    def setUp(self):
        #Create a mock vehicle object
        vehicle = mock.create_autospec(Vehicle)

        #Create a mock shotManager object
        shotmgr = mock.create_autospec(ShotManager)
        shotmgr.rcMgr = Mock(specs=['remapper'])

        #Run the shot constructor
        self.shot = follow.FollowShot(vehicle, shotmgr)

        #Mock Methods
        self.shot.updateMountStatus = Mock()
        self.shot.initLookAtMeController = Mock()
        self.shot.initOrbitController = Mock()
        self.shot.initLeashController = Mock()
        self.shot.initFreeLookController = Mock()
        self.shot.updateMountStatus = Mock()
        self.shot.updateAppOptions = Mock()
        self.shot.setButtonMappings = Mock()

        #Setup Attributes
        self.shot.followState = FOLLOW_WAIT
        self.shot.rawROI = location_helpers.newLocationFromAzimuthAndDistance(
            self.shot.vehicle.location.global_relative_frame,
            self.ARBITRARY_HEADING, self.DISTANCE)
Esempio n. 2
0
    def setUp(self):
        #Create a mock vehicle object
        vehicle = mock.create_autospec(Vehicle)

        #Create a mock shotManager object
        shotmgr = mock.create_autospec(ShotManager)
        shotmgr.rcMgr = Mock(specs=['remapper'])
        shotmgr.buttonManager = Mock()
        #Run the shot constructor
        self.shot = follow.FollowShot(vehicle, shotmgr)

        # rawROI
        self.ROI = LocationGlobalRelative(37.873168, -122.302062,
                                          0)  #sample ROI, used throughout
        self.shot.rawROI = self.ROI

        # mock methods
        self.shot.initState = Mock()
        location_helpers.calcYawPitchFromLocations = Mock()
        location_helpers.calcYawPitchFromLocations.return_value = (0.0, 0.0)

        #roiDeltaTime
        self.shot.roiDeltaTime = 0.04  # 25Hz (guess)

        #init vars
        self.shot.roiVelocity = Vector3()
Esempio n. 3
0
    def setUp(self):
        #Create a mock vehicle object
        vehicle = mock.create_autospec(Vehicle)

        #Create a mock shotManager object
        shotmgr = mock.create_autospec(ShotManager)
        shotmgr.rcMgr = Mock(specs=['remapper'])

        #Run the shot constructor
        self.shot = follow.FollowShot(vehicle, shotmgr)
Esempio n. 4
0
    def setUp(self):
        #Create a mock vehicle object
        vehicle = mock.create_autospec(Vehicle)
        vehicle.attitude.yaw = math.radians(30)
        vehicle.mount_status[0] = -45

        #Create a mock shotManager object
        shotmgr = mock.create_autospec(ShotManager)
        shotmgr.rcMgr = Mock(specs=['remapper'])
        shotmgr.getParam.return_value = 0  # so mock doesn't do lazy binds

        #Run the shot constructor
        self.shot = follow.FollowShot(vehicle, shotmgr)
Esempio n. 5
0
    def setUp(self):

        #Create a mock vehicle object
        vehicle = mock.create_autospec(Vehicle)

        #Create a mock shotManager object
        shotmgr = mock.create_autospec(ShotManager)
        shotmgr.rcMgr = Mock(specs=['remapper'])

        #Run the shot constructor
        self.shot = follow.FollowShot(vehicle, shotmgr)

        #roi
        self.tempROI = LocationGlobalRelative(37.873168, -122.302062, 0)
Esempio n. 6
0
    def setUp(self):

        #Create a mock vehicle object
        vehicle = mock.create_autospec(Vehicle)

        #Create a mock shotManager object
        shotmgr = mock.create_autospec(ShotManager)
        shotmgr.rcMgr = Mock(specs=['remapper'])

        #Run the shot constructor
        self.shot = follow.FollowShot(vehicle, shotmgr)

        self.shot.camYaw = float(1.111333)
        self.shot.camPitch = float(2.55556666)
        self.shot.camDir = 1
Esempio n. 7
0
    def setUp(self):
        #Create a mock vehicle object
        vehicle = mock.create_autospec(Vehicle)

        #Create a mock shotManager object
        shotmgr = mock.create_autospec(ShotManager)
        shotmgr.rcMgr = Mock(specs=['remapper'])

        #Run the shot constructor
        self.shot = follow.FollowShot(vehicle, shotmgr)

        sampleData = struct.pack('<IIddf', app_packet.SOLO_MESSAGE_LOCATION,
                                 20, 37.873168, -122.302062, 0)
        self.shot.socket.recvfrom = Mock(
            side_effect=[(sampleData, '127.0.0.1'), socket.timeout])
Esempio n. 8
0
    def setUp(self):
        #Create a mock vehicle object
        vehicle = mock.create_autospec(Vehicle)

        #Create a mock shotManager object
        shotmgr = mock.create_autospec(ShotManager)
        shotmgr.rcMgr = Mock(specs=['remapper'])

        #Run the shot constructor
        self.shot = follow.FollowShot(vehicle, shotmgr)

        #Neutral sticks
        throttle = 0.0
        roll = 0.0
        pitch = 0.0
        yaw = 0.0
        self.channels = [throttle, roll, pitch, yaw, 0.0, 0.0, 0.0, 0.0]
Esempio n. 9
0
    def setUp(self):
        #Create a mock vehicle object
        vehicle = mock.create_autospec(Vehicle)

        #Create a mock shotManager object
        shotmgr = mock.create_autospec(ShotManager)
        shotmgr.rcMgr = Mock(specs=['remapper'])

        #Run the shot constructor
        self.shot = follow.FollowShot(vehicle, shotmgr)

        # mock methods
        location_helpers.getDistanceFromPoints = Mock()
        location_helpers.calcAzimuthFromPoints = Mock()

        location_helpers.getDistanceFromPoints.return_value = 10.0
        location_helpers.calcAzimuthFromPoints.return_value = 0.0
Esempio n. 10
0
    def setUp(self):
        #Create a mock vehicle object
        vehicle = mock.create_autospec(Vehicle)

        #Create a mock shotManager object
        shotmgr = mock.create_autospec(ShotManager)
        shotmgr.rcMgr = Mock(specs=['remapper'])
        shotmgr.getParam.return_value = 0  # so mock doesn't do lazy binds

        #Run the shot constructor
        self.shot = follow.FollowShot(vehicle, shotmgr)

        # Mock the functions
        self.shot.checkSocket = Mock()
        self.shot.filterROI = Mock()

        # Mock Attributes
        self.shot.rawROI = LocationGlobalRelative(37.873168, -122.302062, 0)

        self.shot.filteredROI = LocationGlobalRelative(37.873168, -122.302062,
                                                       0)

        self.shot.roiVelocity = Vector3(0, 0, 0)

        self.shot.camYaw = 0.0
        # Mock the pointing functions
        self.shot.handleFreeLookPointing = Mock()
        self.shot.handleFollowPointing = Mock()
        self.shot.handleLookAtMePointing = Mock()

        #Mock the pathHandler object
        self.shot.pathHandler = mock.create_autospec(pathHandler.PathHandler)
        self.shot.pathHandler.cruiseSpeed = 0

        #Mock the pathController object
        self.shot.pathController = mock.create_autospec(OrbitController)
        self.shot.pathController.move.return_value = (LocationGlobalRelative(
            37.873168, -122.302062, 0), Vector3(1, 1, 1))

        #Neutral sticks
        throttle = 0.0
        roll = 0.0
        pitch = 0.0
        yaw = 0.0
        self.channels = [throttle, roll, pitch, yaw, 0.0, 0.0, 0.0, 0.0]
Esempio n. 11
0
    def setUp(self):
        #Create a mock vehicle object
        vehicle = mock.create_autospec(Vehicle)

        #Create a mock shotManager object
        shotmgr = mock.create_autospec(ShotManager)
        shotmgr.rcMgr = Mock(specs=['remapper'])

        #Run the shot constructor
        self.shot = follow.FollowShot(vehicle, shotmgr)

        self.shot.camYaw = 0  #init to zero. Can be permuted below.
        #Neutral sticks, unless permuted in the methods below
        throttle = 0.0
        roll = 0.0
        pitch = 0.0
        yaw = 0.0
        self.channels = [throttle, roll, pitch, yaw, 0.0, 0.0, 0.0, 0.0]
Esempio n. 12
0
    def setUp(self):
        #Create a mock vehicle object
        vehicle = mock.create_autospec(Vehicle)

        #Create a mock shotManager object
        shotmgr = mock.create_autospec(ShotManager)
        shotmgr.rcMgr = Mock(specs=['remapper'])

        #Run the shot constructor
        self.shot = follow.FollowShot(vehicle, shotmgr)

        self.shot.pathHandler = mock.create_autospec(pathHandler.PathHandler)
        self.shot.pathHandler.cruiseSpeed = 0

        #Mock the pathController object
        self.shot.followState = FOLLOW_ORBIT
        self.shot.pathController = mock.create_autospec(OrbitController)

        self.shot.ROIAltitudeOffset = 0.0

        self.shot.ROIAltitudeOffset = 0.0
Esempio n. 13
0
    def triggerShot(self, shot):
        # invalid shot!
        if shot not in shots.SHOT_NAMES:
            logger.log(
                "[triggerShot]: Error, trying to trigger an invalid shot! %d" %
                (shot))
            return

        self.currentShot = shot
        """
        ok, this is hacky.
        Because of the delay in mode reporting from pixhawk,
        If we change shots while we're in guided to another shot,
        our shot auto-exit protection will kick in and boot us out
        of our new shot.  This prevents that by making sure we're
        not in guided so that protection doesn't kick in.
        """
        if self.lastMode == "GUIDED":
            self.lastMode = "changing"
        if self.currentShot == shots.APP_SHOT_NONE:
            del self.curController
            self.curController = None
            self.enableManualGimbalControl()
            # stop any stick remapping
            self.remapper.enableRemapping(False)
            if self.vehicle.mode.name == "GUIDED":
                self.vehicle.mode = VehicleMode("LOITER")
                logger.log(
                    "setting vehicle to loiter because we're exiting a shot")
            else:
                logger.log("Didn't set loiter because mode was %s" %
                           (self.vehicle.mode.name))
            # set a decent speed so RTLs don't go super slowly
            # this is needed because nothing resets the DO_CHANGE_SPEED from the shots
            speed = self.getParam("WPNAV_SPEED",
                                  DEFAULT_WPNAV_SPEED_VALUE) / 100.0
            msg = self.vehicle.message_factory.command_long_encode(
                0,
                1,  # target system, target component
                mavutil.mavlink.MAV_CMD_DO_CHANGE_SPEED,  # frame
                0,  # confirmation
                1,
                speed,
                -1,  # params 1-3
                0.0,
                0.0,
                0.0,
                0.0)  # params 4-7 (not used)

            # send command to vehicle
            self.vehicle.send_mavlink(msg)
            self.vehicle.flush()

        elif self.currentShot == shots.APP_SHOT_SELFIE:
            self.initStreamRates()
            self.curController = selfie.SelfieShot(self.vehicle, self)
        elif self.currentShot == shots.APP_SHOT_ORBIT:
            self.initStreamRates()
            self.curController = orbit.OrbitShot(self.vehicle, self)
        elif self.currentShot == shots.APP_SHOT_CABLECAM:
            self.initStreamRates()
            self.curController = cable_cam.CableCamShot(self.vehicle, self)
        elif self.currentShot == shots.APP_SHOT_FOLLOW:
            self.initStreamRates()
            self.curController = follow.FollowShot(self.vehicle, self)
        elif self.currentShot == shots.APP_SHOT_MULTIPOINT:
            self.initStreamRates()
            self.curController = multipoint.MultipointShot(self.vehicle, self)
        elif self.currentShot == shots.APP_SHOT_PANO:
            self.initStreamRates()
            self.curController = pano.PanoShot(self.vehicle, self)
        #send back a response
        packet = struct.pack('<IIi', app_packet.SOLO_MESSAGE_GET_CURRENT_SHOT,
                             4, shot)
        self.sendPacket(packet)

        self.buttonManager.setButtonMappings()
        self.buttonManager.setArtooShot(shot)

        logger.log("[triggerShot]: Entered shot: %s" % shots.SHOT_NAMES[shot])