From 4ee4dc4616aab355e2a1dd0edfccf4adf808302c Mon Sep 17 00:00:00 2001 From: Artem30801 Date: Thu, 21 Mar 2019 21:32:17 +0300 Subject: [PATCH 1/2] Fixes flightlib --- Drone/FlightLib2/FlightLib.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Drone/FlightLib2/FlightLib.py b/Drone/FlightLib2/FlightLib.py index a41cbd7..86c6a78 100644 --- a/Drone/FlightLib2/FlightLib.py +++ b/Drone/FlightLib2/FlightLib.py @@ -203,7 +203,7 @@ def land(descend=True, z=1.0, frame_id_descend="aruco_map", frame_id_land="aruco reach_attitude(z=z, frame_id=frame_id_descend, timeout=timeout_descend, freq=freq) landing() - telemetry = get_telemetry(frame_id='aruco_map') + telemetry = get_telemetry(frame_id=frame_id_land) rate = rospy.Rate(1000 / wait_ms) time_start = rospy.get_rostime() @@ -213,7 +213,7 @@ def land(descend=True, z=1.0, frame_id_descend="aruco_map", frame_id_land="aruco interrupt_event.clear() break - telemetry = get_telemetry(frame_id='aruco_map') + telemetry = get_telemetry(frame_id=frame_id_land) module_logger.info("Landing...") time_passed = (rospy.get_rostime() - time_start).to_sec() * 1000 @@ -233,7 +233,7 @@ def takeoff(z=1.0, speed=0.5, frame_id='body', freq=FREQUENCY, timeout_arm=750, timeout_takeoff=5000, wait=False, emergency_land=True): module_logger.info("Starting takeoff!") module_logger.info("Arming, going to OFFBOARD mode") - navigate(frame_id=frame_id_takeoff, speed=speed_takeoff, auto_arm=True) + navigate(frame_id=frame_id, speed=speed_takeoff, auto_arm=True) telemetry = get_telemetry(frame_id=frame_id) rate = rospy.Rate(freq) @@ -257,7 +257,7 @@ def takeoff(z=1.0, speed=0.5, frame_id='body', freq=FREQUENCY, module_logger.info("Armed!") - result = reach_point(z=z, speed=speed, frame_id=frame_id_takeoff, timeout=timeout_takeoff, freq=freq, wait=wait) + result = reach_point(z=z, speed=speed, frame_id=frame_id, timeout=timeout_takeoff, freq=freq, wait=wait) if result: module_logger.info("Takeoff succeeded!") else: From 32c16bb2060a6cc7e46d6cea84d07a0c86094270 Mon Sep 17 00:00:00 2001 From: Artem30801 Date: Thu, 21 Mar 2019 22:00:27 +0300 Subject: [PATCH 2/2] Json error fix --- Drone/client.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Drone/client.py b/Drone/client.py index a0e9d52..18c13ca 100644 --- a/Drone/client.py +++ b/Drone/client.py @@ -110,9 +110,9 @@ def form_message(str_command, dict_arguments): def parse_message(msg): try: j_message = json.loads(msg) - except json.decoder.JSONDecodeError: + except json.JSONDecodeError: print("Json string not in correct format") - return None + return None, None str_command = list(j_message.keys())[0] @@ -253,13 +253,13 @@ try: command, args = parse_message(message) print("Command from server:", command, args) if command == "writefile": - recive_file(list(args.values)[0]) + recive_file(list(args.values)[0]) #TODO repace elif command == 'config_write': write_to_config(args['section'], args['option'], args['value']) elif command == 'config_reload': load_config() elif command == "starttime": - starttime = float(list(args.values)[0]) + starttime = float(list(args.values)[0]) #TODO repace print("Starting on:", time.ctime(starttime)) dt = starttime - get_ntp_time(NTP_HOST, NTP_PORT) print("Until start:", dt)