Exemplo n.º 1
0
 public void SetFollowMode()
 {
     if (!followee)
     {
         Debug.LogError("ERROR:  Followee needs to be set in the inspector.");
         SetMaintainMode();
     }
     else if (curFollowMode == DroneFollowMode.Constrained && !nextWaypoint)
     {
         Debug.LogError("Error:  nextWaypoint must be set in the Inspector.");
         SetMaintainMode();
     }
     else
     {
         curMode = userMode = DroneMode.Follow;
         if (userFollowMode == DroneFollowMode.Constrained)
         {
             targetBehavior = targetConstrainedBehavior;
         }
         else // (userFollowMode == DroneFollowMode.Direct)
         {
             targetBehavior = targetDirectBehavior;
         }
         targetBehavior.DroneTargetInit(thisScript);
         // Set the target to be the followee (XZ), but at the same height as the drone (Y).
         target          = GeometryClass.TargetSameHeight(transform.position, followee.transform.position);
         effectiveTarget = targetBehavior.GetEffectiveTarget(transform, target, thisScript);
         EnterAdjustLateralState();
     }
 }
Exemplo n.º 2
0
 public void SetLandMode()
 {
     curMode         = userMode = DroneMode.Land;
     targetBehavior  = targetDirectBehavior;
     target          = transform.position;
     target.y        = droneScr.HeightOfGround();
     effectiveTarget = targetBehavior.GetEffectiveTarget(transform, target, thisScript);
     EnterLandingState();
 }
Exemplo n.º 3
0
 public void SetHoverMode()
 {
     curMode         = userMode = DroneMode.Hover;
     targetBehavior  = targetDirectBehavior;
     target          = transform.position;
     target.y        = hoverHeight;
     effectiveTarget = targetBehavior.GetEffectiveTarget(transform, target, thisScript);
     EnterAdjustHeightState();
 }
Exemplo n.º 4
0
    // This is called by FixedUpdate(), but with a quick exit if there is no change.
    private void SetUserMode(bool force = false)
    {
        if (force || (userMode != curMode))
        {
            switch (userMode)
            {
            case DroneMode.Follow:
                SetFollowMode();
                break;

            case DroneMode.Hover:
                SetHoverMode();
                break;

            case DroneMode.Land:
                SetLandMode();
                break;

            case DroneMode.Maintain:
                SetMaintainMode();
                break;

            case DroneMode.Manual:
                SetManualMode();
                break;

            case DroneMode.Patrol:
                SetPatrolMode();
                break;

            default:
                SetMaintainMode();
                break;
            }
        }

        // Adjust the targetBehavior if necessary.
        if (userMode == DroneMode.Follow && (force || userFollowMode != curFollowMode))
        {
            switch (userFollowMode)
            {
            case DroneFollowMode.Constrained:
                targetBehavior = targetConstrainedBehavior;
                curFollowMode  = DroneFollowMode.Constrained;
                break;

            default:
                targetBehavior = targetDirectBehavior;
                curFollowMode  = DroneFollowMode.Direct;
                break;
            }
        }
    }
Exemplo n.º 5
0
    private void InitializeModes()
    {
        // Get all travel scripts.
        travelBehaviorDirect       = ScriptableObject.CreateInstance <DroneTravelDirect>();
        travelBehaviorTurnThenMove = ScriptableObject.CreateInstance <DroneTravelTurnThenMove>();
        travelBehaviorIncremental  = ScriptableObject.CreateInstance <DroneTravelIncremental>();

        // Get all motion scripts.
        motionBehaviorSine   = ScriptableObject.CreateInstance <DroneMotionSinusoidal>();
        motionBehaviorSimple = ScriptableObject.CreateInstance <DroneMotionSimple>();
        motionBehaviorNone   = ScriptableObject.CreateInstance <DroneMotionNone>();

        // Get all targeting scripts.
        targetDirectBehavior      = ScriptableObject.CreateInstance <DroneTargetDirect>();
        targetWaypointBehavior    = ScriptableObject.CreateInstance <DroneTargetWaypoint>();
        targetConstrainedBehavior = ScriptableObject.CreateInstance <DroneTargetConstrained>();
        targetBehavior            = targetDirectBehavior; // Set initial targeting to direct.
    }
