Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050 #ifndef BMG160_H_
00051 #define BMG160_H_
00052
00053 #include <iostream>
00054 #include <cmath>
00055 #include <unistd.h>
00056
00057
00058 #include <ros/console.h>
00059
00060 #include <bosch_drivers_sensor_driver.hpp>
00061 #include <bosch_drivers_hardware_interface.hpp>
00062 #include "bmg160_parameters.hpp"
00063
00064 #include <bmg160_driver/bmg160meas.h>
00065
00066 using namespace bosch_drivers_common;
00067
00082 class BMG160: public sensor_driver, public BMG160Parameters
00083 {
00084
00085 public:
00086
00088 static const uint8_t SOFTRESET_CMD = 0xB6;
00089
00096 static const uint8_t DATA_HIGH_BW = 7;
00097
00104 static const uint8_t fast_offset_en = 3;
00105 static const uint8_t fast_offset_en_z = 2;
00106 static const uint8_t fast_offset_en_y = 1;
00107 static const uint8_t fast_offset_en_x = 0;
00108
00115 static const uint8_t fast_offset_unfilt = 7;
00116
00123 static const uint8_t slow_offset_th = 6;
00124 static const uint8_t slow_offset_dur = 3;
00125 static const uint8_t slow_offset_en_x = 0;
00126 static const uint8_t slow_offset_en_y = 1;
00127 static const uint8_t slow_offset_en_z = 2;
00128
00135 static const uint8_t slow_offset_unfilt = 5;
00136
00143 static const uint8_t nvm_load = 3;
00144
00145 BMG160( bosch_hardware_interface* hw );
00146 ~BMG160();
00147
00156 uint8_t getDeviceAddress();
00157
00164 bool initialize();
00165
00173 bool takeMeasurement();
00174
00182 bool softReset();
00183
00194 bool changeRange();
00195
00208 bool filterData( bool request );
00209
00224 bool changeBandwidth();
00225
00235 double getGyroX();
00236
00246 double getGyroY();
00247
00257 double getGyroZ();
00258
00268 double getTemperature();
00269
00281 void SimpleCalibration();
00282
00289 bool readSensorData( uint8_t reg, uint8_t* data, uint8_t num_bytes );
00290
00298 void computeOffsets( uint8_t* raw_offset_data, int16_t* clean_offset_data );
00299
00306 bool printOffsets();
00307
00308
00310
00314 static const uint8_t SLAVE_ADDRESS0 = 0x68;
00318 static const uint8_t SLAVE_ADDRESS1 = 0x69;
00319
00320 static const uint8_t ADDRESS_GYRO_X_LSB = 0x02;
00321 static const uint8_t ADDRESS_GYRO_Y_LSB = 0x04;
00322 static const uint8_t ADDRESS_GYRO_Z_LSB = 0x06;
00323 static const uint8_t ADDRESS_TEMPERATURE = 0x08;
00324
00325 static const uint8_t ADDRESS_RANGE = 0x0F;
00326 static const uint8_t ADDRESS_BANDWIDTH = 0x10;
00327 static const uint8_t ADDRESS_FILTER = 0x13;
00328 static const uint8_t ADDRESS_SOFTRESET = 0x14;
00329 static const uint8_t ADDRESS_FILTERED_CAL = 0x1A;
00330 static const uint8_t ADDRESS_FILTERED_CAL_FAST = 0x1B;
00331 static const uint8_t ADDRESS_ENABLE_CAL = 0x31;
00332 static const uint8_t ADDRESS_ENABLE_FAST_CAL = 0x32;
00333 static const uint8_t ADDRESS_NVM = 0x33;
00334
00346 static const uint8_t ADDRESS_OFFSETS = 0x36;
00347
00348 double GyroX_;
00349 double GyroY_;
00350 double GyroZ_;
00351 double Temperature_;
00352 double TempSlope_;
00353
00354 private:
00355 bool readReg( uint8_t reg, uint8_t* value );
00356 bool writeToReg( uint8_t reg, uint8_t value );
00357 bool writeToRegAndVerify( uint8_t reg, uint8_t value, uint8_t expected );
00358 };
00359
00360 #endif // BMC050_H_