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(); } }
public void SetLandMode() { curMode = userMode = DroneMode.Land; targetBehavior = targetDirectBehavior; target = transform.position; target.y = droneScr.HeightOfGround(); effectiveTarget = targetBehavior.GetEffectiveTarget(transform, target, thisScript); EnterLandingState(); }
public void SetHoverMode() { curMode = userMode = DroneMode.Hover; targetBehavior = targetDirectBehavior; target = transform.position; target.y = hoverHeight; effectiveTarget = targetBehavior.GetEffectiveTarget(transform, target, thisScript); EnterAdjustHeightState(); }
// 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; } } }
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. }
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(); } }
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. }
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(); } }
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(); } }
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(); }
public void SetMaintainMode() { curMode = userMode = DroneMode.Maintain; targetBehavior = targetDirectBehavior; EnterAtDestinationState(); }
public void SetManualMode() { curMode = userMode = DroneMode.Manual; targetBehavior = targetDirectBehavior; EnterFreeMovementState(); }