Example #1
0
        /// <summary>
        /// Constructs the Calibration class, passing the associated IMU number and parent IMUConnection instance.
        /// Looks for the associated calibration file and attempts to read it if it exists, else creates a new one.
        /// </summary>
        /// <param name="_IMU_number">IMU device number.</param>
        /// <param name="_IMU_connection"> Parent IMU connection instance.</param>
        public Calibration(string _IMU_number, IMUConnection _IMU_connection)
        {
            populate_variables();
            IMU_number     = _IMU_number;
            IMU_connection = _IMU_connection;
            bool use_calibration = IMU_connection.use_calibration;

            path += @"C:\Users\Nathan\Dev\Imperial\IMU\Avatar\NUClass\calibrationFiles" + IMU_number + ".txt";  //MMark.Info.MMarkInfo.MMarkResources + "IMU_Memory\\MagCali\\" + IMU_number + ".txt";

            if (File.Exists(path) && use_calibration)
            {
                System.Diagnostics.Debug.WriteLine(IMU_number.ToString() + " ACTIVATED");
                try
                {
                    string[] CalibrationValues = File.ReadAllLines(path);

                    for (var i = 0; i < 3; i++)
                    {
                        variables["GYRO"][axes[i]]  = int.Parse(CalibrationValues[i]);
                        variables["ACCEL"][axes[i]] = int.Parse(CalibrationValues[(i + 3)]);
                        variables["MAG"][axes[i]]   = int.Parse(CalibrationValues[(i + 6)]);
                    }
                    valid_config_file = true;
                }
                catch (Exception)
                {
                    valid_config_file = false;
                }
            }
            System.Diagnostics.Debug.WriteLine(valid_config_file);
        }
Example #2
0
 /// <summary>
 /// Constructs the class and assigns global variables from the passed parameters, then sets up
 /// basic connection variables.
 /// </summary>
 /// <param name="_IMU_connection"> Parent IMUConnection instance.</param>
 /// <param name="_bt_address"> Bluetooth address for IMU device.</param>
 /// <param name="_debug_connection_reports"> Produce debug report?</param>
 /// <param name="_connection_info"> Get IMU firmware information? </param>
 public BTManager(IMUConnection _IMU_connection, BluetoothAddress _bt_address, bool _debug_connection_reports, bool _connection_info)
 {
     IMU_connection           = _IMU_connection;
     debug_connection_reports = _debug_connection_reports;
     bt_address      = _bt_address;
     connection_info = _connection_info;
     db_report("Bluetooth Manager Created.");
     establish_bluetooth_connection();
 }