Exemplo n.º 6
0
 public void SetPatrolMode()
 {
     if (!nextWaypoint)
     {
         Debug.LogError("Error:  nextWaypoint must be set in the Inspector.");
         SetMaintainMode();
     }
     else
     {
         curMode        = userMode = DroneMode.Patrol;
         targetBehavior = targetWaypointBehavior;
         targetBehavior.DroneTargetInit(thisScript);
         // Find the closest waypoint.  This may be any of the waypoints if the drone has been controlled manually.
         DroneWaypointScript wpScript = nextWaypoint.GetComponent <DroneWaypointScript>();
         nextWaypoint = wpScript.NearestWaypoint(transform.position);
         //prevWaypoint = null;
         target          = nextWaypoint.transform.position;
         effectiveTarget = targetBehavior.GetEffectiveTarget(transform, target, thisScript);
         EnterAdjustHeightState();
     }
 }
Exemplo n.º 7
0
    // This is called by FixedUpdate(), but with a quick exit if there is no change.
    private void SetUserMode(bool force = false)
    {
        if (force || (userMode != curMode))
        {
            switch (userMode)
            {
                case DroneMode.Follow:
                    SetFollowMode();
                    break;
                case DroneMode.Hover:
                    SetHoverMode();
                    break;
                case DroneMode.Land:
                    SetLandMode();
                    break;
                case DroneMode.Maintain:
                    SetMaintainMode();
                    break;
                case DroneMode.Manual:
                    SetManualMode();
                    break;
                case DroneMode.Patrol:
                    SetPatrolMode();
                    break;
                default:
                    SetMaintainMode();
                    break;
            }
        }

        // Adjust the targetBehavior if necessary.
        if (userMode == DroneMode.Follow && (force || userFollowMode != curFollowMode))
        {
            switch (userFollowMode)
            {
                case DroneFollowMode.Constrained:
                    targetBehavior = targetConstrainedBehavior;
                    curFollowMode = DroneFollowMode.Constrained;
                    break;
                default:
                    targetBehavior = targetDirectBehavior;
                    curFollowMode = DroneFollowMode.Direct;
                    break;
            }
        }

    }
Exemplo n.º 8
0
    private void InitializeModes()
    {
        // Get all travel scripts.
        travelBehaviorDirect = ScriptableObject.CreateInstance<DroneTravelDirect>();
        travelBehaviorTurnThenMove = ScriptableObject.CreateInstance<DroneTravelTurnThenMove>();
        travelBehaviorIncremental = ScriptableObject.CreateInstance<DroneTravelIncremental>();

        // Get all motion scripts.
        motionBehaviorSine = ScriptableObject.CreateInstance<DroneMotionSinusoidal>();
        motionBehaviorSimple = ScriptableObject.CreateInstance<DroneMotionSimple>();
        motionBehaviorNone = ScriptableObject.CreateInstance<DroneMotionNone>();

        // Get all targeting scripts.
        targetDirectBehavior = ScriptableObject.CreateInstance<DroneTargetDirect>();
        targetWaypointBehavior = ScriptableObject.CreateInstance<DroneTargetWaypoint>();
        targetConstrainedBehavior = ScriptableObject.CreateInstance<DroneTargetConstrained>();
        targetBehavior = targetDirectBehavior;  // Set initial targeting to direct.

    }
Exemplo n.º 9
0
 public void SetFollowMode()
 {
     if (!followee)
     {
         Debug.LogError("ERROR:  Followee needs to be set in the inspector.");
         SetMaintainMode();
     }
     else if (curFollowMode == DroneFollowMode.Constrained && !nextWaypoint)
     {
         Debug.LogError("Error:  nextWaypoint must be set in the Inspector.");
         SetMaintainMode();
     }
     else
     {
         curMode = userMode = DroneMode.Follow;
         if (userFollowMode == DroneFollowMode.Constrained)
             targetBehavior = targetConstrainedBehavior;
         else // (userFollowMode == DroneFollowMode.Direct)
             targetBehavior = targetDirectBehavior;
         targetBehavior.DroneTargetInit(thisScript);
         // Set the target to be the followee (XZ), but at the same height as the drone (Y).
         target = GeometryClass.TargetSameHeight(transform.position, followee.transform.position);
         effectiveTarget = targetBehavior.GetEffectiveTarget(transform, target, thisScript);
         EnterAdjustLateralState();
     }
 }
