Navio2 Yaw Value Issues

Hello,

I am working on a project that uses the Navio2 to record sensor data. When I run the AHRS example it gives me a yaw value that constantly changes when the Navio2 is stationary. Do I need to calibrate a compass or do something to fix this issue? My goal is to be able to record this Yaw, Pitch, Roll data on the Raspberry Pi without connecting to a ground base.

Thanks

Hello.

For yaw drift compensation you need to use magnetometer. But for now AHRS only uses acc and gyro values.

Christian, myself and other have run into this same problem as documented in this post

It contains a link to instructions that outline the calibration procedure needed to get the AHRS to read correct and steady yaw values.

Thank you for the response. I went into Ardupilot and found the offsets for the magnetometer. However, I am having trouble finding where to put them in the AHRS.cpp code.

The issue I am experiencing now is that when I use the Update() method in the AHRS.cpp code, I will turn the navio2 and yaw will drift back to 60 degrees. I have tried subtracting magnetometer offsets from the magnetometer reading in the Update calculation, but it does not change this behavior.

Have you been able to get Yaw working for AHRS?

Thanks!

It’s been a while since I have used the AHRS.cpp code from EMLID and it appears it has been updated since then. The last time I used it, this was the code I had put together:

void imuLoop()
{
	gettimeofday(&ahrs_tv,NULL);
	previoustime = currenttime;
	currenttime = 1000000 * ahrs_tv.tv_sec + ahrs_tv.tv_usec;
	ahrs_dt = (currenttime - previoustime) / 1000000.0;
	if(ahrs_dt < 1/1300.0) usleep((1/1300.0-ahrs_dt)*1000000);
        gettimeofday(&ahrs_tv,NULL);
        currenttime = 1000000 * ahrs_tv.tv_sec + ahrs_tv.tv_usec;
	ahrs_dt = (currenttime - previoustime) / 1000000.0;

	imu.getMotion9(&ax, &ay, &az, &gx, &gy, &gz, &mx, &my, &mz);
// Bench hard iron offsets - RPiB & NAVIO
//     mx-=17.0317;
//     my-=25.7831;
//     mz+=12.5051;

// Installed hard iron offsets - RPiB & NAVIO
//     	mx-=17.9105;
//     	my-=27.4368;
//     	mz+=19.0404;

// Installed hard iron offsets - RPiB+ & NAVIO+
 	mx+=37.4836;
 	my-=212.7862;
 	mz+=8.0719;
 	ahrs.update(ax, ay, az, gx*0.0175, gy*0.0175, gz*0.0175, my, mx, -mz, ahrs_dt);
ahrs.getEuler(&roll, &pitch, &yaw);

if (!isFirst)
	{
		if (ahrs_dt > maxdt) maxdt = ahrs_dt;
		if (ahrs_dt < mindt) mindt = ahrs_dt;
}
	isFirst = 0;
	dtsumm += ahrs_dt;
	if(dtsumm > 0.05)
	{
    	dtsumm = 0;
	}

}
It basically does the same thing you are doing by subtracting the offsets in the update function. This worked for me when I last used it ~2 years ago. Not sure why it doesn’t work for you. Does ardupilot give you the offsets in the same units as the IMU data? If not, that could be causing the problem.

This topic was automatically closed after 119 days. New replies are no longer allowed.