From 6354d524f638ef3d693863c24da19715da98bf3d Mon Sep 17 00:00:00 2001 From: Arthur Golubtsov Date: Tue, 7 Apr 2020 10:34:25 +0300 Subject: [PATCH] Client: Remove waste spaces --- Drone/client.py | 2 +- Drone/client_setup.sh | 4 ++-- Drone/copter_client.py | 14 +++++++------- Drone/mavros_mavlink.py | 4 ++-- Drone/tasking_lib.py | 20 ++++++++++---------- Drone/visual_pose_watchdog.py | 18 +++++++++--------- 6 files changed, 31 insertions(+), 31 deletions(-) diff --git a/Drone/client.py b/Drone/client.py index 9fb5081..88c5057 100644 --- a/Drone/client.py +++ b/Drone/client.py @@ -13,7 +13,7 @@ from contextlib import closing import inspect # Add parent dir to PATH to import messaging_lib current_dir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) parent_dir = os.path.dirname(current_dir) -sys.path.insert(0, parent_dir) +sys.path.insert(0, parent_dir) logger = logging.getLogger(__name__) diff --git a/Drone/client_setup.sh b/Drone/client_setup.sh index 81f1496..b92b777 100755 --- a/Drone/client_setup.sh +++ b/Drone/client_setup.sh @@ -2,7 +2,7 @@ # $1 - ssid, $2 - password of wifi router # $3 - hostname of rpi -# $4 - server ip +# $4 - server ip if [ $(whoami) != "root" ]; then echo -e "\nThis should be run as root!\n" @@ -38,7 +38,7 @@ country=GB network={ ssid="$1" psk="$2" - scan_ssid=1 + scan_ssid=1 } EOF diff --git a/Drone/copter_client.py b/Drone/copter_client.py index f6856d0..6fdcf33 100644 --- a/Drone/copter_client.py +++ b/Drone/copter_client.py @@ -303,7 +303,7 @@ def _response_animation_id(*args, **kwargs): if result != 'No animation': logger.debug("Saving corrected animation") offset = numpy.array(client.active_client.config.private_offset) + numpy.array(client.active_client.config.copter_common_offset) - frames = animation.load_animation(os.path.abspath("animation.csv"), client.active_client.config.animation_frame_delay, + frames = animation.load_animation(os.path.abspath("animation.csv"), client.active_client.config.animation_frame_delay, offset[0], offset[1], offset[2], *client.active_client.config.animation_ratio) # Correct start and land frames in animation corrected_frames, start_action, start_delay = animation.correct_animation(frames, @@ -390,10 +390,10 @@ def _command_move_start_to_current_position(*args, **kwargs): telem = FlightLib.get_telemetry_locked(client.active_client.config.copter_frame_id) logger.debug("x_telem = {}, y_telem = {}".format(telem.x, telem.y)) if not math.isnan(telem.x): - client.active_client.config.set('PRIVATE', 'offset', + client.active_client.config.set('PRIVATE', 'offset', [telem.x - x_start, telem.y - y_start, client.active_client.config.private_offset[2]], write=True) - logger.info("Set start delta: {:.2f} {:.2f}".format(client.active_client.config.private_offset[0], + logger.info("Set start delta: {:.2f} {:.2f}".format(client.active_client.config.private_offset[0], client.active_client.config.private_offset[1])) else: logger.debug("Wrong telemetry") @@ -403,17 +403,17 @@ def _command_move_start_to_current_position(*args, **kwargs): @messaging.message_callback("reset_start") def _command_reset_start(*args, **kwargs): - client.active_client.config.set('PRIVATE', 'offset', + client.active_client.config.set('PRIVATE', 'offset', [0, 0, client.active_client.config.private_offset[2]], write=True) - logger.info("Reset start to {:.2f} {:.2f}".format(client.active_client.config.private_offset[0], + logger.info("Reset start to {:.2f} {:.2f}".format(client.active_client.config.private_offset[0], client.active_client.config.private_offset[1])) @messaging.message_callback("set_z_to_ground") def _command_set_z(*args, **kwargs): telem = FlightLib.get_telemetry_locked(client.active_client.config.copter_frame_id) - client.active_client.config.set('PRIVATE', 'offset', + client.active_client.config.set('PRIVATE', 'offset', [client.active_client.config.private_offset[0], client.active_client.config.private_offset[1], telem.z], write=True) logger.info("Set z offset to {:.2f}".format(client.active_client.config.private_offset[2])) @@ -421,7 +421,7 @@ def _command_set_z(*args, **kwargs): @messaging.message_callback("reset_z_offset") def _command_reset_z(*args, **kwargs): - client.active_client.config.set('PRIVATE', 'offset', + client.active_client.config.set('PRIVATE', 'offset', [client.active_client.config.private_offset[0], client.active_client.config.private_offset[1], 0], write=True) logger.info("Reset z offset to {:.2f}".format(client.active_client.config.private_offset[2])) diff --git a/Drone/mavros_mavlink.py b/Drone/mavros_mavlink.py index b4602c4..90ee00c 100644 --- a/Drone/mavros_mavlink.py +++ b/Drone/mavros_mavlink.py @@ -63,7 +63,7 @@ def calibrate(sensor): return False # Make calibration message calibration_message = calibration_msg(sensor) - # Send mavlink calibration command + # Send mavlink calibration command send_command_long(False, mavlink.MAV_CMD_PREFLIGHT_CALIBRATION, 0, *calibration_message) rospy.loginfo('Send {} calibration message'.format(sensor)) # Wait until system status to uninit (during calibration on px4) @@ -87,7 +87,7 @@ def get_calibration_status(): if mag_status.value.integer == 0 and mag_status.success: status_text += "mag: uncalibrated; " if acc_status.value.integer == 0 and acc_status.success: - status_text += "acc: uncalibrated; " + status_text += "acc: uncalibrated; " if status_text == "": if not gyro_status.success or not mag_status.success or not acc_status.success: status_text = "NO_INFO" diff --git a/Drone/tasking_lib.py b/Drone/tasking_lib.py index 1827c3c..c64dbcb 100644 --- a/Drone/tasking_lib.py +++ b/Drone/tasking_lib.py @@ -54,7 +54,7 @@ class TaskManager(object): self._wait_interrupt_event.set() self._running_event.clear() - task = Task(task_function, task_args, task_kwargs, task_delayable) + task = Task(task_function, task_args, task_kwargs, task_delayable) count = next(self._counter) entry = (timestamp, priority, count, task) @@ -64,21 +64,21 @@ class TaskManager(object): entry_old = self.task_queue[0] else: entry_old = entry - + heapq.heappush(self.task_queue, entry) if self.task_queue[0] != entry_old: self._task_interrupt_event.set() #print("Task queue updated with more priority task") - + if self._reset_event.is_set(): self._task_interrupt_event.set() self._reset_event.clear() #print("Task queue updated after reset") - + self._wait_interrupt_event.clear() self._running_event.set() - + # #print(self.task_queue) def pop_task(self): @@ -89,7 +89,7 @@ class TaskManager(object): def get_last_task_name(self): return self._last_task - + def get_current_task(self): try: start_time, priority, count, task = self.task_queue[0] @@ -134,7 +134,7 @@ class TaskManager(object): if self.task_queue: next_task_time = self.task_queue[0][0] if time_to_start_next_task > next_task_time: - self._timeshift = time_to_start_next_task - next_task_time + self._timeshift = time_to_start_next_task - next_task_time self._wait_interrupt_event.clear() self._task_interrupt_event.clear() self._running_event.set() @@ -178,7 +178,7 @@ class TaskManager(object): #print("Interrupter is set: {}".format(self._task_interrupt_event.is_set())) try: task.func(*task.args, interrupter=self._task_interrupt_event, **task.kwargs) - + except Exception as e: logger.error("Error '{}' occurred in task {}".format(e, task)) #print("Error '{}' occurred in task {}".format(e, task)) @@ -211,10 +211,10 @@ class TaskManager(object): #try: #print("Pop {} function!".format(task.func.__name__)) #except Exception as e: - #print("Pop something!") + #print("Pop something!") if self._task_interrupt_event.is_set(): - self._task_interrupt_event.clear() + self._task_interrupt_event.clear() logger.info("Execution done") #print("Execution done") diff --git a/Drone/visual_pose_watchdog.py b/Drone/visual_pose_watchdog.py index 7f62957..d36aba2 100644 --- a/Drone/visual_pose_watchdog.py +++ b/Drone/visual_pose_watchdog.py @@ -144,7 +144,7 @@ def laser_callback(data): laser_range = data.range def emergency_land(disarm_if_timeout = True): - global emergency_land_thrust, laser_range + global emergency_land_thrust, laser_range current_thrust = emergency_land_thrust action_timestamp = time.time() while armed: @@ -153,13 +153,13 @@ def emergency_land(disarm_if_timeout = True): try: set_attitude(thrust = current_thrust, yaw = 0, frame_id = 'body', auto_arm = True) except rospy.ServiceException as e: - logger.info(e) + logger.info(e) delta = time.time() - action_timestamp if delta > timeout_to_disarm and disarm_if_timeout: try: arming(False) except rospy.ServiceException as e: - logger.info(e) + logger.info(e) if (laser_range < 0.1 or delta > emergency_land_decrease_thrust_after) and current_thrust >= 0.: current_thrust -= 0.02 if current_thrust <= 0.03: @@ -167,7 +167,7 @@ def emergency_land(disarm_if_timeout = True): try: arming(False) except rospy.ServiceException as e: - logger.info(e) + logger.info(e) rate.sleep() def emergency_land_service(request): @@ -181,7 +181,7 @@ def emergency_land_service(request): responce.success = False responce.message = "Copter is disarmed, no need for emergency landing!" emergency_land_called = False - return responce + return responce def watchdog_callback(event): global visual_pose_last_timestamp, armed, mode, watchdog_action, laser_range @@ -224,7 +224,7 @@ def watchdog_callback(event): try: arming(False) except rospy.ServiceException as e: - logger.info(e) + logger.info(e) rate.sleep() elif watchdog_action == 'disarm': logger.info('Visual pose data is too old, copter is armed, disarming...') @@ -232,15 +232,15 @@ def watchdog_callback(event): try: arming(False) except rospy.ServiceException as e: - logger.info(e) - rate.sleep() + logger.info(e) + rate.sleep() elif watchdog_action == 'emergency_land': if visual_pose_dt > visual_pose_timeout: logger.info('Visual pose data is too old, copter is armed, emergency landing...') if pos_delta > pos_delta_max: logger.info('Position delta is {} m, copter is armed, emergency landing...'.format(pos_delta)) emergency_land() - logger.info('Disarmed') + logger.info('Disarmed') emergency = False if emergency_land_called: emergency = True