Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mission takeoff fix #46

Merged
merged 2 commits into from
Dec 3, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 19 additions & 18 deletions wadl/mission.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@


class MissionParameters(Parameters):
"""Parameter container for seting missions parameters
"""Parameter container for setting missions parameters

Set paramters directly like how you would for a dictionary.
Set parameters directly like how you would for a dictionary.
``missionParameters = MissionParameters``
``missionParameters["Paramter"] = value``
``missionParameters["Parameter"] = value``

Args:
autoland (bool): land after route
Expand All @@ -31,7 +31,7 @@ class MissionParameters(Parameters):
assign (str): assignment option
N_bands (int): number of altitude bands
band_start (float): starting altitude band
band_step (float): step for the altiude bands
band_step (float): step for the altitude bands
offset_takeoff_dist (float): takeoff offset distance in (m)
offset_landf_dist (float): land offset distance in (m)

Expand Down Expand Up @@ -88,7 +88,7 @@ def __init__(self, missionParamters=None):
}

self.autoland = self.parameters["autoland"]
# altitude bands for vertical seperation
# altitude bands for vertical separation
self.nBands = self.parameters["N_bands"]
bandStep = self.parameters["band_step"]
bandStart = self.parameters["band_start"]
Expand Down Expand Up @@ -139,7 +139,7 @@ def fromSurvey(self, survey, showPlot=False):

# build mission.json header
self.buildMission()
# oraganze and build routes
# organize and build routes
self.buildRoutes(survey)

def fromDirc(self, srcDir):
Expand All @@ -155,7 +155,7 @@ def buildRoutes(self, survey):
routes = self.groupRoutes(survey)
routes = self.sortRoutes(routes)

# start plottng
# start plotting
fig, ax = plt.subplots(figsize=(16, 16))
survey.plotKeyPoints(ax)
cols = plt.cm.rainbow_r(np.linspace(0, 1, self.nBands))
Expand Down Expand Up @@ -251,7 +251,7 @@ def sortRoutes(self, routes):
# route sorting methods
@staticmethod
def headingAngle(route):
# returns the inital heading angle of a route
# returns the initial heading angle of a route
wp = route.waypoints
angle = np.arctan2(wp[1][1]-wp[0][1],
wp[1][0]-wp[0][0])
Expand All @@ -264,7 +264,7 @@ def eastStart(route):
return route.UTMcords[0][0]

@staticmethod
def eastStart(route):
def northStart(route):
# returns the northing of the starting point
route.GPS2UTM()
return route.UTMcords[0][1]
Expand All @@ -285,6 +285,7 @@ def offsetHome(self, home, pt, dist):

# helper functions to build the waypoint lists
def makeRoute(self, name, route, bandAlt=None, home=None):
xferSpd = route[0][3]
failsafe = {"rcLost": "GO_HOME",
"gpsLost": None,
"lowBattery": None,
Expand Down Expand Up @@ -315,8 +316,8 @@ def makeRoute(self, name, route, bandAlt=None, home=None):

# transit in. point camera down
lat, lng, alt, spd = route[0]
alt = alt if bandAlt is not None else bandAlt
pt = self.makePoint(lat, lng, bandAlt)
alt = alt if bandAlt is None else bandAlt
pt = self.makePoint(lat, lng, alt)
routeJson["segments"].append(self.makeWaypoint(pt, spd,
tilt=90, camera=2))

Expand All @@ -330,8 +331,8 @@ def makeRoute(self, name, route, bandAlt=None, home=None):
routeJson["segments"].append(self.makeWaypoint(pt, spd))
# ascend camera forward
lat, lng, alt, spd = route[-1]
alt = alt if bandAlt is not None else bandAlt
pt = self.makePoint(lat, lng, bandAlt)
alt = alt if bandAlt is None else bandAlt
pt = self.makePoint(lat, lng, alt)
routeJson["segments"].append(self.makeWaypoint(pt, spd, tilt=0))

if home is not None:
Expand All @@ -340,18 +341,18 @@ def makeRoute(self, name, route, bandAlt=None, home=None):
offsetPt = self.offsetHome(home, route[1],
self.parameters["offset_takeoff_dist"])
lat, lng, alt, spd = offsetPt
alt = alt if bandAlt is not None else bandAlt
alt = alt if bandAlt is None else bandAlt
pt = self.makePoint(lat, lng, alt)
routeJson["segments"].insert(0, self.makeWaypoint(pt, spd))
routeJson["segments"].insert(0, self.makeWaypoint(pt, xferSpd))

# transfer out
offsetPt = self.offsetHome(home, route[-1],
self.parameters["offset_land_dist"])
lat, lng, alt, spd = offsetPt
alt = alt if bandAlt is not None else bandAlt
alt = alt if bandAlt is None else bandAlt
pt = self.makePoint(lat, lng, alt)
routeJson["segments"].append(self.makeWaypoint(pt, spd))
# pre land
# pre-land
if self.parameters["pre_land_alt"] is not None:
pt = self.makePoint(lat, lng, self.parameters["pre_land_alt"])
routeJson["segments"].append(self.makeWaypoint(pt, 4))
Expand All @@ -375,7 +376,7 @@ def makePoint(lat, lng, alt):

@staticmethod
def makeWaypoint(pt, spd, camera=None, tilt=None):
# make paramter
# make parameter
param = {"avoidObstacles": True,
"avoidTerrain": True,
"speed": spd,
Expand Down