Skip to content

Commit

Permalink
Plugin to make Terrain DAT file for copying to the SD card of the fli…
Browse files Browse the repository at this point in the history
…ght controller
  • Loading branch information
EosBandi authored and meee1 committed Sep 19, 2024
1 parent 3fbc606 commit 6050a04
Show file tree
Hide file tree
Showing 5 changed files with 892 additions and 5 deletions.
17 changes: 12 additions & 5 deletions MissionPlanner.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.3.32811.315
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MissionPlanner", "MissionPlanner.csproj", "{A2E22272-95FE-47B6-B050-9AE7E2055BF5}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MissionPlanner", "MissionPlanner.csproj", "{A2E22272-95FE-47B6-B050-9AE7E2055BF5}"
ProjectSection(ProjectDependencies) = postProject
{DF86AFC2-CA79-4137-9BB5-70AA529C3B79} = {DF86AFC2-CA79-4137-9BB5-70AA529C3B79}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Updater", "Updater\Updater.csproj", "{E64A1A41-A5B0-458E-8284-BB63705354DA}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Updater", "Updater\Updater.csproj", "{E64A1A41-A5B0-458E-8284-BB63705354DA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "wix", "wix\wix.csproj", "{76374F95-C343-4ACC-B86F-7ECFDD668F46}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "wix", "wix\wix.csproj", "{76374F95-C343-4ACC-B86F-7ECFDD668F46}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Plugins", "Plugins", "{9B3AC501-5FCB-4A2A-A628-BE0985DB2BD4}"
EndProject
Expand Down Expand Up @@ -83,7 +83,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ExtGuided", "ExtLibs\ExtGui
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LibVLC.NET", "ExtLibs\LibVLC.NET\LibVLC.NET.csproj", "{BB06DFF7-4F41-4B9D-A3C3-3B6D2B8702B6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SikRadio", "SikRadio\SikRadio.csproj", "{B8943726-04B0-4477-BFDA-E156A0CD98A4}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SikRadio", "SikRadio\SikRadio.csproj", "{B8943726-04B0-4477-BFDA-E156A0CD98A4}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ManagedNativeWifi.Simple", "ExtLibs\ManagedNativeWifi.Simple\ManagedNativeWifi.Simple.csproj", "{CCE510F7-1DA6-40F2-8921-B86ED41BB85E}"
EndProject
Expand Down Expand Up @@ -219,10 +219,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenDroneID_Plugin", "Plugi
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bulb", "ExtLibs\LEDBulb\Bulb\Bulb.csproj", "{AF81C41B-06E6-4CA5-9FD4-A4E7042F1107}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MissionPlannerTests", "MissionPlannerTests\MissionPlannerTests.csproj", "{0B99EBF2-B964-4AAC-9EC5-76353610AAAE}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MissionPlannerTests", "MissionPlannerTests\MissionPlannerTests.csproj", "{0B99EBF2-B964-4AAC-9EC5-76353610AAAE}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MockDroneID", "ExtLibs\MockDroneID\MockDroneID.csproj", "{6D39C141-733B-4C4A-87AB-974637952D1B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TerrainMakerPlugin", "Plugins\TerrainMakerPlugin\TerrainMakerPlugin.csproj", "{DDD2FEA8-801E-463B-8913-9CCCDA2D9429}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -550,6 +552,10 @@ Global
{6D39C141-733B-4C4A-87AB-974637952D1B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6D39C141-733B-4C4A-87AB-974637952D1B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6D39C141-733B-4C4A-87AB-974637952D1B}.Release|Any CPU.Build.0 = Release|Any CPU
{DDD2FEA8-801E-463B-8913-9CCCDA2D9429}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DDD2FEA8-801E-463B-8913-9CCCDA2D9429}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DDD2FEA8-801E-463B-8913-9CCCDA2D9429}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DDD2FEA8-801E-463B-8913-9CCCDA2D9429}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -635,6 +641,7 @@ Global
{FBE658B3-684D-46E6-8668-50DEF0778538} = {9B3AC501-5FCB-4A2A-A628-BE0985DB2BD4}
{AF81C41B-06E6-4CA5-9FD4-A4E7042F1107} = {7E264F12-9EC3-4CDC-A187-6879C2B2BFCF}
{6D39C141-733B-4C4A-87AB-974637952D1B} = {0371886E-5A61-4626-B9E0-50A837ECE2DD}
{DDD2FEA8-801E-463B-8913-9CCCDA2D9429} = {9B3AC501-5FCB-4A2A-A628-BE0985DB2BD4}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {FD2C9507-1A09-4F5B-98AB-B6B194A4B260}
Expand Down
125 changes: 125 additions & 0 deletions Plugins/TerrainMakerPlugin/Location.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static IronPython.Modules.PythonThread;

namespace TerrainMakerPlugin
{
public class Location
{


const double LOCATION_SCALING_FACTOR = 0.011131884502145034;
const double LOCATION_SCALING_FACTOR_INV = 89.83204953368922;

// note that mission storage only stores 24 bits of altitude (~ +/- 83km)
public Int32 lat; // in 1E7 degrees
public Int32 lng; // in 1E7 degrees


public Location()
{
lat = 0;
lng = 0;
}

public Location(Int32 lat, Int32 lng)
{
this.lat = lat;
this.lng = lng;
}



// return horizontal distance in meters between two locations
public double get_distance(Location loc2)
{
double dlat = (double)(loc2.lat - lat);
double dlng = ((double)diff_longitude(loc2.lng, lng)) * longitude_scale((lat + loc2.lat) / 2);

return Math.Sqrt(dlat*dlat + dlng*dlng) * LOCATION_SCALING_FACTOR;
}


public double longitude_scale(Int32 lat)
{

double scale = Math.Cos(lat * (1.0e-7 * (Math.PI / 180.0)));
return Math.Max(scale, 0.01);
}

/*
get lon1-lon2, wrapping at -180e7 to 180e7
*/
public Int32 diff_longitude(Int32 lon1, Int32 lon2)
{
if ((lon1 & 0x80000000) == (lon2 & 0x80000000))
{
// common case of same sign
return lon1 - lon2;
}
long dlon = (long)lon1 - (long)lon2;
if (dlon > 1800000000L)
{
dlon -= 3600000000L;
}
else if (dlon < -1800000000L)
{
dlon += 3600000000L;
}
return (Int32)dlon;
}


/*
return the distance in meters in North/East plane as a N/E vector
from loc1 to loc2
*/
public Vector2d get_distance_NE(Location loc2)
{

Vector2d retvect = new Vector2d((loc2.lat - lat) * LOCATION_SCALING_FACTOR,
diff_longitude(loc2.lng, lng) * LOCATION_SCALING_FACTOR * longitude_scale((loc2.lat + lat) / 2));

return retvect;
}


// extrapolate latitude/longitude given distances (in meters) north and east
public Location add_offset_meters(double ofs_north, double ofs_east)
{
double dlat = ofs_north * LOCATION_SCALING_FACTOR_INV;
double dlng = (ofs_east * LOCATION_SCALING_FACTOR_INV) / longitude_scale((Int32)(lat + dlat / 2));

Location retval = new Location(lat + (Int32)dlat, (Int32)(dlng + lng));

return retval;

}


}


public class Vector2d
{
public double x;
public double y;


public Vector2d(double x, double y)
{
this.x = x;
this.y = y;
}




}



}
Loading

0 comments on commit 6050a04

Please sign in to comment.