Skip to content
Snippets Groups Projects
Commit 69b75e83 authored by Sergi Hernandez's avatar Sergi Hernandez
Browse files

Changed the name of the class (Added a C in front of the class name)

Changed the communications timeout to 500 ms.
the set_operation_mode() function only does it function if the new mode is different from the current one.
parent 304fb697
No related branches found
No related tags found
No related merge requests found
File added
This diff is collapsed.
......@@ -150,7 +150,7 @@ typedef enum {temp_celcius,temp_farenheit} temp_units_t;
/* axis remapping definitions */
typedef enum {X_AXIS=0x00,Y_AXIS=0x01,Z_AXIS=0x02} axis_t;
class BNO055IMUDriver
class CBNO055IMUDriver
{
private:
std::string imu_name;
......@@ -205,7 +205,7 @@ class BNO055IMUDriver
void get_sensor_units(void);
void get_sensor_configs(void);
public:
BNO055IMUDriver(const std::string &name);
CBNO055IMUDriver(const std::string &name);
void open(const std::string &serial_dev);
void set_power_mode(power_mode_t power_mode);
power_mode_t get_power_mode(void);
......@@ -242,7 +242,7 @@ class BNO055IMUDriver
bool is_magnetometer_calibrated(void);
bool is_gyroscope_calibrated(void);
bool is_imu_calibrated(void);
~BNO055IMUDriver();
~CBNO055IMUDriver();
};
#endif
......@@ -6,28 +6,41 @@
int main(int argc, char *argv[])
{
try{
bool accel_cal,mag_cal,gyro_cal,imu_cal;
bool accel_cal,mag_cal,gyro_cal;
CEventServer *event_server=CEventServer::instance();
std::list<std::string> events;
BNO055IMUDriver imu("darwin_imu");
CBNO055IMUDriver imu("darwin_imu");
std::vector<double> accel,mag,gyro;
std::vector<double> quat,euler,linear_acc,gravity;
unsigned int i;
imu.open("/dev/ttyUSB1");
imu.set_operation_mode(ndof_mode);
do{
accel_cal=imu.is_accelerometer_calibrated();
std::cout << "Accelerometer calibrated: " << accel_cal << std::endl;
mag_cal=imu.is_magnetometer_calibrated();
std::cout << "Magnetometer calibrated: " << mag_cal << std::endl;
gyro_cal=imu.is_gyroscope_calibrated();
std::cout << "Gyroscope calibrated: " << gyro_cal << std::endl;
imu_cal=imu.is_imu_calibrated();
std::cout << "IMU calibrated: " << imu_cal << std::endl;
sleep(1);
}while(!accel_cal || !mag_cal || !gyro_cal || !imu_cal);
try{
imu.load_calibration("bno055.cal");
do{
imu.set_operation_mode(ndof_mode);
accel_cal=imu.is_accelerometer_calibrated();
std::cout << "Accelerometer calibrated: " << accel_cal << std::endl;
mag_cal=imu.is_magnetometer_calibrated();
std::cout << "Magnetometer calibrated: " << mag_cal << std::endl;
gyro_cal=imu.is_gyroscope_calibrated();
std::cout << "Gyroscope calibrated: " << gyro_cal << std::endl;
sleep(1);
}while(!accel_cal || !mag_cal || !gyro_cal);
}catch(CException &e){
std::cout << e.what() << std::endl;
do{
imu.set_operation_mode(ndof_mode);
accel_cal=imu.is_accelerometer_calibrated();
std::cout << "Accelerometer calibrated: " << accel_cal << std::endl;
mag_cal=imu.is_magnetometer_calibrated();
std::cout << "Magnetometer calibrated: " << mag_cal << std::endl;
gyro_cal=imu.is_gyroscope_calibrated();
std::cout << "Gyroscope calibrated: " << gyro_cal << std::endl;
sleep(1);
}while(!accel_cal || !mag_cal || !gyro_cal);
imu.save_calibration("bno055.cal");
}
events.push_back(imu.get_new_data_event_id());
for(i=0;i<1000;i++)
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment