public override void StartCommand(DHUI_FlightController _flightController, Transform _leader, Transform _drone)
        {
            base.StartCommand(_flightController, _leader, _drone);

            startPosition = _leader.position;
            startRotation = _leader.rotation;

            // If we are landing on the floor, the targeted positions are the given position projected onto the floor.
            if (floorLanding)
            {
                targetPosition.y = _flightController.GetFloorHeight();
            }

            touchDownHeight = targetPosition.y + _flightController.GetTriggerHeight_TouchDown();
            shutOffHeight   = targetPosition.y + flightController.GetTriggerHeight_ShutOff();


            target_TouchDownTrigger.rotation   = targetRotation;
            target_TouchDownTrigger.position   = targetPosition;
            target_TouchDownTrigger.position.y = touchDownHeight;

            time = Vector3.Distance(startPosition, target_TouchDownTrigger.position) / landingSpeed;

            currentState = LandingState.MoveTo;
        }
コード例 #2
0
        public override void StartCommand(DHUI_FlightController _flightController, Transform _leader, Transform _drone)
        {
            base.StartCommand(_flightController, _leader, _drone);

            targetPosition = leader.position;
            targetRotation = leader.rotation;
        }
        /// <summary>
        /// When this command is started, it gets the Drones last takeOff pose and sets it as the landing target.
        /// </summary>
        public override void StartCommand(DHUI_FlightController _flightController, Transform _leader, Transform _drone)
        {
            Pose startPose = _flightController.GetDroneStartingPose();

            targetPosition = startPose.position;
            targetRotation = startPose.rotation;

            base.StartCommand(_flightController, _leader, _drone);
        }
コード例 #4
0
        /// <summary>
        /// Starts the current Command and sets up necessary members.
        /// </summary>
        /// <param name="_flightController">The FlightController-instance handling the commands.</param>
        /// <param name="_leader">The leader-object we control.</param>
        /// <param name="_drone">The drone-object.</param>
        public virtual void StartCommand(DHUI_FlightController _flightController, Transform _leader, Transform _drone)
        {
            flightController = _flightController;
            leader           = _leader;
            drone            = _drone;
            startTime        = Time.time;

            SetFlightModeAtCommandStart();
        }
 /// <summary>
 /// When this Command is started, we set the landing pose to be the current pose (of leader or drone).
 /// </summary>
 public override void StartCommand(DHUI_FlightController _flightController, Transform _leader, Transform _drone)
 {
     if (landAtDroneInsteadOfLeader)
     {
         _leader.position = _drone.position;
         _leader.rotation = _drone.rotation;
     }
     targetPosition = _leader.position;
     targetRotation = _leader.rotation;
     base.StartCommand(_flightController, _leader, _drone);
 }
コード例 #6
0
        public override void StartCommand(DHUI_FlightController _flightController, Transform _leader, Transform _drone)
        {
            base.StartCommand(_flightController, _leader, _drone);

            startPosition = leader.position;
            startRotation = leader.rotation;

            if (!manualTimeSet)
            {
                if (speed <= 0)
                {
                    time = 0;
                }
                else
                {
                    time = Vector3.Distance(startPosition, targetPosition) / speed;
                }
            }
        }
 public override void StartCommand(DHUI_FlightController _flightController, Transform _leader, Transform _drone)
 {
     base.StartCommand(_flightController, _leader, _drone);
 }
コード例 #8
0
        /// <summary>
        /// On Start: Check if everything necessary is set up correctly.
        /// </summary>
        private void Start()
        {
            if (_target == null)
            {
                DHUI_FlightController flightController = FindObjectOfType <DHUI_FlightController>();
                if (flightController != null)
                {
                    _target = flightController.transform;
                    Debug.Log("<b>DHUI</b> | DroneController | No Transform for Target was set in Inspector -> Defaulting to transform of DHUI_FlightController. (\"" + _target.gameObject.name + "\")");
                }
                else
                {
                    Debug.LogError("<b>DHUI</b> | DroneController | No Transform for Target was set in Inspector and no DHUI_FlightController could be found in Scene. Please set a Target in the Unity Inspector.");
                }
            }
            if (_virtualDrone == null)
            {
                _virtualDrone = transform;
                Debug.Log("<b>DHUI</b> | DroneController | No Transform for VirtualDrone was set in Inspector -> Defaulting to this transform. (\"" + gameObject.name + "\")");
            }
            if (_droneTracker == null)
            {
                _droneTracker = FindObjectOfType <DHUI_DroneTracking_Base>();
                if (_droneTracker != null)
                {
                    Debug.Log("<b>DHUI</b> | DroneController | No DHUI_DroneTracking_Base was set in Inspector -> Found one in the scene on \"" + _droneTracker.gameObject.name + "\".");
                }
                else
                {
                    Debug.LogError("<b>DHUI</b> | DroneController | No DHUI_DroneTracking_Base was set in Inspector and none was found in the scene.");
                }
            }
            if (_PIDCalculator == null)
            {
                _PIDCalculator = FindObjectOfType <DHUI_PIDCalculation>();
                if (_PIDCalculator != null)
                {
                    Debug.Log("<b>DHUI</b> | DroneController | No DHUI_PIDCalculation was set in Inspector -> Found one in the scene on \"" + _PIDCalculator.gameObject.name + "\".");
                }
                else
                {
                    Debug.LogError("<b>DHUI</b> | DroneController | No DHUI_PIDCalculation was set in Inspector and none was found in the scene.");
                }
            }
            if (_output == null)
            {
                _output = FindObjectOfType <DHUI_Output>();
                if (_output != null)
                {
                    Debug.Log("<b>DHUI</b> | DroneController | No DHUI_Output was set in Inspector -> Found one in the scene on \"" + _output.gameObject.name + "\".");
                }
                else
                {
                    Debug.LogError("<b>DHUI</b> | DroneController | No DHUI_Output was set in Inspector and none was found in the scene.");
                }
            }
            if (_emergencyInputs == null)
            {
                _emergencyInputs = FindObjectOfType <DHUI_EmergencyInput_Base>();
                if (_emergencyInputs != null)
                {
                    Debug.Log("<b>DHUI</b> | DroneController | No DHUI_EmergencyInput was set in Inspector -> Found one in the scene on \"" + _emergencyInputs.gameObject.name + "\".");
                }
                else
                {
                    Debug.LogError("<b>DHUI</b> | DroneController | No DHUI_EmergencyInput_Base was set in Inspector and none was found in the scene.");
                }
            }
            _emergencyInputs.Setup(this);


            if (_target != null && _droneTracker != null && _output != null && _PIDCalculator != null && _emergencyInputs != null)
            {
                setupCorrect = true;
            }
        }