# Our ROS node main entry point. Starts up the node and then waits forever. if __name__ == '__main__': if TRACE: rospy.init_node("recipe_handler", log_level=rospy.DEBUG) pub_debug = rospy.Publisher('debug/recipe_handler', \ String, queue_size=10) else: rospy.init_node("recipe_handler") db_server = config["local_server"]["url"] if not db_server: raise RuntimeError("No local database specified") server = Server(db_server) namespace = rospy.get_namespace() environment = read_environment_from_ns(namespace) recipe_handler = RecipeHandler(server, environment) recipe_handler.register_services() recipe_handler.recover_any_previous_recipe() # Subscribe to our own 'recipe_end' message so we can stop publishing # and clear the recipe when we get it. topic_name = "{}/desired".format(RECIPE_END.name) def callback(data): try: recipe_handler.clear_recipe() except RecipeIdleError: pass trace("recipe_handler.Subscriber: clearing current recipe.") sub = rospy.Subscriber(topic_name, String, callback)
if __name__ == '__main__': db_server = cli_config["local_server"]["url"] if not db_server: raise RuntimeError("No local database specified") server = Server(db_server) rospy.init_node('sensor_persistence') try: max_update_interval = rospy.get_param("~max_update_interval") except KeyError: rospy.logwarn( "No maximum update interval specified for sensor persistence " "module" ) max_update_interval = 600 try: min_update_interval = rospy.get_param("~min_update_interval") except KeyError: rospy.logwarn( "No minimum update interval specified for sensor persistence " "module" ) min_update_interval = 5 environment_id = read_environment_from_ns(rospy.get_namespace()) create_persistence_objects( server, environment_id, max_update_interval=max_update_interval, min_update_interval=min_update_interval ) rospy.spin()
headers = { "Content-Type": "image/png" } res = requests.put(url, data=buf, headers=headers) if res.status_code != 201: raise RuntimeError( "Failed to post image to database: {}".format(res.content) ) if __name__ == '__main__': db_server = cli_config["local_server"]["url"] if not db_server: raise RuntimeError("No database server specified") server = Server(db_server) rospy.init_node('image_persistence_1') environment_id = read_environment_from_ns(rospy.get_namespace()) try: min_update_interval = rospy.get_param("~min_update_interval") except KeyError: rospy.logwarn( "No minimum update interval specified for image persistence module" ) min_update_interval = 3600 env_var_db = server[ENVIRONMENTAL_DATA_POINT] persistence_objs = [] for variable in CAMERA_VARIABLES.itervalues(): topic = "{}/image_raw".format(variable) persistence_objs.append(ImagePersistence( db=env_var_db, topic=topic, variable=variable, environment=environment_id, min_update_interval=min_update_interval
# Our ROS node main entry point. Starts up the node and then waits forever. if __name__ == '__main__': if TRACE: rospy.init_node("recipe_handler", log_level=rospy.DEBUG) pub_debug = rospy.Publisher('debug/recipe_handler', \ String, queue_size=10) else: rospy.init_node("recipe_handler") db_server = config["local_server"]["url"] if not db_server: raise RuntimeError("No local database specified") server = Server(db_server) namespace = rospy.get_namespace() environment = read_environment_from_ns(namespace) recipe_handler = RecipeHandler(server, environment) recipe_handler.register_services() recipe_handler.recover_any_previous_recipe() # Subscribe to our own 'recipe_end' message so we can stop publishing # and clear the recipe when we get it. topic_name = "{}/desired".format(RECIPE_END.name) def callback(data): try: recipe_handler.clear_recipe() except RecipeIdleError: pass trace("recipe_handler.Subscriber: clearing current recipe.") sub = rospy.Subscriber(topic_name, String, callback)