Horizontal Axis Data

In a previous post I discussed interfacing with the BNO055 9DOF sensor. We discussed how to use the BNO055 to get vertical or “up and down” data for our robotic arm.

Today we will discuss how to get “left and right” or horizontal data. I decided to make this its own post because horizontal motion actually involves 2 axis the x-axis and the y-axis. Which contrasts with gathering “up and down” data which simply uses change in the z-axis. I will explain bellow why horizontal data actually incorporates the x and y-axis.

Horizontal Motion 1
Y-Axis Dominant

The picture above shows the instance when horizontal motion is dominated by changes in the y-axis. Remember their is only one servo that moves left and right while the other servo moves up and down. In this case the servo that goes up and down is all the way down. The other servo, the one that goes left to right is now going to sweep as the y-axis changes. This is simple enough to understand.

Horizontal Motion 2
X-Axis Dominant

This picture obviously is the other extreme, when change in the x-axis best expresses changes in our horizontal plane. In this state the arm is at a 90 degree angle from the body, thus we will be sweeping the arm from “front to back”.

Now the next question is what happens in between these two states? What can we use to govern which axis best expresses horizontal change, if say we are half way between 0 and 90 degrees on our “up and down” plane?

The answer lies in the z-axis. Notice that when the x-axis is dominant the z-axis is parallel to the force of gravity, while when the y-axis is dominant the z-axis is orthogonal or 90 degrees from gravity. Now to sense this the awesomeness of the BNO055 comes into play. The BNO055 can actually tell us how much gravity is in each axis. Before looking at the code lets develop the actual formula for Horizontal change.

Horizontal Change Formula
Horizontal Change Formula

Now the formula is pretty self explanatory. When the percent of gravity in the z-azis is at 100% or 1 then we only look at the x-axis change. The reason we have one minus in front of our gravity percentage for the y-axis, is because when the z-axis is orthogonal to gravity the percent of gravity is 0 thus we need 1-0 to get 1 and now all our focus is on the y-axis.

Finally lets talk about how to actually get all these pieces of data. We will need amount of gravity on the z-axis, change in the x-axis, and change in the y-axis. For change in the y-axis you can take a look at the tutorial for gathering change in the z-axis. The methodology is exactly the same. But for gathering change in the x-axis we simply use the function I made bellow.

Change in x-axis
X-Axis Change

The multiplication constant of 2 is used just because the BNO055 data was changing too slow. So for accuracy this constant had to be added.

The next post will show horizontal and vertical data being used to control both servos! Make sure you take a look at my other post discussing how to talk to the servos using the Lynx Motion Servo Controller.

Thanks for reading!

Leave a comment