Skip to content

Commit

Permalink
balloon_strategy: start video only once vehicle is armed
Browse files Browse the repository at this point in the history
  • Loading branch information
rmackay9 committed Jun 16, 2014
1 parent 8de1b91 commit fffb481
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions scripts/balloon_strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ def __init__(self):
# start background image grabber
if not self.use_simulator:
balloon_video.start_background_capture()
self.writer = balloon_video.open_video_writer()

# initialise video writer
self.writer = None

# horizontal velocity pid controller. maximum effect is 10 degree lean
xy_p = balloon_config.config.get_float('general','VEL_XY_P',1.0)
Expand Down Expand Up @@ -199,6 +201,17 @@ def check_home(self):
# return whether home has been initialised or not
return self.home_initialised

# checks if video output should be started
def check_video_out(self):

# return immediately if video has already been started
if not self.writer is None:
return

# start video once vehicle is armed
if self.vehicle.armed:
self.writer = balloon_video.open_video_writer()

# check_status - poles vehicle' status to determine if we are in control of vehicle or not
def check_status(self):

Expand Down Expand Up @@ -349,7 +362,8 @@ def analyze_image(self):
self.balloon_pos = balloon_finder.project_position(self.vehicle_pos, self.balloon_pitch, self.balloon_heading, self.balloon_distance)

# save image for debugging later
self.writer.write(f)
if not self.writer is None:
self.writer.write(f)

# start_search - start search for balloon
def start_search(self):
Expand Down Expand Up @@ -533,6 +547,9 @@ def run(self):
# only process images once home has been initialised
if self.check_home():

# start video if required
self.check_video_out()

# check if we are controlling the vehicle
self.check_status()

Expand Down

0 comments on commit fffb481

Please sign in to comment.