/// <summary> /// Called from the main control loop whenever the task is running. /// DO NOT call this method directly from DelayMeasurementTask or DelayMeasurementPanel. /// </summary> public override void ContinueTask() { ControlInput controlInput; FunctionTimepoint function; MotionCommand command; double elapsedTime; elapsedTime = runningStopwatch.ElapsedMilliseconds * 1.0 / 1000; function = ForcingFunctions.GetForcingFunction(elapsedTime); controlInput = (Hulk.InnerAxis == Hulk.Axis.Roll) ? new ControlInput(function.Input.roll, function.Input.pitch, false, false) : new ControlInput(function.Input.yaw, function.Input.pitch, false, false); command = new MotionCommand(); command.innerVelocity = controlInput.x * amplitude; command.outerVelocity = controlInput.y * amplitude; command.innerAcceleration = 300; command.outerAcceleration = 300; Hulk.SetCommand(command); Hulk.ContinueTask(); LogData(elapsedTime, Hulk.CurrentMotion, command, controlInput); if (elapsedTime >= ForcingFunctions.GetForcingFunctionMaxTime()) { Hulk.StopTask(); return; } }
/// <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> /// Starts the task. Called when the operator clicks the Go button. /// </summary> internal void Go() { MotionCommand newMotionCommand; logger.Debug("Enter: Go()"); logger.Info("Starting passive movement task."); previousTrigger = false; numClicks = 0; lastPositionOuter = Hulk.CurrentMotion.outerPosition; lastPositionInner = Hulk.CurrentMotion.innerPosition; currentTrialNumber = Recordings.GetFirstTrialNumber(); DataLogger.AcquireDataLog(String.Format("recording{0:000}.csv", currentTrialNumber), dataLogHeader); runningStopwatch.Reset(); runningStopwatch.Start(); 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(); }
/// <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 from the main control loop whenever the task is running. /// DO NOT call this method directly from BalanceTask or BalancePanel. /// </summary> public override void ContinueTask() { if (!InputController.IsJoystickConnected) { logger.Warn("No joystick found. Stopping balance task."); Hulk.StopTask(); return; } switch (trial.TrialStatus) { case Trial.Status.Moving: HandleStateMoving(); break; case Trial.Status.BalancingDOBChanging: // DO NOT add a break here case Trial.Status.BalancingDOBStable: HandleStateBalancing(); break; case Trial.Status.Resetting: HandleResetting(); break; case Trial.Status.Complete: HandleStateComplete(); break; } }
/// <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> /// Gradually stops any rotation of the HULK, using the currently specified /// deceleration parameters. Called when the operator clicks the Soft Stop button. /// </summary> /// <param name="stateInfo">Not used. Here so that the method can be called by a worker thread.</param> internal void SoftStop(Object stateInfo) { MotionCommand newCommand; logger.Debug("Enter: SoftStop(Object)"); logger.Info("Decelerating."); Hulk.SetCommandType(Hulk.CommandType.Velocity); newCommand = new MotionCommand(); newCommand.innerVelocity = 0; newCommand.outerVelocity = 0; newCommand.innerAcceleration = Hulk.NORMAL_ACCELERATION; newCommand.outerAcceleration = Hulk.NORMAL_ACCELERATION; Hulk.SetCommand(newCommand); while ((Hulk.CurrentMotion.innerVelocity > 0.1) || (Hulk.CurrentMotion.outerVelocity > 0.1)) { Thread.Sleep(100); } Hulk.StopTask(); }
/// <summary> /// Stops the task. /// This method should ONLY contain a call to Hulk.StopTask(). /// Any other post-task cleanup should be handled in DelayMeasurementTask.StopTask() or DelayMeasurementPanel.CleanUp(). /// </summary> /// <param name="sender">Not used</param> /// <param name="e">Not used</param> private void stopButton_Click(object sender, EventArgs e) { logger.Debug("Enter: stopButton_Click(object, EventArgs)"); if (Hulk.CheckCommandAllowed()) { Hulk.StopTask(); } }
/// <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(); }
/// <summary> /// Starts the next trial. /// </summary> /// <param name="sender">Not used</param> /// <param name="e">Not used</param> private void goButton_Click(object sender, EventArgs e) { logger.Debug("Enter: goButton_Click(object, EventArgs)"); if (Hulk.CheckCommandAllowed()) { stopButton.Enabled = true; goButton.Enabled = false; ((PositionTask)task).Go(); } }
/// <summary> /// Called from the main control loop whenever the task is running. /// DO NOT call this method directly from RotationTask or RotationPanel. /// </summary> public override void ContinueTask() { if ((stopTime != DateTime.MinValue) && (DateTime.Now.CompareTo(stopTime) >= 0)) { // Duration limit reached. Hulk.StopTask(); } else { Hulk.ContinueTask(); } }
/// <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(); }
/// <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> /// 運用工廠模式,根據傳入值回傳對應的英雄類別 /// </summary> /// <param name="heroType">傳入選項的值</param> /// <returns></returns> public static IAvengers GetAvenger(string heroType) { IAvengers avenger; if (heroType == "1") { return(avenger = new DoctorStrange()); } if (heroType == "2") { return(avenger = new Hulk()); } return(null); }
/// <summary> /// Starts the next trial. /// </summary> /// <param name="sender">Not used</param> /// <param name="e">Not used</param> private void goButton_Click(object sender, EventArgs e) { logger.Debug("Enter: goButton_Click(object, EventArgs)"); if (Hulk.CheckCommandAllowed()) { protocolStopwatch.Start(); fileLoadButton.Enabled = false; goButton.Enabled = false; stopButton.Enabled = true; ThreadPool.QueueUserWorkItem(new WaitCallback(((ModeledControllerWithHmdTask)task).Go)); } }
public HeroesController() { context = new ApplicationDbContext(); Hulk hulk = new Hulk(); Batman batman = new Batman(); Goliath goliath = new Goliath(); OptimusPrime optimusPrime = new OptimusPrime(); List <Heroes> initialHeroes = new List <Heroes>(); initialHeroes.Add(hulk); initialHeroes.Add(batman); initialHeroes.Add(goliath); initialHeroes.Add(optimusPrime); CheckInitialHeroes(initialHeroes); }
/// <summary> /// Starts the next trial. /// </summary> /// <param name="sender">Not used</param> /// <param name="e">Not used</param> private void goButton_Click(object sender, EventArgs e) { logger.Debug("Enter: goButton_Click(object, EventArgs)"); if (Hulk.CheckCommandAllowed()) { recordingFilenamesListBox.ClearSelected(); recordingFilenamesListBox.SetSelected(0, true); fileLoadButton.Enabled = false; goButton.Enabled = false; stopButton.Enabled = true; ((PassiveMovementTask)task).Go(); } }
/// <summary> /// Stops the task. /// This method should ONLY contain a call to Hulk.StopTask(). /// Any other post-task cleanup should be handled in BalanceTask.StopTask() or ModeledControllerWithHmdPanel.CleanUp(). /// </summary> /// <param name="sender">Not used</param> /// <param name="e">Not used</param> private void stopButton_Click(object sender, EventArgs e) { logger.Debug("Enter: stopButton_Click(object, EventArgs)"); if (Hulk.CheckCommandAllowed()) { protocolStopwatch.Stop(); protocolStopwatch.Reset(); Hulk.StopTask(); ICommand c = new ICommand(); c.CommandType = (int)eCommands.FadeOut; AppMain.ServerHandler.sendCommandToRegisteredClients(c, null); } }
/// <summary> /// Called from the main control loop whenever the task is running. /// DO NOT call this method directly from PositionTask or PositionPanel. /// </summary> public override void ContinueTask() { MotionCommand command; ControlInput joystickInput; // Continually command the chair to position itself according to joystick input joystickInput = InputController.JoystickInput; command = new MotionCommand { outerPosition = startOuterPosition + (joystickInput.y * 90.0), innerPosition = startInnerPosition + (joystickInput.x * 90.0), }; Hulk.SetCommand(command); Hulk.ContinueTask(); }
/// <summary> /// Called by th control loop when the trial's time limit has been reached. /// </summary> private void HandleStateComplete() { logger.Info("Completed balance trial: " + trial.TrialNumber); DataLogger.CloseDataLog(); bool advanceToNextTrial = true; if ((trial.NumberIndications == 0) && trial.JoystickIndicationsMandatory) { logger.Warn("Participant did not indicate during this trial - restarting trial"); StartLogging(); StartTrial(); advanceToNextTrial = false; } if (advanceToNextTrial) { trial.PlayEndSound(); if (Trials.CurrentTrialIndex == (Trials.List.Count - 1)) { // Entire protocol has been completed Hulk.StopTask(); } else { // Continue to following trial Trials.CurrentTrialIndex++; trial = Trials.CurrentTrial; StartLogging(); trial.MovingDirectionOfBalance.roll = Trials.PreviousTrial.MovingDirectionOfBalance.roll; trial.MovingDirectionOfBalance.pitch = Trials.PreviousTrial.MovingDirectionOfBalance.pitch; trial.MovingDirectionOfBalance.yaw = Trials.PreviousTrial.MovingDirectionOfBalance.yaw; StartTrial(); } } }
public bool CheckIfHeroIsDefault(int id) { Hulk hulk = new Hulk(); Batman batman = new Batman(); Goliath goliath = new Goliath(); OptimusPrime optimusPrime = new OptimusPrime(); var listedHeroes = (from r in context.Heroes where r.heroId == id select r.heroName).FirstOrDefault(); if (listedHeroes.ToString() == hulk.heroName || listedHeroes.ToString() == batman.heroName || listedHeroes.ToString() == goliath.heroName || listedHeroes.ToString() == optimusPrime.heroName) { return(true); } else { return(false); } }
/// <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(); }
/// <summary> /// Starts the next trial. /// </summary> /// <param name="sender">Not used</param> /// <param name="e">Not used</param> private void goButton_Click(object sender, EventArgs e) { logger.Debug("Enter: goButton_Click(object, EventArgs)"); if (Hulk.CheckCommandAllowed()) { loadButton.Enabled = false; goButton.Enabled = false; stopButton.Enabled = true; amplitudeTextBox.Enabled = false; amplitudeTextBox.BackColor = ColorScheme.Instance.TextBoxDisabledBackground; offsetTextBox.Enabled = false; offsetTextBox.BackColor = ColorScheme.Instance.TextBoxDisabledBackground; ((DelayMeasurementTask)task).Go(forcingFunctionsFilename, Double.Parse(amplitudeTextBox.Text), Double.Parse(offsetTextBox.Text)); } }
/// <summary> /// Sets up timing and movement commands for the start of a new trial. /// </summary> private void StartTrial() { logger.Debug("Enter: StartTrial()"); logger.Info("Starting balance trial: " + trial.TrialNumber); ICommand c = new ICommand(); c.CommandType = (int)eCommands.SelectTrial; c.addParameter((int)eSelectTrialCommandParameters.TrialNumber, trial.TrialNumber.ToString()); trial.PlayStartSound(); trialStopwatch = new Stopwatch(); trialStopwatch.Start(); previousMillis = trialStopwatch.ElapsedMilliseconds; trial.TrialStatus = Trial.Status.BalancingDOBChanging; Hulk.SetCommandType(Hulk.CommandType.Velocity); }
/// <summary> /// Starts the movement. /// </summary> /// <param name="sender">Not used</param> /// <param name="e">Not used</param> private void goButton_Click(object sender, EventArgs e) { MotionCommand newMotionCommand; double duration; logger.Debug("Enter: goButton_Click(object, EventArgs)"); if (Hulk.CheckCommandAllowed()) { MessageBox.Show("NOT IMPLEMENTED YET!"); //newMotionCommand = new MotionCommand(); //newMotionCommand.innerAcceleration = Double.Parse(accelerationCommandInnerTextBox.Text); //newMotionCommand.outerAcceleration = Double.Parse(accelerationCommandOuterTextBox.Text); //newMotionCommand.innerVelocity = Double.Parse(velocityCommandInnerTextBox.Text); //newMotionCommand.outerVelocity = Double.Parse(velocityCommandOuterTextBox.Text); //softStopButton.Enabled = true; //hardStopButton.Enabled = true; //((UnrealLandscapesDemoTask)task).Go(newMotionCommand, 0); } }
/// <summary> /// Starts the movement. /// </summary> /// <param name="sender">Not used</param> /// <param name="e">Not used</param> private void goButton_Click(object sender, EventArgs e) { MotionCommand newMotionCommand; double duration; logger.Debug("Enter: goButton_Click(object, EventArgs)"); if (Hulk.CheckCommandAllowed()) { newMotionCommand = new MotionCommand(); newMotionCommand.innerAcceleration = Double.Parse(accelerationCommandInnerTextBox.Text); newMotionCommand.outerAcceleration = Double.Parse(accelerationCommandOuterTextBox.Text); newMotionCommand.innerVelocity = Double.Parse(velocityCommandInnerTextBox.Text); newMotionCommand.outerVelocity = Double.Parse(velocityCommandOuterTextBox.Text); if (positionCheckBox.Checked) { newMotionCommand.innerPosition = Double.Parse(positionCommandInnerTextBox.Text); newMotionCommand.outerPosition = Double.Parse(positionCommandOuterTextBox.Text); softStopButton.Enabled = false; hardStopButton.Enabled = false; } else { softStopButton.Enabled = true; hardStopButton.Enabled = true; } duration = -1.0; if (durationCheckBox.Checked) { duration = Double.Parse(durationCommandTextBox.Text); } ((RotationTask)task).Go(newMotionCommand, duration); } }
/// <summary> /// Called from the main control loop whenever the task is running. /// DO NOT call this method directly from PassiveMovementTask or PassiveMovementPanel. /// </summary> public override void ContinueTask() { MotionCommand command; RecordingTimepoint recording; double elapsedTime; double angleDiff; elapsedTime = runningStopwatch.ElapsedMilliseconds * 1.0 / 1000; // Check whether the entire block is complete if (Recordings.IsEndOfRecordingSeries(currentTrialNumber, elapsedTime)) { // Play the last recording timepoint recording = Recordings.GetRecording(currentTrialNumber, elapsedTime); command = new MotionCommand(); command.outerPosition = recording.Angles.pitch; if (Hulk.ChairMount == Hulk.MountType.Back) { command.innerPosition = recording.Angles.roll; } else { command.innerPosition = recording.Angles.yaw; } Hulk.SetCommand(command); Hulk.ContinueTask(); // Stop the HULK and return to idling Hulk.StopTask(); return; } // Check whether the current trial is complete if (Recordings.IsEndOfRecordingTrial(currentTrialNumber, elapsedTime)) { // Clean up from last trial DataLogger.CloseDataLog(); runningStopwatch.Reset(); // Prepare for next trial runningStopwatch.Start(); currentTrialNumber++; numClicks = 0; ((PassiveMovementPanel)panel).UpdateListbox(); DataLogger.AcquireDataLog(String.Format("recording{0:000}.csv", currentTrialNumber), dataLogHeader); return; } // Determine the control input for this simulation step if (Recordings.HasRecording()) { // Check whether the trigger has just been pressed if (!previousTrigger && InputController.JoystickInput.trigger) { numClicks++; } previousTrigger = InputController.JoystickInput.trigger; recording = Recordings.GetRecording(currentTrialNumber, elapsedTime); command = new MotionCommand(); command.outerPosition = recording.Angles.pitch; if (Hulk.ChairMount == Hulk.MountType.Back) { command.innerPosition = recording.Angles.roll; } else { command.innerPosition = recording.Angles.yaw; } // Stop if a large angle change is commanded. A large angle change could be dangerous at these accelerations. angleDiff = Math.Abs(lastPositionInner - command.innerPosition); if ((angleDiff > 3.0) && (angleDiff < 357.0)) { logger.Warn("SAFETY: Instantaneous INNER move >3 deg prevented. Current=" + lastPositionInner.ToString("F2") + " New=" + command.innerPosition.ToString("F2")); Hulk.StopTask(); return; } angleDiff = Math.Abs(lastPositionOuter - command.outerPosition); if ((angleDiff > 3.0) && (angleDiff < 357.0)) { logger.Warn("SAFETY: Instantaneous OUTER move >3 deg prevented. Current=" + lastPositionOuter.ToString("F2") + " New=" + command.outerPosition.ToString("F2")); Hulk.StopTask(); return; } lastPositionOuter = command.outerPosition; lastPositionInner = command.innerPosition; LogData(elapsedTime, Hulk.CurrentMotion, command, recording, InputController.JoystickInput); Hulk.SetCommand(command); Hulk.ContinueTask(); } }
public Obstacle(Point p, string level) { Location = p; this.level = level; if (level == "Hulk") { int k = Form1.r.Next(0, Enum.GetNames(typeof(Hulk)).Length); Hulk e = (Hulk)k; if (Hulk.car == e) { image = new Bitmap(Resources.car, new Size(50, 100)); } if (Hulk.bus == e) { image = new Bitmap(Resources.bus, new Size(50, 150)); } if (Hulk.motorcycle == e) { image = new Bitmap(Resources.motorcycle, new Size(30, 60)); } } if (level == "IronMan") { int k = Form1.r.Next(1, 3); if (k == 1) { image = new Bitmap(Resources.IronManObstacle1, new Size(56, 46)); } else { image = new Bitmap(Resources.IronManObstacle2, new Size(82, 94)); } } if (level == "Thor") { int k = Form1.r.Next(1, 3); if (k == 1) { image = new Bitmap(Resources.ThorObstacle1, new Size(113, 45)); } else { image = new Bitmap(Resources.ThorObstacle2, new Size(40, 123)); } } if (level == "CaptainAmerica") { int k = Form1.r.Next(1, 4); if (k == 1) { image = new Bitmap(Resources.CaptainAmericaObstacle1, new Size(97, 110)); } else if (k == 2) { image = new Bitmap(Resources.CaptainAmericaObstacle2, new Size(122, 60)); } else { image = new Bitmap(Resources.CaptainAmericaObstacle3, new Size(118, 105)); } } if (level == "ScarletWitch") { int k = Form1.r.Next(1, 3); if (k == 1) { image = new Bitmap(Resources.car, new Size(50, 100)); } else { image = new Bitmap(Resources.bus, new Size(50, 150)); } } if (level == "DrStrange") { int k = Form1.r.Next(1, 4); if (k == 1) { image = new Bitmap(Resources.drstrangeObstacle1, new Size(100, 50)); } else if (k == 2) { image = new Bitmap(Resources.drstrangeObstacle2, new Size(100, 50)); } else { image = new Bitmap(Resources.drstrangeObstacle3, new Size(70, 50)); } } }