Compass again

Hi,

calibrating the compass proves to be a real challenge. I now enabled my external compass module (HMC5883l) in the APM firmware and mounted it high up (20cm above the electronics) on a mast to minimize influences from the rovers body and electronics.
With the Navios internal compass I sometimes had offsets as high as +/- 300.
With the external module in the current position I get -15, 15, -48. Not bad, but the compass display in MP is really slow (over 30s for a 180° turn) and sometimes after a few circles, north and south are switched.
I thought, maybe it is something I am doing wrong, so I updated my APM2.5 copter (with 3DR external gps/compass) to version APM:copter 3.2.
I did the compass calibration in the same room/location as I did with the rover and the compass display is fast and accurate. I moved the copter in all directions, fast and slow and the compass was still spot on. Both tests/calibrations were done through 3dr radio connections, same settings.
(Ah, something new, now east and west are switched)
Ok, I will try to calibrate the compass outdoors and report back…

Hi Sebastian,
We’ve fixed incorrect orientation for compass on Navio, if you’d like to use it is required to recalibrate it. As for external compass - did you set the orientation for 3DR module?
There should be no difference with HMC on Navio and APM2.5.

I set compass orientation for the HMC to 0.
When did you fix the compass orientation problem? I last updated the apmrover elf a few days ago. Should I use navio or navio-experimental?

I just did a quick test outside.
First with the calibration I did indoors.
9 sats and the rover did one run down an paved farming road in guided mode quite well. On the return run in guided mode it took off in a completly random direction.
I did a calibration 15m away from my car with similar offsets as before. Again completly random driving.
Set compass learn to 1, drove up and down the road for 5min, but the heading displayed in Apmplanner did not get correct.
I then set compass-use to 0 and even then the heading did not follow the gps course.
I did not restart with each new setting, is this necessary?
I will update the apmrover elf as soon as I am home.

Compass orientation in Navio branch was updated 9 days ago. Navio-experimental has ADC battery monitoring for testing. So you could use any branch.

I tested it outside with orientation set to 0 and after calibration it worked perfectly.
For 3DR GPS+compass orientation should also be 0.

Do you have compass mounted with white arrow pointing to the front of the rover?

I have the 3DR gps/compass mounted on my quadcopter. I just used the whole copter to verify if there was something wrong in general with how I did the calibration.
On the rover I have a seperate HMC5883L module and I mounted it like I did, when I was using it with my pixhawk. X arrow to the front, y arrow to the left and z arrow up.

I think, I know why I missed the fixed compass problem. I updated the apmrover elf, but at the same time I changed from the AK8963 to the HMC5883l compass.

Sebastian, I am pretty sure that default axis orientation for APM is with X forward, Y right and Z down.

Yes, it is quite confusing. With the APM2.5/2.6 and the 3DR gps/comapss module, you have to set compass orientation roll 180° as the magnetometer chip is soldered to the underside of the GPS pcb. This is exactly what you said above, x stays the same, but y and z turn 180°. I used the HMC5883l module with my pixhawk, magnetometer chip and markings on top, compass orientation 0, and it worked.

One of you said the navio compass is handled as an external compass. I have the board rotated 180° yaw (AHRS orientation 4), servo connectors on the front. Is the compass rotated too in the firmware, or do I have to set it to 180° yaw with the compass_orient setting?

Anyway, I fear I will drop my rover, if I do another calibration today. The last try with updated apmrover elf did not work either, so I leave it be for now.

Thanks for your help!

Compass in Navio is handled as internal and it is rotated to the board_orientation. So compass_orient stays zero. Can you try it again without the rover so that we can separate the problem? It should work when you rotate it in your hand, can you try that? If it does not there is clearly some config problem.

Yes, I will try this tomorrow. I put the raspberry pi on velcro, so it should be easy to remove it. This way my arms will get a little more time to rest :-).

I think I got it working.
Here is what I did:

  1. Remove the RPi+Navio from the rover
  2. Do the compass calibration again
  3. Swearing
  4. Download the prebuild APMrover2.elf
  5. Reset the APM to defaults
  6. Do the compass calibration again
  7. IT IS WORKING!
  8. Change AHRS orientation to 4
  9. Calibration… still working!
  10. Compare the saved settings with the default settings
  11. Noticed that AHRS_EKF_USE was set to 1 before
  12. Set it to 1 again
  13. Compass goes nuts
  14. Calibration… compass still not working
  15. Disabling NavEKF
  16. Calibration… compass is working again

Should the EKF work with Navio?

The NavEKF seems to have screwed up the GPS, too. I now have a fix with 8 sats indoors about 1 meter away from the window.
The rover icon on the map is moving much less than last time I tried it outdoors.
The rover icon sometimes jumped 50m away without the rover actually moving.

There is no difference for EKF on Navio, it should work, but it is still an experimental feature on APM.

Can you try autonomous driving without EKF? If it works we can explore why EKF screws up orientation. Did you perform accel calibration?

Hm, how do you calibrate the accelerometer in APMrover?
Missionplanner does not show “Accel calibration” under “Initial setup” and in APMPlanner2 it is not working.
Terminal is not working either.

I will try an automission as soon as it stops raining. While the rover should be waterproof, my laptop is not…

The rover is finally working in Auto/Guided/RTL modes. The NavEKF must have been the problem.
It is still not driving a straight line sometimes, but I did not further tune it yet.
It returned to the home point from different directions and distances (300m max) without a problem.
I also did some testing with guided mode and a simple rectangular auto mission, no problem.

Great news! Thank you for your effort in testing!
Did you succeed with internal or external compass?
Any chance for a video?

No problem. Testing is fun. The rover was using the navios internal compass.
I tried to run onboard video recording with the raspicam, but the live video started to stutter. I then ran just the live video to get the testing done.
I will mount my GoPro to the rover, the next time I am letting it loose.

My post here adds quite a bit to this discussion. I’m still working on getting the external HMC5883L working on my quad, but for now using the Navio+ internal compass was the only way to get it working. Happy to share more info as it comes in.