Skip to content

This library is for the receiver end of the Razor 9-DOF IMU.

Notifications You must be signed in to change notification settings

shashank3199/RazorIMU_9DOF

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Version tag

Introduction

This library is for the receiver end of the Razor 9 DOF IMU (reference here.

Index

User guide

Downloading the library

It is suggested that you download the entire repository and then select this folder, so that you can enjoy the benifits of VCS like git. It makes it simpler to update the contents whenever patch fixes are done. You can simply open a terminal (or gitbash on windows), go to the folder where you want to save this repository and type the following command.

	git clone https://github.com/shashank3199/RazorIMU_9DOF

Not recommended: You can download only this folder by clicking here

Using the library with Arduino

Move this folder into the arduino libraries folder on your PC. If you don't know where the libraries folder of your arduino is, you can check out the README file of this entire repository for this, click here.

Prerequisites

Please follow the following steps before working with this library:

  • Download the official code folder from here, you'll be uploading this to the IMU.
  • Extract folder Razor_AHRS to an appropriate location, open the Razor_AHRS file in Arduino IDE.
  • Under the tools dropdown, select the following:
    • Board: Arduino Pro or Pro Mini
    • Processor: Atmega 328P (3.3V, 8MHz)
    • Port: The connected port (/dev/ttyUSB* for Ubuntu, COM* for windows).
  • In the code of Razor_AHRS file, go to USER SETUP AREA and uncomment the correct #define HW__VERSION_CODE. It's 10736 in our examples, check the version from the correct hardware datasheet.
  • Upload the code.
  • Open serial monitor
  • Set baud rate to 57600
  • There must be output

More info about setting up software here.

Usage of the library

In order to use this library, you must do the following:

  • Include the header file RazorIMU_9DOF.h (the RazorIMU_9DOF library folder must be in your arduino libraries folder).
  • Create an object of class RazorIMU_9DOF. You can pass the constructor parameters to initialize here itself, or leave it as a simple object declaration.
  • Initialize the Serial stream on which the IMU is attached using the AttachIMUSerial function.
  • To avoid wastage of resources, the library doesn't continuously poll the serial. You must call the function UpdateData for the library to fetch the values from the serial.
  • To get the values, you can use one of the getter functions, for example if you want to access the YAW value, then you could use the function: GetYaw which will give you the continuous YAW value.

Examples

Get_RPY_values

This example is to show you how to fetch YAW, PITCH and ROLL values from the IMU using the RazorIMU_9DOF library.
File: ./examples/Get_RPY_values/Get_RPY_values.ino
We simply follow the following steps:

  1. Include library
  2. Create object
  3. Initialize Serials. IMU on Serial1. Keep in mind to match the baud rates.
  4. Attach the serial of the IMU
  5. Then start a loop
    1. Update the data readings from IMU
    2. Get YAW, PITCH and ROLL values
  6. Re-run the loop

Developers Guide

This library has a single class named RazorIMU_9DOF. Let's explore all the contents in detail.

Library Details

Files in the library

RazorIMU_9DOF.h

The header file for the RazorIMU_9DOF class. It only has function declarations, not definitions.

RazorIMU_9DOF.cpp

This file consists the code for all the functions declared in the RazorIMU_9DOF class.

keywords.txt

This file consists the list of keywords and their types to be recognized by the Arduino IDE.

README.md

The description file that you're currently reading. All documentation here.

Class contents

Let's explore the contents of the class, but first, we also have literals defined for general purpose use (using #define). They are:

Name Value Purpose
PITCH 0 The index of pitch values in arrays
ROLL 1 The index of roll values in arrays
YAW 2 The index of yaw values in arrays

Let's explore the class now

Protected members

Variables
  • float YPR_values[3]: Stores the values (-180 to 180, as output by the module) of Roll, Pitch and Yaw.
  • Stream *IMU_Serial: This is the serial on which IMU operates. The parent Stream class allows any kind of serial, Hardware or Software.

Public members

Constructors

  • RazorIMU_9DOF(): Empty constructor for the class.
  • RazorIMU_9DOF(Stream *AttachedSerial): To attach a pre-initialized serial to the IMU. This function calls the AttachIMUSerial member function.

Member functions

  • void AttachIMUSerial(Stream *AttachedSerial): Connect the IMU Serial.
  • void UpdateData(): Updates the IMU readings stored in variables of the class.
  • float GetRoll(): To get the continuous ROLL values.
  • float GetPitch(): To get the continuous PITCH values.
  • float GetYaw(): To get the continuous YAW values.

Developers Tag

About

This library is for the receiver end of the Razor 9-DOF IMU.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages