Request for battery on start

This commit is contained in:
artem30801@gmail.com
2019-03-25 16:53:05 +03:00
parent a08a6267f0
commit 8551933cd6
4 changed files with 16 additions and 9 deletions

View File

@@ -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)})))

View File

@@ -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

View File

@@ -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