def update_parameter_list(self, root, info, **kwargs): application_log.debug(f"Parameter list mutation handler {kwargs}") # TODO iterate over the list and set all the values params = kwargs.get("parameters", []) ret_param_list = [] for param in params: parameter_id = param.get("id") parameter_value = float(param.get("value")) ret = param_set(parameter_id, parameter_value) if ret == parameter_value: # param set worked pass else: # param set failed pass # check to see if the set value matches the provided value ret_param = param_get(parameter_id) application_log.debug( f"param set {parameter_id}:{parameter_value}->{ret_param} {ret}" ) if ret: ret_param_list.append({ "id": parameter_id, "value": ret_param, "meta": self.parameter_meta.get(parameter_id, None), }) return {"parameters": ret_param_list}
def takeoff(self): if self.takeoff: print("Vehicle has already Taken Off") else: try: alt = param.param_get("MIS_TAKEOFF_ALT") print("Taking off at Current Latitude = %3f Longitude = %3f" % (self.latitude, self.longitude)) ret = command.takeoff(min_pitch=0, yaw=0, latitude=self.latitude, longitude=self.longitude, altitude=alt) while self.altitude <= (alt - 0.1): continue self.takeoff = True if not ret.success: utils.fault("Request failed. Check mavros logs") except rospy.ServiceException as ex: utils.fault(ex) print("Takeoff Command result: %s" % (self.takeoff == True))
def update_parameter(self, root, info, **kwargs): parameter_id = kwargs.get("id") parameter_value = kwargs.get("value") parameter_meta = self.parameter_meta.get(parameter_id, None) parameter_type = kwargs.get("type", None) if parameter_type and parameter_meta: self.parameter_meta[parameter_id]["type"] = parameter_type parameter_meta = self.parameter_meta.get(parameter_id, None) application_log.debug( f"Parameter mutation handler {kwargs} root:{root} info:{info} meta:{parameter_meta}" ) if (root is None) and (info is None): # The call came from the api, don't action as a param change request self.parameter_data[parameter_id] = parameter_value self.subscriptions.emit( "maverick_api.modules.api.mavros.ParamSchema" + "Parameter", { "Parameter": { "id": parameter_id, "value": parameter_value, "meta": parameter_meta, } }, ) else: ret = param_set(parameter_id, float(parameter_value)) if ret == parameter_value: # param set worked pass else: # param set failed pass # check to see if the set value matches the provided value ret_param = param_get(parameter_id) application_log.debug("param set {0}:{1} {2}".format( parameter_id, parameter_value, ret)) application_log.debug("{0}".format(ret_param)) return {"id": parameter_id, "value": parameter_value}