Example #1
0
 /// <summary>
 /// Changes the selected COM Port
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void comboBoxCOMPort_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (comboBoxCOMPort.Enabled) //If enabled (it gets dissabled if there are no ports
     {
         TreadmillController.ClearSerialPortName();
         TreadmillController.SetSerialPortName(comboBoxCOMPort.Items[comboBoxCOMPort.SelectedIndex].ToString());
         treadmillStatus = comboBoxCOMPort.Items[comboBoxCOMPort.SelectedIndex].ToString();
     }
 }
 /// <summary>
 /// Turns on or off playing back motion capture data
 /// You must call OpenMotionCaptureSubSession first
 /// </summary>
 /// <param name="playback"></param>
 public static void MotionCaptureDataPlayback(bool playback)
 {
     if (playback)
     {
         MotionCaptureDataRecord(false);
         if (_lastSpeed != -1f)
         {
             TreadmillController.SetSpeed(_lastSpeed);
         }
     }
     else
     {
         _lastSpeed = TreadmillController.GetSpeed(); // save the current speed
     }
 }
        /// <summary>
        /// Sends the virtual motion capture data to the motion capture controller
        /// and sends out any treadmill speed updates
        /// </summary>
        public static void UpdateCoordinates()
        {
            // Get the next frame from the database
            bool status = GetNextFrame();

            if (status == false)
            {
                OnVirtualMotionCaptureSubSessionPlaybackEnded();
                return;
            }
            else
            {
                // Check to see if the treadmill speed changed this session, if so send it out
                float _treadmillSpeed = 0f;
                if (TreadmillSpeedChanged(out _treadmillSpeed))
                {
                    TreadmillController.SetSpeed(_treadmillSpeed);
                }

                // Send out the motion capture data
                MotionCaptureController.VirtualMotionCaptureControllerCallbackOnMarkerListAvaliable(_currentFrame.MarkerList, _currentFrame.TimeStamp);
                MotionCaptureController.VirtualMotionCaptureControllerCallbackOnTrackableListAvaliable(_currentFrame.TrackableList, _currentFrame.TimeStamp);
            }
        }
 void Awake()
 {
     Treadmill = GetComponent <TreadmillPlayerController>(); //Get Player prefab
     controls  = new TreadmillController();                  //creates a new contrller object
 }
Example #5
0
        /// <summary>
        /// Converts byte to command and then executes command
        /// </summary>
        /// <param name="receivedCommand"></param>
        public void handleCommand(byte[] receivedCommand)
        {
            lock (this) // Lock the code
            {
                int command = (int)receivedCommand[2];
                switch (command)
                {
                // 0 is Start Cameras
                case 0:
                    MotionCaptureStart();
                    break;

                // 1 is Stop Cameras
                case 1:
                    MotionCaptureStop();
                    break;

                // 2 is Send Camera Coordinates
                case 2:
                    if (MotionCaptureController.APIRunning)
                    {
                        MotionCaptureController.UpdateCameraList();
                        OptitrackCameraList.TransmitListOfCameras();
                    }
                    break;

                // 3 is Start Treadmill At Fixed Speed
                case 3:
                {
                    TreadmillController.SetSpeed((float)BitConverter.ToDouble(receivedCommand, 4));
                    break;
                }

                // 4 is Stop Treadmill
                case 4:
                {
                    TreadmillController.SetSpeed(0.0f);
                    break;
                }

                case 6:
                {
                    if (VirtualMotionCaputrePlayback)
                    {
                        VirtualMotionCaptureController.UpdateCoordinates();
                    }
                    else
                    {
                        MotionCaptureController.UpdateCoordinates(true, true);
                    }
                    break;
                }

                // 7 is Calibrate ground plane.
                case 7:
                {
                    //TODO: Reinstate or remove this?
                    //MotionCapture.Calibrate();
                    break;
                }

                //8 is toggle displaying feet
                case 8:
                {
                    if (ToggleFeetCommandReceivedEvent != null)
                    {
                        ToggleFeetCommandReceivedEvent(BitConverter.ToBoolean(receivedCommand, 4));
                    }
                    break;
                }

                case 9:     // Shuts down the drivers so the application can close
                {
                    FinalShutdown();
                    break;
                }

                case 10:     // Clears the CoR data - This should be called at the start of each session
                {
                    JointProcessor.ResetCoRCalculations();
                    break;
                }

                case 11:     // Requests an update for the current speed
                {
                    TreadmillController.TransmitSpeed();
                    break;
                }

                default:
                {
                    System.Diagnostics.Debug.WriteLine("Invalid command received: " + command.ToString());
                    break;
                }
                }
            }
        }
Example #6
0
 /// <summary>
 /// Redetects avaliable COM ports
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void buttonRestartTM_Click(object sender, EventArgs e)
 {
     comboBoxCOMPort.Items.Clear();
     TreadmillController.ClearSerialPortName();
     DetectTreadmill();
 }