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

Added the simulated IMU to the example.

parent 2f7a2d2f
No related branches found
No related tags found
No related merge requests found
...@@ -17,6 +17,7 @@ INCLUDE_DIRECTORIES(${dynamixel_INCLUDE_DIR}) ...@@ -17,6 +17,7 @@ INCLUDE_DIRECTORIES(${dynamixel_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${darwin_robot_INCLUDE_DIR}) INCLUDE_DIRECTORIES(${darwin_robot_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${OpenCV_INCLUDE_DIRS}) INCLUDE_DIRECTORIES(${OpenCV_INCLUDE_DIRS})
INCLUDE_DIRECTORIES(${detectqrcode_INCLUDE_DIR}) INCLUDE_DIRECTORIES(${detectqrcode_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${bno055_imu_driver_INCLUDE_DIR})
# application source files # application source files
SET(sources darwin_loc_nav.cpp) SET(sources darwin_loc_nav.cpp)
# application header files # application header files
...@@ -30,3 +31,4 @@ TARGET_LINK_LIBRARIES(darwin_loc_nav ${dynamixel_LIBRARY}) ...@@ -30,3 +31,4 @@ TARGET_LINK_LIBRARIES(darwin_loc_nav ${dynamixel_LIBRARY})
TARGET_LINK_LIBRARIES(darwin_loc_nav ${darwin_robot_LIBRARY}) TARGET_LINK_LIBRARIES(darwin_loc_nav ${darwin_robot_LIBRARY})
TARGET_LINK_LIBRARIES(darwin_loc_nav ${OpenCV_LIBRARIES}) TARGET_LINK_LIBRARIES(darwin_loc_nav ${OpenCV_LIBRARIES})
TARGET_LINK_LIBRARIES(darwin_loc_nav ${detectqrcode_LIBRARY}) TARGET_LINK_LIBRARIES(darwin_loc_nav ${detectqrcode_LIBRARY})
TARGET_LINK_LIBRARIES(darwin_loc_nav ${bno055_imu_driver_LIBRARY})
...@@ -2,13 +2,16 @@ ...@@ -2,13 +2,16 @@
#include "darwin_robot_exceptions.h" #include "darwin_robot_exceptions.h"
#include "action_id.h" #include "action_id.h"
#include "detectqrcode.h" #include "detectqrcode.h"
#include "bno055_imu_driver.h"
#include <iostream> #include <iostream>
#ifdef _SIM #ifdef _SIM
std::string robot_device="/dev/pts/20"; std::string robot_device="/dev/pts/20";
std::string imu_device="/dev/pts/23";
#else #else
std::string robot_device="A603LOBS"; std::string robot_device="A603LOBS";
std::string imu_device="/dev/ttyUSB0";
#endif #endif
int main(int argc, char *argv[]) int main(int argc, char *argv[])
...@@ -17,6 +20,7 @@ int main(int argc, char *argv[]) ...@@ -17,6 +20,7 @@ int main(int argc, char *argv[])
cv::Mat gray; cv::Mat gray;
int i=0,num_servos; int i=0,num_servos;
unsigned int present_servos; unsigned int present_servos;
bool accel_cal,mag_cal,gyro_cal;
std::vector<std::vector<cv::Point> > squares; std::vector<std::vector<cv::Point> > squares;
try{ try{
...@@ -40,6 +44,36 @@ int main(int argc, char *argv[]) ...@@ -40,6 +44,36 @@ int main(int argc, char *argv[])
cv::namedWindow("QRcode",1); cv::namedWindow("QRcode",1);
/* initialize IMU */
CBNO055IMUDriver imu("darwin_imu");
imu.open(imu_device);
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");
}
/* initialize robot */ /* initialize robot */
num_servos=darwin.mm_get_num_servos(); num_servos=darwin.mm_get_num_servos();
present_servos=darwin.mm_get_present_servos(); present_servos=darwin.mm_get_present_servos();
......
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