Book Image

Learning Robotics using Python

Book Image

Learning Robotics using Python

Overview of this book

Table of Contents (19 chapters)
Learning Robotics Using Python
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Interfacing MPU 6050 to Launchpad with the DMP support using Energia


In this section, we will see the interfacing code of MPU 6050 by activating DMP, which can give us direct orientation values in quaternion or yaw, pitch, and roll. This value can be directly applied to our robotic application too.

The following section of code imports all the necessary header files to interface and create an MPU6050 object like the previous code:

#include "Wire.h"
#include "I2Cdev.h"
#include "MPU6050_6Axis_MotionApps20.h"

//Creating MPU6050 Object
MPU6050 accelgyro(0x68);

The following code initializes and declares variables to handle DMP:

//DMP options
//Set true if DMP initialization was successful
bool dmpReady = false;

//Holds actual interrupt status byte from MPU
uint8_t mpuIntStatus;

//return status after each device operation
uint8_t devStatus;

//Expected DMP packet size
uint16_t packetSize;

//count of all bytes currently in FIFO
uint16_t fifoCount;

//FIFO storate buffer
uint8_t fifoBuffer[64...