コード例 #1
0
        /// <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();
        }
コード例 #2
0
        /// <summary>
        /// Sets up logging for the start of a new trial.
        /// </summary>
        private void StartLogging()
        {
            logger.Debug("Enter: StartLogging()");

            DataLogger.AcquireDataLog(String.Format(Trials.ProtocolFilename + "_trial_{0}.csv",
                                                    Trials.CurrentTrial.TrialNumber.ToString("000")), dataLogHeader);
            logStopwatch = new Stopwatch();
            logStopwatch.Start();
        }
コード例 #3
0
        /// <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();
        }
コード例 #4
0
        /// <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();
            }
        }