One part of the Aussie Outback challenge rules dictate that the aircraft/GCS must have GPS boundary detection and if the aircraft wanders outside of this boundary then it must go into the spiral of death.
As part of my slow but sure attempt at entering the competition I have created a simple but effective solution to this part of the rules using a Ray casting algorithm and running this on a Netduino in C# (easy to convert to Arduino).
Here is the code to test if the current location falls within a polygon:
public static bool LocationInsideBoundry(Position point, Position[] boundry)
{
bool insideBoundry = false;
try
{
int j = boundry.Length - 1;
for (int i = 0; i < boundry.Length; i++)
{
if (boundry[i].Longitude < point.Longitude && boundry[j].Longitude >= point.Longitude ||
boundry[j].Longitude < point.Longitude && boundry[i].Longitude >= point.Longitude)
{
if (boundry[i].Latitude +
(point.Longitude - boundry[i].Longitude) / (boundry[j].Longitude - boundry[i].Longitude) * (boundry[j].Latitude - boundry[i].Latitude) < point.Latitude)
{
insideBoundry = !insideBoundry;
}
}
j = i;
}
}
catch (Exception)
{
return false;
}
return insideBoundry;
}
Pretty simple stuff and works a treat.
Here is a simple app in .net that shows if the current location is inside the boundary – drag the map around with the right mouse button add some points and if the location is inside the boundary then the group box background will be green – outside then red.
Hopefully it will be of some use.
Cheers
Justin
Comment
Season Two of the Trust Time Trial (T3) Contest has now begun. The fourth round is an accuracy round for multicopters, which requires contestants to fly a cube. The deadline is April 14th.1299 members
48 members
693 members
51 members
249 members
© 2013 Created by Chris Anderson.
Powered by

You need to be a member of DIY Drones to add comments!
Join DIY Drones