def main(request): """HTTP Cloud Function. :param flask.Request request: The request object - http://flask.pocoo.org/docs/1.0/api/#flask.Request """ # initialise Houston client h = Houston(plan="houston-quickstart", api_key=KEY) stage = request.args.get('stage') if stage == "start": # start a new mission and get an ID for it mission_id = h.create_mission() else: mission_id = request.args.get('mission_id') # call houston to start the stage response = h.start_stage(stage, mission_id=mission_id) logging.info(response) # # # # run the main process - depending on the stage name if 'upload-file' in stage: upload_file(request.args.get('file_name')) elif 'run-query' in stage: run_query(request.args.get('query_name')) elif 'build-report' in stage: build_report(request.args.get('source_table')) elif stage == "start": pass else: raise ValueError(f"Didn't know what task to run for stage: '{stage}'") # # # # call houston to end the stage - response from houston will tell us which stages are next response = h.end_stage(stage, mission_id) logging.info(response) # trigger the next stage(s) for next_stage in response['next']: headers = get_authorization_headers( response['params'][next_stage]['uri']) # don't wait for requests to resolve - this allows stages to run concurrently fire_and_forget(response['params'][next_stage]['uri'], headers=headers, params=response['params'][next_stage]) return "stage finished", 200
def __init__(self): rospy.init_node('AUV', anonymous=True) # initialize AUV rosnode rospy.Subscriber( 'kill_switch', Int8, self.kill_switch_callback) # Subscriber for magnet kill switch self.motor_state = None self.tasks = None # self.config = Config() # initialize Config() class self.read_config() # read parameters from the config.ini file self.motor = Motor(self.motor_state) # initialize Motor() class self.navigation = Navigation() # initialize Navigation() class self.keyboard = Keyboard( self.navigation) # initialize Keyboard() class self.houston = Houston(self.navigation, self.tasks) # initialize Houston() class
def __init__(self): rospy.init_node('AUV', anonymous=True) # initialize AUV rosnode #listening to nothing... don't need currently #rospy.Subscriber('kill_switch', Int8, self.kill_switch_callback) # Subscriber for magnet kill switch self.motor_state = None self.tasks = None # self.config = Config() # initialize Config() class # doesn't store everything that's needed. incomplete. self.read_config() # read parameters from the config.ini file self.motor = Motor(self.motor_state) # initialize Motor() class self.navigation = Navigation() # initialize Navigation() class self.keyboard = Keyboard( self.navigation) # initialize Keyboard() class self.houston = Houston(self.navigation, self.tasks) # initialize Houston() class
"query_name": "clean_sales.sql" } }, { "name": "run-query-report", "upstream": ["run-query-clean-customers", "run-query-clean-sales"], "downstream": "build-report", "params": { "psq": ps_topic, "query_name": "report_data.sql" } }, { "name": "build-report", "params": { "psq": ps_topic, "source_table": "report_data" } } ] } # initialise Houston client h = Houston(plan=plan, api_key=KEY) # note: if you want to change an existing plan you'll need to delete it first # h.delete_plan() # save the plan h.save_plan()
class AUV(): """AUV Master, automates tasks""" def __init__(self): rospy.init_node('AUV', anonymous=True) # initialize AUV rosnode rospy.Subscriber( 'kill_switch', Int8, self.kill_switch_callback) # Subscriber for magnet kill switch self.motor_state = None self.tasks = None # self.test self.config = Config() # initialize Config() class self.read_config() self.motor = Motor(self.motor_state) # initialize Motor() class self.navigation = Navigation() # initialize Navigation() class self.keyboard = Keyboard( self.navigation) # initialize Keyboard() class self.status_logger = StatusLogger() # initialize StatusLogger() class # try: self.houston = Houston(self.navigation, self.tasks) # initialize Houston() class # except NameError: # print('Houston is not initialized.') def kill_switch_callback(self, data): if data.data == 1: self.start() if data.data == 0: self.stop() def read_config(self): """ Reads from config/config.ini""" self.motor_state = self.config.get_config( 'auv', 'motor_state') # read motor state from config self.tasks = self.config.get_config('auv', 'tasks') # read tasks from config def keyboard_nav(self): """Navigate the robosub using keyboard controls""" self.keyboard.getch() def perform_tasks(self): """Has houston perform task""" # try: self.houston.start_all_tasks() # except AttributeError: # print('houston not initialized') def specific_task(self, task_num): """Has houston do specific task""" self.houston.do_one_task(task_num) def stop_task(self): """Has houston stop task""" self.houston.stop_task() def display_tasks(self): """Has houston display list of tasks""" self.houston.print_tasks() # def stop_one_task(self, task_num): # self.houston.stop_one_task(task_num) def start(self): """Starts the modules when magnet killswitch is plugged in""" self.motor.start() self.navigation.start() self.keyboard.start() self.status_logger.start() # try: self.houston.start() # except AttributeError: # print('houston not initialized') # self.cv.start(self.tasks) def stop(self): """Stops the modules when magnet killswitch is removed""" self.motor.stop() self.navigation.stop() self.keyboard.stop() self.status_logger.stop() # try: self.houston.stop()
class AUV(): """AUV Master, automates tasks""" def __init__(self): rospy.init_node('AUV', anonymous=True) # initialize AUV rosnode rospy.Subscriber( 'kill_switch', Int8, self.kill_switch_callback) # Subscriber for magnet kill switch self.motor_state = None self.tasks = None # self.config = Config() # initialize Config() class self.read_config() # read parameters from the config.ini file self.motor = Motor(self.motor_state) # initialize Motor() class self.navigation = Navigation() # initialize Navigation() class self.keyboard = Keyboard( self.navigation) # initialize Keyboard() class self.houston = Houston(self.navigation, self.tasks) # initialize Houston() class def kill_switch_callback(self, data): if data.data == 1: self.start() if data.data == 0: self.stop() def open_config(self): """ Opens the config file and updates the parameters""" os.system('gedit config/config.ini') self.update_config() def update_config(self): """ Loads the updated parameters from config""" self.read_config() self.houston.cvcontroller.set_model( ) # read and set all models from config def update_color(self): """ Update RGB/HSV for computer vision from config""" lower_color = config.get_config('cv', 'lower_color') upper_color = config.get_config('cv', 'upper_color') self.houston.cvcontroller.set_lower_color(lower_color[0], lower_color[1:]) self.houston.cvcontroller.set_upper_color(upper_color[0], upper_color[1:]) def read_config(self): """ Reads from config/config.ini""" self.motor_state = config.get_config( 'auv', 'motor_state') # read motor state from config self.tasks = config.get_config('auv', 'tasks') # read tasks from config def keyboard_nav(self): """Navigate the robosub using keyboard controls""" self.keyboard.getch() def perform_tasks(self): """Has houston perform task""" self.houston.start_task('all', None) def specific_task(self, task_num): """Has houston do specific task""" self.houston.start_task('one', task_num) def specific_task_for_gui(self, task_name): """Has houston do specific task from gui""" self.houston.start_task_from_gui('one', task_name) def stop_task(self): """Has houston stop task""" self.houston.stop_task() def display_tasks(self): """Has houston display list of tasks""" self.houston.print_tasks() # def stop_one_task(self, task_num): # self.houston.stop_one_task(task_num) def start(self): """Starts the modules when magnet killswitch is plugged in""" self.motor.start() self.navigation.start() self.keyboard.start() self.houston.start() def stop(self): """Stops the modules when magnet killswitch is removed""" self.motor.stop() self.navigation.stop() self.keyboard.stop() status.stop() self.houston.stop() def save_heading(self): self.navigation.save_current_heading()