Exemplo n.º 10
0
 public void SetPatrolMode()
 {
     if (!nextWaypoint)
     {
         Debug.LogError("Error:  nextWaypoint must be set in the Inspector.");
         SetMaintainMode();
     }
     else
     {
         curMode = userMode = DroneMode.Patrol;
         targetBehavior = targetWaypointBehavior;
         targetBehavior.DroneTargetInit(thisScript);
         // Find the closest waypoint.  This may be any of the waypoints if the drone has been controlled manually.
         DroneWaypointScript wpScript = nextWaypoint.GetComponent<DroneWaypointScript>();
         nextWaypoint = wpScript.NearestWaypoint(transform.position);
         //prevWaypoint = null;
         target = nextWaypoint.transform.position;
         effectiveTarget = targetBehavior.GetEffectiveTarget(transform, target, thisScript);
         EnterAdjustHeightState();
     }
 }
Exemplo n.º 11
0
    public void SetManualMode()
    {
        // REALSENSE 

        /* Initialize a PXCMSenseManager instance */
        sm = PXCMSenseManager.CreateInstance();
        if (sm == null)
            Debug.LogError("SenseManager Initialization Failed");

        /* Enable hand tracking and retrieve an hand module instance to configure */
        sts = sm.EnableHand();
        handAnalyzer = sm.QueryHand();
        if (sts != pxcmStatus.PXCM_STATUS_NO_ERROR)
            Debug.LogError("PXCSenseManager.EnableHand: " + sts);

        /* Initialize the execution pipeline */
        sts = sm.Init();
        if (sts != pxcmStatus.PXCM_STATUS_NO_ERROR)
            Debug.LogError("PXCSenseManager.Init: " + sts);

        /* Retrieve the the DataSmoothing instance */
        sm.QuerySession().CreateImpl<PXCMSmoother>(out smoother);

        /* Create a 3D Weighted algorithm */
        smoother3D = new PXCMSmoother.Smoother3D[MaxHands][];

        /* Configure a hand - Enable Gestures and Alerts */
        PXCMHandConfiguration hcfg = handAnalyzer.CreateActiveConfiguration();
        if (hcfg != null)
        {
            hcfg.EnableAllGestures();
            hcfg.EnableAlert(PXCMHandData.AlertType.ALERT_HAND_NOT_DETECTED);
            hcfg.SubscribeGesture(OnFiredGesture);
            hcfg.ApplyChanges();
            hcfg.Dispose();
        }



      //  handAnalyzer = sm.QueryHand();

        //////

        curMode = userMode = DroneMode.Manual;
        targetBehavior = targetDirectBehavior;
        EnterFreeMovementState();
    }
Exemplo n.º 12
0
 public void SetLandMode()
 {
     curMode = userMode = DroneMode.Land;
     targetBehavior = targetDirectBehavior;
     target = transform.position;
     target.y = droneScr.HeightOfGround();
     effectiveTarget = targetBehavior.GetEffectiveTarget(transform, target, thisScript);
     EnterLandingState();
 }
Exemplo n.º 13
0
 public void SetHoverMode()
 {
     curMode = userMode = DroneMode.Hover;
     targetBehavior = targetDirectBehavior;
     target = transform.position;
     target.y = hoverHeight;
     effectiveTarget = targetBehavior.GetEffectiveTarget(transform, target, thisScript);
     EnterAdjustHeightState();
 }
Exemplo n.º 14
0
 public void SetMaintainMode()
 {
     curMode = userMode = DroneMode.Maintain;
     targetBehavior = targetDirectBehavior;
     EnterAtDestinationState();
 }
Exemplo n.º 15
0
 public void SetManualMode()
 {
     curMode        = userMode = DroneMode.Manual;
     targetBehavior = targetDirectBehavior;
     EnterFreeMovementState();
 }
Exemplo n.º 16
0
 public void SetMaintainMode()
 {
     curMode        = userMode = DroneMode.Maintain;
     targetBehavior = targetDirectBehavior;
     EnterAtDestinationState();
 }