Skip to content

PIXHAWK: Inertial Measurement Unit

Abhi10arora edited this page Oct 27, 2017 · 1 revision

Maintainers: Abhinav Arora and Varun Pawar

IMU

Inertial Measurement Unit is a device which tells us about the motion of the body it is attached to. Basically, an IMU consists of an accelerometer, magnetometer and gyroscope. Each one of them gives some data which is used to study the motion of the body and to localize its position.

To know more about the working of the IMU a good place to read up on the basics and the math involved can be understood here. On the mentioned link you would also be able to find a simple algorithm which can be used to reduce the bias errors from the measurements we get from the IMU. Here is a report which talks about different kinds of errors and noises which one encounter while taking and processing the data from an IMU.

Filters for data processing

Filters are data algorithms used to process the data and remove the errors that accompany with any data. Here we have to calculate linear and angular displacements of the body attached to the IMU, but we have linear acceleration, angular velocity and the magnetometer readings from the IMU. So, we have to integrate the data to get the results. But, we have to twice integrate the values of linear accelerations to get the displacements, which will produce a lot of error in the results. So, some standard filters are used to get displacements.

One of them is EKF. There is a standard ROS package Robot_pose_Ekf which can be used to get the output directly from the input of the sensors. Other popular algorithm is AHRS. It applies DCM filter on quateranion form of data.

PIXHAWK

These days IMU's come with the above mentioned filters in their firmwares. The one we are using in our bot is PIXHAWK. It is a flight controller which has many sensors inside it. With the help from some other devices, it is used in executing and studying flight motions. There are many algorithms that runs in it which processes data outputs from various sensors and use the processed data for various motions of the flight. Similarly, it has an IMU as well. It applies EKF and AHRS algorithms on the IMU's data and gives the output in form of quateranions to us.

Retrieving data from PIXHAWK

Ensure you have the software packages required. If not then download them be referring to our wiki page. To use PIXHAWK with ROS install Mavros package from the Readme.md file.

  1. Go down to the Binary Installation title and run the command sudo apt-get install ros-kinetic-mavros ros-kinetic-mavros-extras for Ubuntu Kinetic (for ubuntu indigo replace indigo with kinetic in the command).

  2. After this installation plug-in PIXHAWK in your laptop and run the command 'ls /dev and find ttyACMn file where n is any whole number.

  3. Now start ROS with roscore and in ttyACMn file if n = 0(say), then run the command rosrun mavros mavros_node _fcu_url:=/dev/ttyACM0:921600 _gcs_url:=udp://@172.16.254.1.

  4. Now run the command rostopic list to see all the topics from which data can be extracted from PIXHAWK.

  5. Run the command rostopic echo /mavros/data/imu to see the quateranion output, angular velocity and magnetometer readings from the PIXHAWK.

  6. So now make a subscriber of /mavros/imu/data topic which has sensor_msgs/IMU as its message type. Take the quateranion output and convert it into euclidean form for getting YAW ANGLE by using this formula yaw = atan2(2*x*y-2*w*z, 2*w*w+2*x*x-1).

QGround Control

Download QGround Control and run it with PIXHAWK attached with your computer. It is a portal from where you control various settings of the PIXHAWK. To calibrate the magnetometer, accelerometer and gyroscope you can access the SENSORS tab in the settings and callibrate them as per the instructions.