Skip to content

Commit

Permalink
MagCalib: fix mag cal on apm2
Browse files Browse the repository at this point in the history
  • Loading branch information
meee1 committed Feb 5, 2017
1 parent 1d840eb commit 3a0a86b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions MagCalib.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1154,7 +1154,7 @@ public static void SaveOffsets(double[] ofs)
MainV2.comPort.GetParam("COMPASS_OFS_Z");
}

if (ofs.Length > 3)
if (ofs.Length > 3 && MainV2.comPort.MAV.param.ContainsKey("COMPASS_DIA_X"))
{
// ellipsoid
MainV2.comPort.setParam("COMPASS_DIA_X", (float)ofs[3]);
Expand Down Expand Up @@ -1209,7 +1209,7 @@ public static void SaveOffsets2(double[] ofs)
MainV2.comPort.GetParam("COMPASS_OFS2_Y");
MainV2.comPort.GetParam("COMPASS_OFS2_Z");
}
if (ofs.Length > 3)
if (ofs.Length > 3 && MainV2.comPort.MAV.param.ContainsKey("COMPASS_DIA2_X"))
{
// ellipsoid
MainV2.comPort.setParam("COMPASS_DIA2_X", (float)ofs[3]);
Expand Down Expand Up @@ -1252,7 +1252,7 @@ public static void SaveOffsets3(double[] ofs)
MainV2.comPort.setParam("COMPASS_OFS3_Y", (float)ofs[1]);
MainV2.comPort.setParam("COMPASS_OFS3_Z", (float)ofs[2]);
}
if (ofs.Length > 3)
if (ofs.Length > 3 && MainV2.comPort.MAV.param.ContainsKey("COMPASS_DIA3_X"))
{
// ellipsoid
MainV2.comPort.setParam("COMPASS_DIA3_X", (float)ofs[3]);
Expand Down

0 comments on commit 3a0a86b

Please sign in to comment.