ArPiRobot-CoreLib C++
C++ library for ArPiRobot robots
Public Member Functions | Protected Member Functions | List of all members
arpirobot::Mpu6050Imu Class Reference

#include <arpirobot/arduino/sensor/Mpu6050Imu.hpp>

Inheritance diagram for arpirobot::Mpu6050Imu:
arpirobot::ArduinoDevice

Public Member Functions

 Mpu6050Imu (bool createDevice=true, int deviceId=-1)
 
void calibrate (uint16_t samples)
 
double getGyroX ()
 
double getGyroY ()
 
double getGyroZ ()
 
double getAccelX ()
 
double getAccelY ()
 
double getAccelZ ()
 
void setGyroX (double newGyroX)
 
void setGyroY (double newGyroY)
 
void setGyroZ (double newGyroZ)
 
- Public Member Functions inherited from arpirobot::ArduinoDevice
 ArduinoDevice (bool createDevice, int deviceId)
 
virtual std::string getDeviceName ()
 

Protected Member Functions

void applyDefaultState () override
 
std::vector< uint8_t > getCreateData () override
 
void handleData (const std::vector< uint8_t > &data) override
 
- Protected Member Functions inherited from arpirobot::ArduinoDevice
void setArduino (BaseArduinoInterface *arduino)
 
void setDeviceId (int deviceId)
 
bool sendData (const std::vector< uint8_t > &data)
 
bool sendData (const std::string &data)
 

Additional Inherited Members

- Static Protected Member Functions inherited from arpirobot::ArduinoDevice
static std::vector< uint8_t > stringToData (const std::string &str)
 
- Protected Attributes inherited from arpirobot::ArduinoDevice
bool createDevice
 
int deviceId
 
std::string deviceName
 
BaseArduinoInterfacearduino = nullptr
 

Detailed Description

MPU6050 IMU https://www.adafruit.com/product/1714

Constructor & Destructor Documentation

◆ Mpu6050Imu()

arpirobot::Mpu6050Imu::Mpu6050Imu ( bool  createDevice = true,
int  deviceId = -1 
)
Parameters
createDeviceLeave this true unless the device is hard-coded in arduino firmware
deviceIdSet this to the hard-coded deviceId if createDevice is false

Member Function Documentation

◆ calibrate()

void arpirobot::Mpu6050Imu::calibrate ( uint16_t  samples)

Calibrate the IMU. Should reduce gyro drift and accelerometer error IMU MUST BE STATIONARY DURING CALIBRATION. GRAVITATIONAL ACCELERATION MUST BE IN NEGATIVE Z DIRECTION DURING CALIBRATION.

Parameters
samplesThe number of samples to take during calibration. More samples may be more accurate, but will take longer.

◆ getAccelX()

double arpirobot::Mpu6050Imu::getAccelX ( )

Get the X axis acceleration

Returns
X acceleration in m/s^2

◆ getAccelY()

double arpirobot::Mpu6050Imu::getAccelY ( )

Get the Y axis acceleration

Returns
Y acceleration in m/s^2

◆ getAccelZ()

double arpirobot::Mpu6050Imu::getAccelZ ( )

Get the Z axis acceleration

Returns
Z acceleration in m/s^2

◆ getGyroX()

double arpirobot::Mpu6050Imu::getGyroX ( )

Get the X rotation

Returns
X rotation in degrees

◆ getGyroY()

double arpirobot::Mpu6050Imu::getGyroY ( )

Get the Y rotation

Returns
Y rotation in degrees

◆ getGyroZ()

double arpirobot::Mpu6050Imu::getGyroZ ( )

Get the Z rotation

Returns
Z rotation in degrees

◆ setGyroX()

void arpirobot::Mpu6050Imu::setGyroX ( double  newGyroX)

Set current X rotation to the given value

Parameters
newGyroXThe new X rotation to set

◆ setGyroY()

void arpirobot::Mpu6050Imu::setGyroY ( double  newGyroY)

Set current Y rotation to the given value

Parameters
newGyroYThe new Y rotation to set

◆ setGyroZ()

void arpirobot::Mpu6050Imu::setGyroZ ( double  newGyroZ)

Set current Z rotation to the given value

Parameters
newGyroZThe new Z rotation to set

The documentation for this class was generated from the following file: