///<summary>A constructor that initializes the model with the appropriate Kalman filter values. </summary>
 ///<param name="r_coefficient"> The R coefficient of the Kalman filter. </param>
 ///<param name="q_coefficient"> The Q coefficient of the Kalman filter. </param>
 public KalmanFilterEstimationController(double _R, double _Q, int _muscle_amplifcation, Body _body)
 {
     R = _R;
     Q = _Q;
     muscle_amplification = _muscle_amplifcation;
     body = _body;
     signal_processing       = new SignalProcessing();
     optimization_parameters = new List <double>();
 }
 ///<summary>The default contructor initialzes internal variables to defaults.</summary>
 public KalmanFilterEstimationController()
 {
     R = 0;
     Q = 0;
     muscle_amplification = 0;
     body = new Body();
     signal_processing       = new SignalProcessing();
     optimization_parameters = new List <double>();
 }
示例#3
0
 public BiomechanicalEstimationController(double _timestep, Body _body, List <List <double> > _muscle_activation_coefficients)
 {
     W        = 0.56;
     A        = 0.25;
     gmax     = 1.5;
     timestep = _timestep;
     muscle_activation_coefficients = _muscle_activation_coefficients;
     body = _body;
     signal_processing       = new SignalProcessing();
     optimization_parameters = new List <double>(2);
 }
示例#4
0
 public BiomechanicalEstimationController()
 {
     W        = 0.56;
     A        = 0.25;
     gmax     = 1.5;
     timestep = 0;
     muscle_activation_coefficients = new List <List <double> >();
     body = new Body();
     signal_processing       = new SignalProcessing();
     optimization_parameters = new List <double>();
 }
        public ElbowMotionTrackingController(int _window_size, int _biceps_emg_channel, int _triceps_emg_channel, ExperimentInterface _experiment_interface) //add other arguments from startup
        {
            experiment_interface = _experiment_interface;

            subject = new Body();
            emg_sampling_frequency = 2000;
            time_step                     = 1 / emg_sampling_frequency;
            window_size                   = _window_size;
            brace_position                = 0;
            subject_position              = 0;
            biceps_emg_channel            = _biceps_emg_channel;
            triceps_emg_channel           = _triceps_emg_channel;
            brace_encoder_offset          = 0;
            gear_ratio                    = 713; //Taylor's brace gear ratio
            save_motion_data              = false;
            save_system_data              = false;
            track_motion_data             = false;
            current_estimation_controller = 0;
            upper_position_limit          = 130;
            lower_position_limit          = -20;
            command_position              = 0;
            command_frequency             = Convert.ToDouble(experiment_interface.textBox8.Text);
            counter = 0;

            //initialize complex data types
            estimation_controllers = new List <EstimationController>();
            kfmm = new KalmanFilterEstimationController();
            pmm  = new ProportionalEstimationController(time_step);
            npmm = new PolynomialEstimationController(time_step, 3);
            estimation_controllers.Add(kfmm);
            estimation_controllers.Add(pmm);
            estimation_controllers.Add(npmm);
            actuation_controller  = new WearMEBraceController(epos, this);
            epos_manager          = new DeviceManager("EPOS", "MAXON_RS232", "RS232", experiment_interface.textBox9.Text);
            epos_manager.Baudrate = 115200;
            epos_manager.Timeout  = 500;
            trigno                       = new DelsysTrignoCSharpLibrary.Driver();
            collection_arm               = new CollectionArmLibrary.CollectionArm(experiment_interface.textBox13.Text, 38400);
            subject_positions            = new List <double>(window_size);
            brace_positions              = new List <double>(window_size);
            triceps_emg                  = new List <double>(window_size);
            biceps_emg                   = new List <double>(window_size);
            position_estimates           = new List <double>(window_size);
            previous_biceps_emg          = new List <double>(window_size);
            previous_triceps_emg         = new List <double>(window_size);
            previous_subject_positions   = new List <double>(window_size);
            previous_brace_positions     = new List <double>(window_size);
            command_positions            = new List <double>(window_size);
            previous_biceps_emg_filter1  = new List <double>(window_size);
            previous_triceps_emg_filter1 = new List <double>(window_size);
            for (int i = 0; i < window_size; i++)
            {
                previous_biceps_emg.Add(0);
                previous_triceps_emg.Add(0);
                previous_subject_positions.Add(0);
                previous_brace_positions.Add(0);
                previous_biceps_emg_filter1.Add(0);
                previous_triceps_emg_filter1.Add(0);
                position_estimates.Add(0);
            }
            muscle_activation_parameters = new List <List <double> >();
            kalman_filter_parameters     = new List <double>();
            proportional_parameters      = new List <double>();
            subject_motion_data          = new List <List <double> >();
            stop_watch        = new Stopwatch();
            stop_watch2       = new Stopwatch();
            stop_watch3       = new Stopwatch();
            finished_logging  = true;
            signal_processing = new SignalProcessing();

            //Thread initialization
            emg_data_thread                             = new EMGDataThread();
            emg_data_thread.window_size                 = window_size;
            emg_data_thread.trigno                      = trigno;
            emg_data_thread.biceps_emg_channel          = biceps_emg_channel;
            emg_data_thread.triceps_emg_channel         = triceps_emg_channel;
            emg_data_worker                             = new BackgroundWorker();
            emg_data_worker.DoWork                     += new DoWorkEventHandler(EMGDataWorker_DoWork);
            emg_data_worker.RunWorkerCompleted         += new RunWorkerCompletedEventHandler(EMGDataWorker_RunWorkerCompleted);
            subject_position_thread                     = new SubjectPositionThread();
            subject_position_thread.collection_arm      = collection_arm;
            subject_position_worker                     = new BackgroundWorker();
            subject_position_worker.DoWork             += new DoWorkEventHandler(SubjectPositionWorker_DoWork);
            subject_position_worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(SubjectPositionWorker_RunWorkerCompleted);
            logger_thread                     = new LoggerThread();
            logger_worker                     = new BackgroundWorker();
            logger_worker.DoWork             += new DoWorkEventHandler(LoggerWorker_DoWork);
            logger_worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(LoggerWorker_RunWorkerCompleted);

            tracking_loop_timer    = 0;
            data_log_timer         = 0;
            subject_position_timer = 0;
            brace_position_timer   = 0;
            brace_command_timer    = 0;
        }