/// <summary> /// Starts the task. Called when the operator clicks the Go button. /// </summary> /// <param name="command">The movement command (velocity, acceleration)</param> /// <param name="duration">The duration of movement</param> internal void Go(MotionCommand command, double duration) { logger.Debug("Enter: Go(MotionCommand, double)"); if (command.innerPosition == Hulk.ANY_MOTION) { // Moving with given velocity/acceleration and (optionally) duration. logger.Info("Starting rotation task with given velocity, acceleration, and duration."); Hulk.SetCommandType(Hulk.CommandType.Velocity); if (duration == -1.0) { stopTime = DateTime.MinValue; } else { stopTime = DateTime.Now.AddSeconds(duration); } Hulk.SetCommand(command); Hulk.StartTask(); } else { // Moving to the given position. logger.Info("Starting rotation task to given position."); Hulk.SetCommandType(Hulk.CommandType.ModulusPosition); Hulk.SetCommand(command); Hulk.StartDefinedMove(false); } }
/// <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> /// Starts the task. Called when the operator clicks the Go button. /// </summary> /// <param name="command">The movement command (velocity, acceleration)</param> /// <param name="duration">The duration of movement</param> internal void Go(MotionCommand command, double duration) { logger.Debug("Enter: Go(MotionCommand, double)"); if (command.innerPosition == Hulk.ANY_MOTION) { // Moving with given velocity/acceleration and (optionally) duration. logger.Info("Starting UnrealLandscapesDemoTask with given duration."); Hulk.SetCommandType(Hulk.CommandType.Velocity); Hulk.SetCommand(command); Hulk.StartTask(); } else { // Moving to the given position. logger.Info("Starting UnrealLandscapesDemoTask to given position."); Hulk.SetCommandType(Hulk.CommandType.ModulusPosition); Hulk.SetCommand(command); Hulk.StartDefinedMove(false); } }
/// <summary> /// Starts the task. Called when the operator clicks the Go button. /// </summary> /// <param name="stateInfo">Not used. Here so that the method can be called by a worker thread.</param> internal void Go(Object stateInfo) { MotionCommand moveCommand; logger.Debug("Enter: Go(Object)"); Trials.CurrentTrialIndex = 0; trial = Trials.CurrentTrial; SendPlottingAxesCenterChange(); queueResetEndSound = false; StartLogging(); // Begin moving to the starting location of the first trial logger.Info("Moving to location for beginning of balance trial: " + trial.TrialNumber); trial.MovingDirectionOfBalance.yaw = trial.DirectionOfBalance.yaw; trial.MovingDirectionOfBalance.pitch = trial.DirectionOfBalance.pitch; trial.MovingDirectionOfBalance.roll = trial.DirectionOfBalance.roll; trial.TrialStatus = Trial.Status.Moving; trial.PlayMoveSound(); moveCommand = new MotionCommand { innerVelocity = Hulk.NORMAL_VELOCITY, outerVelocity = Hulk.NORMAL_VELOCITY, innerAcceleration = Hulk.NORMAL_ACCELERATION, outerAcceleration = Hulk.NORMAL_ACCELERATION }; if (trial.BeginAt == null) { moveCommand.innerPosition = (Hulk.InnerAxis == Hulk.Axis.Roll) ? trial.DirectionOfBalance.roll : trial.DirectionOfBalance.yaw; moveCommand.outerPosition = trial.DirectionOfBalance.pitch; } else { moveCommand.innerPosition = (Hulk.InnerAxis == Hulk.Axis.Roll) ? trial.BeginAt.roll : trial.BeginAt.yaw; moveCommand.outerPosition = trial.BeginAt.pitch; } Hulk.SetCommandType(Hulk.CommandType.ModulusPosition); Hulk.SetCommand(moveCommand); Hulk.StartDefinedMove(true); }
/// <summary> /// Starts the task. Called when the operator clicks the Go button. /// </summary> /// <param name="functionFilename">The filename of the CSV file containing the forcing function</param> /// <param name="selectedAmplitude">The amplitude of the forcing function</param> /// <param name="selectedOffset">???</param> internal void Go(string functionFilename, double selectedAmplitude, double selectedOffset) { MotionCommand newMotionCommand; logger.Debug("Enter: Go()"); logger.Info("Starting delay measurement task."); amplitude = selectedAmplitude; // Move to the start location Hulk.SetCommandType(Hulk.CommandType.ModulusPosition); newMotionCommand = new MotionCommand(); newMotionCommand.innerPosition = selectedOffset; newMotionCommand.outerPosition = 0.0; newMotionCommand.outerVelocity = Hulk.NORMAL_VELOCITY; newMotionCommand.innerVelocity = Hulk.NORMAL_VELOCITY; newMotionCommand.outerAcceleration = Hulk.NORMAL_ACCELERATION; newMotionCommand.innerAcceleration = Hulk.NORMAL_ACCELERATION; Hulk.SetCommand(newMotionCommand); Hulk.StartDefinedMove(false); while (Hulk.SystemStatus != Hulk.Status.Idling) { Thread.Sleep(100); } // Prepare for trial DataLogger.AcquireDataLog(Path.GetFileNameWithoutExtension(functionFilename) + "_Amplitude" + amplitude.ToString("F1") + "_Offset" + selectedOffset.ToString("F1") + "_data.csv", dataLogHeader); runningStopwatch.Reset(); runningStopwatch.Start(); // Start task Hulk.SetCommandType(Hulk.CommandType.Velocity); Hulk.StartTask(); }