/// <summary>
        /// Starts the task. Called when the operator clicks the Go button.
        /// </summary>
        /// <param name="sender">Not used</param>
        /// <param name="e">Not used</param>
        internal void Go()
        {
            MotionCommand newMotionCommand;

            logger.Debug("Enter: Go()");

            Hulk.Halt();

            startOuterPosition = Hulk.CurrentMotion.outerPosition;
            startInnerPosition = Hulk.CurrentMotion.innerPosition;

            logger.Info("Starting position task with center at OUTER=" + startOuterPosition.ToString("F1") +
                        " INNER=" + startInnerPosition.ToString("F1") + ".");

            Hulk.SetCommandType(Hulk.CommandType.ModulusPosition);

            newMotionCommand = new MotionCommand {
                outerVelocity     = POSITIONING_VELOCITY,
                innerVelocity     = POSITIONING_VELOCITY,
                outerAcceleration = POSITIONING_ACCELERATION,
                innerAcceleration = POSITIONING_ACCELERATION
            };

            Hulk.SetCommand(newMotionCommand);
            Hulk.StartTask();
        }
        /// <summary>
        /// Called by the control loop when the participant exceeds the max allowable angle from the DOB.
        /// </summary>
        private void HandleResetting()
        {
            MotionCommand moveCommand;

            // Restart with balancing once reset is complete
            trial.TrialStatus = Trial.Status.Moving;

            Hulk.Halt();

            trial.PlayResetStartSound();

            queueResetEndSound = true;

            // Move back to the DOB

            moveCommand = new MotionCommand {
                innerVelocity     = Hulk.NORMAL_VELOCITY,
                outerVelocity     = Hulk.NORMAL_VELOCITY,
                innerAcceleration = Hulk.NORMAL_ACCELERATION,
                outerAcceleration = Hulk.NORMAL_ACCELERATION
            };

            // calculate random offset from DOB to return the chair to

            double dobOffsetY = _calculateDOBOffset(trial.RestartDOBOffsetMinYaw, trial.RestartDOBOffsetMaxYaw);
            double dobOffsetP = _calculateDOBOffset(trial.RestartDOBOffsetMinPitch, trial.RestartDOBOffsetMaxPitch);
            double dobOffsetR = _calculateDOBOffset(trial.RestartDOBOffsetMinRoll, trial.RestartDOBOffsetMaxRoll);

            if (Math.Abs(dobOffsetY) > trial.MaxAngle)
            {
                logger.Warn("The calculated random offset for the DOB yaw return position is outside of the maximum angle specified for this trial. Using a random offset of 0!");
                dobOffsetY = 0;
            }
            if (Math.Abs(dobOffsetP) > trial.MaxAngle)
            {
                logger.Warn("The calculated random offset for the DOB pitch return position is outside of the maximum angle specified for this trial. Using a random offset of 0!");
                dobOffsetP = 0;
            }
            if (Math.Abs(dobOffsetR) > trial.MaxAngle)
            {
                logger.Warn("The calculated random offset for the DOB roll return position is outside of the maximum angle specified for this trial. Using a random offset of 0!");
                dobOffsetR = 0;
            }

            double resetDobY = trial.MovingDirectionOfBalance.yaw + dobOffsetY;
            double resetDobP = trial.MovingDirectionOfBalance.pitch + dobOffsetP;
            double resetDobR = trial.MovingDirectionOfBalance.roll + dobOffsetR;

            moveCommand.innerPosition = (Hulk.InnerAxis == Hulk.Axis.Roll) ? resetDobR : resetDobY;
            moveCommand.outerPosition = resetDobP;

            Hulk.SetCommandType(Hulk.CommandType.ModulusPosition);
            Hulk.SetCommand(moveCommand);

            Hulk.StartDefinedMove(true);

            logger.Info("Participant lost control. Resetting to orientation: yaw " + resetDobY.ToString("0.##") + " pitch " + resetDobP.ToString("0.##") + " roll " + resetDobR.ToString("0.##"));

            _sendCommandStopTrial();
        }
        /// <summary>
        /// Called from the main control loop whenever the task should be stopped.
        /// DO NOT call this method directly from BalanceTask or BalancePanel.
        /// </summary>
        public override void StopTask()
        {
            logger.Debug("Enter: StopTask()");

            if (trial.TrialStatus == Trial.Status.Complete)
            {
                logger.Info("Completed set of balance trials.");
            }
            else
            {
                logger.Info("Aborting balance trial: " + trial.TrialNumber);
                trial.TrialStatus = Trial.Status.Complete;
            }

            DataLogger.CloseDataLog();

            Hulk.Halt();

            ((BalanceWithHmdPanel)panel).CleanUp();

            logStopwatch   = null;
            trialStopwatch = null;

            _sendCommandStopTrial();
            _sendCommandFadeOut();
        }
Пример #4
0
        /// <summary>
        /// Called from the main control loop whenever the task should be stopped.
        /// DO NOT call this method directly from RotationTask or RotationPanel.
        /// </summary>
        public override void StopTask()
        {
            logger.Debug("Enter: StopTask()");

            logger.Info("Stopping rotation task.");

            Hulk.Halt();

            ((RotationPanel)panel).CleanUp();
        }
Пример #5
0
        /// <summary>
        /// Called from the main control loop whenever the task should be stopped.
        /// DO NOT call this method directly from PassiveMovementTask or PassiveMovementPanel.
        /// </summary>
        public override void StopTask()
        {
            logger.Debug("Enter: StopTask()");

            logger.Info("Stopping passive movement task.");

            Hulk.Halt();

            ((PassiveMovementPanel)panel).CleanUp();
            runningStopwatch.Stop();
            DataLogger.CloseDataLog();
        }