Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
SpaceSensor.h
00001 #ifndef MBED_SpaceSsensor_H 00002 #define MBED_SpaceSsensor_H 00003 //#endif 00004 #include "mbed.h" 00005 #include "iostream" 00006 #include "math.h" 00007 using namespace std; 00008 00009 class SpaceSensor { 00010 public: 00011 SpaceSensor(PinName p_tx, PinName p_rx); 00012 /**********************************************************************************************************************/ 00013 /*4.3.1 Commands for Reading Filtered Sensor Data 00014 These commands return sensor data which has been filtered using a Kalman filter. None of these commands take any 00015 parameters, they only return data. 00016 */ 00017 /**********************************************************************************************************************/ 00018 void ReadfilteredtaredQuaternion(float *Quaternion); 00019 void ReadfilteredtaredEulerAngles(float *EulerAngles); 00020 void ReadfilteredtaredRotationMatrix(float *RotationMatrix); 00021 void ReadfilteredtaredAxisAngle(float *Axis,float *Angle); 00022 void ReadfilteredtaredTwoVector(float *Forward,float *Down); 00023 00024 void Readfilteredgyrorates(float *Quaternion); 00025 00026 void ReadfiltereduntaredQuaternion(float *Quaternion); 00027 void ReadfiltereduntaredEulerAngles(float *EulerAngles); 00028 void ReadfiltereduntaredRotationMatrix(float *RotationMatrix); 00029 void ReadfiltereduntaredAxisAngle(float *Axis,float *Angle); 00030 void ReadfiltereduntaredTwoVector(float *Forward,float *Down); 00031 00032 void ReadfilteredtaredForwardandDownVectors(float *Forward,float *Down); 00033 void ReadfilteredNorthEarthVectors(float *North,float *Earth); 00034 /**********************************************************************************************************************/ 00035 /*4.3.2 Commands for Interfacing with Electronic Systems*/ 00036 /**********************************************************************************************************************/ 00037 void Setinterrupttype(int mode); 00038 void Readinterrupttype(int *interrupttype); 00039 void Readinterruptstatus(int *interruptstatus); 00040 /**********************************************************************************************************************/ 00041 /*4.3.3 Commands for Reading Normalized Sensor Data 00042 These commands return sensor data which has been converted from a raw form. In the case of the normalized 00043 accelerometer and compass, the data returned are unit vectors, and as such, have no magnitude data associated with 00044 them. For data that represents real world quantities, both the unnormalized accelerometer command and unnormalized 00045 compass command return data in units of g and gauss respectively. Normalized gyro data is returned in radians/sec. 00046 */ 00047 /**********************************************************************************************************************/ 00048 void Readall(float *gyro,float *accelerometer,float *compass); 00049 void Readgyros(float *gyro); 00050 void Readaccelerometer(float *accelerometer); 00051 void Readcompass(float *compass); 00052 void ReadtemperatureC(float *temp); 00053 void ReadtemperatureF(float *temp); 00054 void Readconfidencefactor(float *confidencefactor); 00055 void Readaccelerometerunnormalized(float *accelunnormalized); 00056 void Readcompassunnormalized(float *compassunnormalized); 00057 /**********************************************************************************************************************/ 00058 /*4.3.4 Commands for Reading Raw Sensor Data 00059 These commands return sensor data just as it was when it was read from each sensor. None of these commands take any 00060 parameters, they only return data. 00061 */ 00062 /**********************************************************************************************************************/ 00063 void Readallraw(float *gyro,float *accelerometer,float *compass); 00064 void Readgyroraw(float *gyro); 00065 void Readaccelerometerraw(float *accelerometer); 00066 void Readcompassraw(float *compass); 00067 /**********************************************************************************************************************/ 00068 /*4.3.5 Commands for Setting Filter Parameters 00069 These commands allow the configuration of parameters associated with the Kalman filter. Most of these commands 00070 take parameters, none return any data. 00071 */ 00072 /**********************************************************************************************************************/ 00073 void Tarewithcurrentorientation(); 00074 void Tarewithquaternion(float Quaternion[4]); 00075 void Tarewithrotationmatrix(float RotationMatrix[9]); 00076 void SetStaticRhoModeAccelerometer(float rho); 00077 void SetConfidenceRhoModeAccelerometer(float min,float max); 00078 void SetStaticRhoModeCompass(float rho); 00079 void SetConfidenceRhoModeCompass(float min, float max); 00080 void SetDesiredUpdateRate(int t); 00081 void SetMultiReferenceVectorsWithCurrentOrientation(); 00082 void SetReferenceVectorMode(int mode); 00083 void SetOversampleRate(int rate); 00084 void EnableDisablegyros(int mode); 00085 void EnableDisableAccelerometer(int mode); 00086 void EnableDisableCompass(int mode); 00087 void ResetMultiReferenceVectorsToZero(); 00088 void SetMultiReferenceResolution(int mode); 00089 void SetCompassMultiReferenceVector(int Index,float Vector[3]); 00090 void SetCompassMultiReferenceCheckVector(int Index,float Vector[3]); 00091 void SetAccelMultiReferenceVector(int Index,float Vector[3]); 00092 void SetAccelMultiReferenceCheckVector(int Index,float Vector[3]); 00093 void SetAxisDirections(int direction); 00094 void SetRunningAveragePercent(float Percent); 00095 void SetCompassReferenceVector(float Vector[3]); 00096 void SetAccelerometerReferenceVector(float Vector[3]); 00097 void ResetKalmanFilter(); 00098 void SetAccelerometerRange(int Accelrange); 00099 void SetMultiReferenceWeightPower(float WeightPower); 00100 void EnableDisableFilter(int Mode); 00101 void SetRunningAverageMode(int Mode); 00102 void SetGyroscopeRange(int mode); 00103 void SetCompassRange(int mode); 00104 /**********************************************************************************************************************/ 00105 /*4.3.6 Commands for Reading Filter Parameters 00106 These commands allow the reading of parameters associated with the Kalman filter. All these commands return data, 00107 and accept no parameters. 00108 */ 00109 /**********************************************************************************************************************/ 00110 void ReadTareOrientationQuaternion(float *Quaternion); 00111 void ReadTareOrientationRotationMatrix(float *RotationMatrix); 00112 void ReadRhoDataAccelerometer(int *Rhomode,float *minroh,float *maxroh); 00113 void ReadRhoDataCompass(int *Rhomode,float *minroh,float *maxroh); 00114 void ReadCurrentUpdateRate(int *rate); 00115 void ReadCompassReferenceVector(float *Vector); 00116 void ReadAccelerometerReferenceVector(float *Vector); 00117 void ReadReferenceVectorMode(int *Mode); 00118 void ReadCompassMultiReferenceVector(int Index,float *Vector); 00119 void ReadCompassMultiReferenceCheckVector(int Index,float *Vector); 00120 void ReadAccelMultiReferenceVector(int Index,float *Vector); 00121 void ReadAccelMultiReferenceCheckVector(int Index,float *Vector); 00122 void ReadGyroEnabledState(int *Mode); 00123 void ReadAccelerometerEnabledState(int *Mode); 00124 void ReadCompassEnabledState(int *Mode); 00125 void ReadAxisDirections(int *direction); 00126 void ReadOversampleRate(int *Rate); 00127 void ReadRunningAveragePercent(float *Percent); 00128 void ReadDesiredUpdateRate(float *rate); 00129 void ReadKalmanFilterCovarianceMatrix(float *CovarianceMatrix); 00130 void ReadAccelerometerRange(int *Accelrange); 00131 void ReadMultiReferenceWeightPower(float *WeightPower); 00132 void ReadMultiReferenceResolution(int *Resolution); 00133 void ReadNumberOfmultiReferenceCells(int *NumberOfCells); 00134 void ReadFilterEnableState(int *Mode); 00135 void ReadRunningAverageMode(int *Mode); 00136 void ReadGyroscopeRange(int *mode); 00137 void ReadCompassRange(int *mode); 00138 /**********************************************************************************************************************/ 00139 /*4.3.7 Commands for Calibration 00140 These commands allow the configuration and reading of calibration parameters and enabling of calibration modes. 00141 */ 00142 /**********************************************************************************************************************/ 00143 void SetCompassCalibrationParameters(float Bias[3],float Matrix[9]); 00144 void SetAccelerometerCalibrationParameters(float Bias[3],float Matrix[9]); 00145 void ReadCompassCalibrationParameters(float *Bias,float *Matrix); 00146 void ReadAccelerometerCalibrationParameters(float *Bias,float *Matrix); 00147 void ReadGyroCalibrationParameters(float *Bias, float *range); 00148 void BeginGyroAutocalibration(); 00149 void SetGyroCalibrationParameters(float Bias[3], float range[3]); 00150 /**********************************************************************************************************************/ 00151 /*4.3.8 General Commands 00152 These commands are for the configuration of the sensor as a whole as opposed to configuration of the filter or sensors. 00153 */ 00154 /**********************************************************************************************************************/ 00155 void ReadSoftwareVersion(char *version); 00156 void RestoreFactorySettings(); 00157 void CommitSettings(); 00158 void SoftwareReset(); 00159 void EnableWatchdogTimer(int timer); 00160 void DisableWatchdogTimer(); 00161 void EnterFirmwareUpdateMode(); 00162 void ReadHardwareVersion(char *version); 00163 void SetUARTBaudRate(int Baudrate); 00164 void GetUARTBaudRate(int *Baudrate); 00165 void SetUSBmode(int mode); 00166 void GetUSBmode(int *mode); 00167 void SetClockSpeed(int clock); 00168 void GetClockSpeed(int *clock); 00169 void GetSerialnumber(int *serialnum); 00170 void SetLEDColor(float color[3]); 00171 void GetLEDColor(float *color); 00172 void EnableDisableJoystick(int Mode); 00173 void EnableDisablemouse(int Mode); 00174 void ReadJoystickEnabledState(int *Mode); 00175 void ReadMouseEnabledState(int *Mode); 00176 void SetControlMode(float Controlclass,float controlindex,float handlerindex); 00177 void SetControlData(float Controlclass,float controlindex,float datapointindex,float datapoint ); 00178 void ReadControlMode(float *Handlerindex, float Controlclass,float controlindex); 00179 void ReadControlData(float *Datapoint,float ControlClass,float controlIndex,float dataPointIndex); 00180 void SetMouseAbsoluteRelative(int Mode); 00181 void ReadMouseAbsoluteRelative(int *Mode); 00182 void SetjoystickAndMousePresentRemoved(int Mode); 00183 void ReadjoystickAndMousePresentRemoved(int *Mode); 00184 /**********************************************************************************************************************/ 00185 /* 00186 clases needed to interface with the sensor 00187 */ 00188 /**********************************************************************************************************************/ 00189 00190 00191 private: 00192 Serial _SpaceSensor; 00193 char *st; 00194 float *vecf; 00195 char var[10]; 00196 void begin(long baud); 00197 void read_string(float *vector,char *c); 00198 }; 00199 00200 #endif
Generated on Sun Jul 17 2022 19:48:27 by
1.7.2