## Calculation of Hedge Axis Rotation by Quaternion _Starter Set HW v4.9-IMU

Jason_L
Posts: 9
Joined: Mon Jul 22, 2019 9:28 am

### Calculation of Hedge Axis Rotation by Quaternion _Starter Set HW v4.9-IMU

Hi everyone:

I am doing a project tracking a moving person's location and orientation to several points fixed in reference frame by a Hedge. Code is conducted under Python 3.5/3.7. So I build a map by 4 static Beacons for the reference frame, and using the quaternion through IMU data to compute the data I want. There are several problems that confuse me and need to be clarified by you.
1. The quaternion received by ''valuesImuData" seems to be related to the orientation at the time powering the Hedge. In other word, it treats the orientation when powering on the hedge as zero point. I did some experiment that place the hedge on table, switch on the hedge and switch off the hedge, then rotate some angle only by z axis, and switch on again. I found every time switching on the hedge, the angle to z axis is zero. It has nothing to do with the reference frame build in DashBoard. If that is the case, every time starting the hedge, it need to be align with the frame built in DashBoard to initiate body frame on hedge. I am not sure the situation above is correct. Hedge is fully calibrated according to the Manual. Angle obtained by the following code

Code: Select all

``````def quaternionToEulerianAngle(self,q):
if isinstance(q, np.ndarray):
q=q
elif isinstance(q, list):
q=np.asarray(q)
w, x, y, z = q
ysqr = y*y

t0 = +2.0 * (w * x + y*z)
t1 = +1.0 - 2.0 * (x*x + ysqr)
X = math.degrees(math.atan2(t0, t1))

t2 = +2.0 * (w*y - z*x)
t2 =  1 if t2 > 1 else t2
t2 = -1 if t2 < -1 else t2
Y = math.degrees(math.asin(t2))

t3 = +2.0 * (w * z + x*y)
t4 = +1.0 - 2.0 * (ysqr + z*z)
Z = math.degrees(math.atan2(t3, t4))

return X, Y, Z ``````
2. During my experiment, the angle about Z axis becomes bigger and bigger at a very slow step, even I did not touch the hedge, and even I pressed the Zero IMU button several times, the situation only happens on Z axis. Can you suggest any other methods can solve this problem?
Here is the settings of hedge and a video of increasing angle
[img][/img]
[img][/img]
https://youtu.be/heNdkywp5ko

Please feel free to let me know what need to be report further more.

Jason_L
Posts: 9
Joined: Mon Jul 22, 2019 9:28 am

### Re: Calculation of Hedge Axis Rotation by Quaternion _Starter Set HW v4.9-IMU

Update:

I set up the beacons in a bigger room (6m * 6m), all 4 beacons are put on corner of walls and above mobile hedge about 2.5m. In suspicion of hedge broken, I also try on another mobile hedge, put it on table, no touch. Everything looks very good except the rotation angle around Z axis keeps increasing or dropping. Also I found the initial (zero) Z axis rotation angle depends on the powering position or the position when I press reset button on hedge.
Another question I want to ask that is there a command that can reset all output quaternion which I can set a initial position

smoker77
Posts: 312
Joined: Sat Feb 06, 2016 4:03 pm

### Re: Calculation of Hedge Axis Rotation by Quaternion _Starter Set HW v4.9-IMU

Hello,
1. Yes, every time after reset hedgehog starts angle around Z from zero, because it can't know real angle from some source. So quaternion gives orientation relative to some startup state.
2. Slow change of angle around Z axis is caused by gyroscope drift. This drift can be compensated by 'Zero IMU' button, but after some time it may return again. Drift around Y and X axes is automatically compensated by accelerometer.

If you need orientation around Z axis (yaw angle), we recommend to use paired beacons feature instead quaternion. Please refer to operating manual for details. IMU fusion location is also work better with paired mobile beacons instead one mobile beacon.

Jason_L
Posts: 9
Joined: Mon Jul 22, 2019 9:28 am

### Re: Calculation of Hedge Axis Rotation by Quaternion _Starter Set HW v4.9-IMU

smoker77 wrote:Hello,
1. Yes, every time after reset hedgehog starts angle around Z from zero, because it can't know real angle from some source. So quaternion gives orientation relative to some startup state.
2. Slow change of angle around Z axis is caused by gyroscope drift. This drift can be compensated by 'Zero IMU' button, but after some time it may return again. Drift around Y and X axes is automatically compensated by accelerometer.

If you need orientation around Z axis (yaw angle), we recommend to use paired beacons feature instead quaternion. Please refer to operating manual for details. IMU fusion location is also work better with paired mobile beacons instead one mobile beacon.
Hello, smoker77:

Thanks for your reply, does the IMU fusion angle under the Paired option output the yaw angle around the Z axis which is established on the center point of the two paired beacons?

smoker77
Posts: 312
Joined: Sat Feb 06, 2016 4:03 pm

### Re: Calculation of Hedge Axis Rotation by Quaternion _Starter Set HW v4.9-IMU

Hello,
Angle by paired beacons feature provides absolute yaw angle in XY coordinates system of the map:
- If both beacons are along X axis and the direction of the pair is along Y axis, the angle is 0 degrees
- If both beacons are along Y axis and the direction of the pair is opposite to X axis, the angle is 90 degrees
- If both beacons are along X axis and the direction of the pair is opposite to Y axis, the angle is 180degrees
- If both beacons are along Y axis and the direction of the pair is along X axis, the angle is 270 degrees
and so on