From 8551933cd6f50050839110ebd7f0c4652f7cedfe Mon Sep 17 00:00:00 2001 From: "artem30801@gmail.com" Date: Mon, 25 Mar 2019 16:53:05 +0300 Subject: [PATCH] Request for battery on start --- Drone/FlightLib | 2 +- Drone/client.py | 16 ++++++++++------ Drone/client_config.ini | 1 + Server/server_qt.py | 6 ++++-- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/Drone/FlightLib b/Drone/FlightLib index 701e7aa..9993d88 160000 --- a/Drone/FlightLib +++ b/Drone/FlightLib @@ -1 +1 @@ -Subproject commit 701e7aa4e12bb99b5ddf05ad40ad198f17ed583a +Subproject commit 9993d88fdcc19f5684fd2db58c8ffa76bb38e34d diff --git a/Drone/client.py b/Drone/client.py index d575827..297658c 100644 --- a/Drone/client.py +++ b/Drone/client.py @@ -132,12 +132,14 @@ def recive_file(filename): print("File received") break file.write(data) + else: + break def animation_player(running_event, stop_event): print("Animation thread activated") frames = play_animation.read_animation_file() - rate = rospy.Rate(1000 / 125) + # rate = rospy.Rate(1000 / 125) delay_time = 0.125 print("Takeoff") @@ -200,8 +202,7 @@ def stop_animation(): def selfcheck(): - telemetry = FlightLib.get_telemetry('body') - return FlightLib.selfcheck(), telemetry.voltage + return FlightLib.selfcheck() def write_to_config(section, option, value): @@ -215,7 +216,7 @@ def load_config(): global broadcast_port, port, host, BUFFER_SIZE global USE_NTP, NTP_HOST, NTP_PORT global files_directory, animation_file - global TAKEOFF_HEIGHT, TAKEOFF_TIME, SAFE_TAKEOFF, RFP_TIME + global FRAME_ID, TAKEOFF_HEIGHT, TAKEOFF_TIME, SAFE_TAKEOFF, RFP_TIME global USE_LEDS, COPTER_ID CONFIG_PATH = "client_config.ini" config = ConfigParser.ConfigParser() @@ -232,6 +233,7 @@ def load_config(): files_directory = config.get('FILETRANSFER', 'files_directory') animation_file = config.get('FILETRANSFER', 'animation_file') + FRAME_ID = config.get('COPTERS', 'frame_id') # TODO in play_animation TAKEOFF_HEIGHT = config.getfloat('COPTERS', 'takeoff_height') TAKEOFF_TIME = config.getfloat('COPTERS', 'takeoff_time') RFP_TIME = config.getfloat('COPTERS', 'reach_first_point_time') @@ -308,9 +310,11 @@ try: elif request_target == 'id': response = COPTER_ID elif request_target == 'selfcheck': - response = selfcheck() + response = FlightLib.selfcheck() elif request_target == 'batt_voltage': - pass # TODO + response = FlightLib.get_telemetry('body').voltage + elif request_target == 'cell_voltage': + response = FlightLib.get_telemetry('body').cell_voltage send_all(bytes(form_message("response", {"status": "ok", "value": response, "value_name": str(request_target)}))) diff --git a/Drone/client_config.ini b/Drone/client_config.ini index 4af3c49..1a63ad8 100644 --- a/Drone/client_config.ini +++ b/Drone/client_config.ini @@ -14,6 +14,7 @@ host = ntp1.stratum2.ru port = 123 [COPTERS] +frame_id = aruco_map takeoff_height = 1.5 takeoff_time = 8.0 safe_takeoff = False diff --git a/Server/server_qt.py b/Server/server_qt.py index 4efd795..1c9ca13 100644 --- a/Server/server_qt.py +++ b/Server/server_qt.py @@ -116,8 +116,10 @@ model.setColumnCount(6) model.setRowCount(0) -def client_connected(self): - model.appendRow((QStandardItem(self.copter_id),)) # TODO: get responses for another columns +def client_connected(self: Client): + batt = self.get_response("batt_voltage") + model.appendRow((QStandardItem(self.copter_id), QStandardItem(batt))) # TODO: get responses for another columns + Client.on_connect = client_connected