Skip to content

Commit

Permalink
Merge branch 'master' into pinocchio_work
Browse files Browse the repository at this point in the history
  • Loading branch information
goldarte committed Oct 23, 2019
2 parents b5b5aac + 5d97ca2 commit a46984d
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 9 deletions.
2 changes: 2 additions & 0 deletions Drone/client.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import time
import errno
import random
Expand Down Expand Up @@ -74,6 +75,7 @@ def load_config(self):
def rewrite_config(self):
with open(self.config_path, 'w') as file:
self.config.write(file)
os.system("chown -R pi:pi /home/pi/clever-show")

def write_config(self, reload_config=True, *config_options):
for config_option in config_options:
Expand Down
4 changes: 2 additions & 2 deletions Drone/client_config.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

[SERVER]
port = 25000
broadcast_port = 8181
Expand Down Expand Up @@ -48,5 +49,4 @@ use_leds = False
led_pin = 21
x0 = 0
y0 = 0
z0 = 0

z0 = 0
14 changes: 11 additions & 3 deletions Drone/copter_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,10 +376,18 @@ def _command_reset_z(*args, **kwargs):

@messaging.message_callback("update_repo")
def _command_update_repo(*args, **kwargs):
os.system("git reset --hard origin/master")
os.system("mv /home/pi/clever-show/Drone/client_config.ini /home/pi/clever-show/Drone/client_config_tmp.ini")
os.system("git reset --hard HEAD")
os.system("git checkout master")
os.system("git fetch")
os.system("git pull")
os.system("chown -R pi:pi ~/CleverSwarm")
os.system("git pull --rebase")
os.system("mv /home/pi/clever-show/Drone/client_config_tmp.ini /home/pi/clever-show/Drone/client_config.ini")
os.system("chown -R pi:pi /home/pi/clever-show")

@messaging.message_callback("reboot_all")
def _command_reboot_all(*args, **kwargs):
reboot_fcu()
execute_command("reboot")

@messaging.message_callback("reboot_fcu")
def _command_reboot(*args, **kwargs):
Expand Down
5 changes: 4 additions & 1 deletion Server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,10 @@ def remove(self):
if self.connected:
self.close()
if self.clients:
self.clients.pop(self.addr[0])
try:
self.clients.pop(self.addr[0])
except Exception as e:
logging.error(e)
logging.info("Client {} successfully removed!".format(self.copter_id))

@requires_connect
Expand Down
6 changes: 5 additions & 1 deletion Server/server_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ def setupUi(self, MainWindow):
self.action_remove_row.setObjectName("action_remove_row")
self.action_send_calibrations = QtWidgets.QAction(MainWindow)
self.action_send_calibrations.setObjectName("action_send_calibrations")
self.action_reboot_all = QtWidgets.QAction(MainWindow)
self.action_reboot_all.setObjectName("action_reboot_all")
self.menuDeveloper_mode.addAction(self.action_send_any_file)
self.menuDeveloper_mode.addAction(self.actionSend_any_command)
self.menuOptions.addAction(self.action_send_animations)
Expand All @@ -261,11 +263,12 @@ def setupUi(self, MainWindow):
self.menuDeveloper_mode_2.addAction(self.action_restart_clever)
self.menuDeveloper_mode_2.addAction(self.action_restart_clever_show)
self.menuDeveloper_mode_2.addAction(self.action_update_client_repo)
self.menuDeveloper_mode_2.addAction(self.action_reboot_all)
self.menuDrone.addAction(self.action_set_z_offset_to_ground)
self.menuDrone.addAction(self.action_reset_z_offset)
self.menuDrone.addAction(self.action_remove_row)
self.menuDrone.addSeparator()
self.menuDrone.addAction(self.menuDeveloper_mode_2.menuAction())
self.menuDrone.addAction(self.action_remove_row)
self.menuMusic.addAction(self.action_select_music_file)
self.menuMusic.addAction(self.action_play_music)
self.menuMusic.addAction(self.action_stop_music)
Expand Down Expand Up @@ -331,3 +334,4 @@ def retranslateUi(self, MainWindow):
self.action_stop_music.setText(_translate("MainWindow", "Stop music"))
self.action_remove_row.setText(_translate("MainWindow", "Remove from table"))
self.action_send_calibrations.setText(_translate("MainWindow", "Send camera calibrations"))
self.action_reboot_all.setText(_translate("MainWindow", "Reboot all"))
8 changes: 7 additions & 1 deletion Server/server_gui.ui
Original file line number Diff line number Diff line change
Expand Up @@ -418,12 +418,13 @@
<addaction name="action_restart_clever"/>
<addaction name="action_restart_clever_show"/>
<addaction name="action_update_client_repo"/>
<addaction name="action_reboot_all"/>
</widget>
<addaction name="action_set_z_offset_to_ground"/>
<addaction name="action_reset_z_offset"/>
<addaction name="action_remove_row"/>
<addaction name="separator"/>
<addaction name="menuDeveloper_mode_2"/>
<addaction name="action_remove_row"/>
</widget>
<widget class="QMenu" name="menuMusic">
<property name="title">
Expand Down Expand Up @@ -551,6 +552,11 @@
<string>Send camera calibrations</string>
</property>
</action>
<action name="action_reboot_all">
<property name="text">
<string>Reboot all</string>
</property>
</action>
</widget>
<tabstops>
<tabstop>start_delay_spin</tabstop>
Expand Down
8 changes: 7 additions & 1 deletion Server/server_qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ def init_ui(self):
self.ui.action_restart_clever.triggered.connect(self.restart_clever)
self.ui.action_restart_clever_show.triggered.connect(self.restart_clever_show)
self.ui.action_update_client_repo.triggered.connect(self.update_client_repo)
self.ui.action_reboot_all.triggered.connect(self.reboot_all_on_selected)
self.ui.action_set_start_to_current_position.triggered.connect(self.update_start_to_current_position)
self.ui.action_reset_start.triggered.connect(self.reset_start)
self.ui.action_set_z_offset_to_ground.triggered.connect(self.set_z_offset_to_ground)
Expand Down Expand Up @@ -439,7 +440,12 @@ def restart_clever_show(self):
@pyqtSlot()
def update_client_repo(self):
for copter in self.model.user_selected():
copter.client.send_message("update_repo")
copter.client.send_message("update_repo")

@pyqtSlot()
def reboot_all_on_selected(self):
for copter in self.model.user_selected():
copter.client.send_message("reboot_all")

@pyqtSlot()
def update_start_to_current_position(self):
Expand Down
2 changes: 2 additions & 0 deletions messaging_lib.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import io
import os
import sys
import json
import socket
Expand Down Expand Up @@ -382,6 +383,7 @@ def _process_filetransfer(self, message): # TODO path?
logger.error("File {} can not be written due error: {}".format(filepath, error))
else:
logger.info("File {} successfully received ".format(filepath))
os.system("chown -R pi:pi /home/pi/clever-show")

def write(self):
with self._send_lock:
Expand Down

0 comments on commit a46984d

Please sign in to comment.