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.
Dependencies: BNO055_fusion mbed
Fork of Bosch_BNO055_Fusion_example by
main.cpp
- Committer:
- kenjiArai
- Date:
- 2015-04-05
- Revision:
- 0:31451519d283
- Child:
- 2:cf77282aea7b
File content as of revision 0:31451519d283:
/*
* mbed Application program for the mbed Nucleo F401
* BNO055 Intelligent 9-axis absolute orientation sensor
* by Bosch Sensortec
*
* Copyright (c) 2015 Kenji Arai / JH1PJL
* http://www.page.sannet.ne.jp/kenjia/index.html
* http://mbed.org/users/kenjiArai/
* Created: March 30th, 2015
* Revised: April 5th, 2015
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
* AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
// Include ---------------------------------------------------------------------------------------
#include "mbed.h"
#include "BNO055.h"
// Definition ------------------------------------------------------------------------------------
// Object ----------------------------------------------------------------------------------------
Serial pc(USBTX,USBRX);
I2C i2c(PB_9, PB_8); // SDA, SCL
BNO055 imu(i2c); // addr = BNO055_G_CHIP_ADDR, mode = MODE_NDOF <- as default
// RAM -------------------------------------------------------------------------------------------
BNO055_ID_INF_TypeDef bno055_id_inf;
BNO055_EULER_TypeDef euler_angles;
BNO055_QUATERNION_TypeDef quaternion;
BNO055_LIN_ACC_TypeDef linear_acc;
BNO055_GRAVITY_TypeDef gravity;
BNO055_TEMPERATURE_TypeDef chip_temp;
// ROM / Constant data ---------------------------------------------------------------------------
// Function prototypes ---------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------
// Control Program
//-------------------------------------------------------------------------------------------------
int main() {
uint8_t i;
pc.printf("Bosch Sensortec BNO055 test program on " __DATE__ "/" __TIME__ "\r\n");
// Is BNO055 avairable?
if (imu.chip_ready() == 0){
pc.printf("Bosch BNO055 is NOT avirable!!\r\n");
}
imu.set_mounting_position(MT_P6);
pc.printf("AXIS_REMAP_CONFIG:0x%02x, AXIS_REMAP_SIGN:0x%02x\r\n",
imu.read_reg0(BNO055_AXIS_MAP_CONFIG), imu.read_reg0(BNO055_AXIS_MAP_SIGN));
imu.read_id_inf(&bno055_id_inf);
pc.printf("CHIP:0x%02x, ACC:0x%02x, MAG:0x%02x, GYR:0x%02x, , SW:0x%04x, , BL:0x%02x\r\n",
bno055_id_inf.chip_id, bno055_id_inf.acc_id, bno055_id_inf.mag_id,
bno055_id_inf.gyr_id, bno055_id_inf.sw_rev_id, bno055_id_inf.bootldr_rev_id);
while(1) {
pc.printf("Euler Angles data\r\n");
for (i = 0; i < 20; i++){
imu.get_Euler_Angles(&euler_angles);
pc.printf("Heading:%+6.1f [deg], Roll:%+6.1f [deg], Pich:%+6.1f [deg], #%02d\r\n",
euler_angles.h, euler_angles.r, euler_angles.p, i);
wait(0.5);
}
pc.printf("Quaternion data\r\n");
for (i = 0; i < 20; i++){
imu.get_quaternion(&quaternion);
pc.printf("W:%d, X:%d, Y:%d, Z:%d, #%02d\r\n",
quaternion.w, quaternion.x, quaternion.y, quaternion.z, i);
wait(0.5);
}
pc.printf("Linear accel data\r\n");
for (i = 0; i < 20; i++){
imu.get_linear_accel(&linear_acc);
pc.printf("X:%+6.1f [m/s*s], Y:%+6.1f [m/s*s], Z:%+6.1f [m/s*s], #%02d\r\n",
linear_acc.x, linear_acc.y, linear_acc.z, i);
wait(0.5);
}
pc.printf("Gravity vector data\r\n");
for (i = 0; i < 20; i++){
imu.get_gravity(&gravity);
pc.printf("X:%+6.1f [m/s*s], Y:%+6.1f [m/s*s], Z:%+6.1f [m/s*s], #%02d\r\n",
gravity.x, gravity.y, gravity.z, i);
wait(0.5);
}
pc.printf("Chip temperature data\r\n");
for (i = 0; i < 20; i++){
imu.get_chip_temperature(&chip_temp);
pc.printf("Acc chip:%+d [degC], Gyr chip:%+d [degC], #%02d\r\n",
chip_temp.acc_chip, chip_temp.gyr_chip, i);
wait(0.5);
}
}
}
