From b72bbba25e5172dac4d1f54a6a78366cfd9fd0d2 Mon Sep 17 00:00:00 2001 From: Alex Mikhalev Date: Sun, 2 Jun 2019 10:29:32 -0700 Subject: [PATCH] Add CRC checking to python tools --- tools/config.yml | 8 +++---- tools/requirements.txt | 1 + tools/ugv.py | 51 ++++++++++++++++++++++++++++++------------ tools/ugv_cmd.py | 7 ++++++ tools/ugv_to_ground.py | 2 +- 5 files changed, 50 insertions(+), 19 deletions(-) diff --git a/tools/config.yml b/tools/config.yml index 1d7151b..590ed1c 100644 --- a/tools/config.yml +++ b/tools/config.yml @@ -1,12 +1,12 @@ REVISION: 1 angle_pid: - kp: 0.06 - ki: 0.01 + kp: 0.04 + ki: 0.00 #0001 kd: 0.4 - max_output: 0.6 + max_output: 0.4 max_i_error: 15.0 min_target_dist: 1.0 min_flip_pitch: 90.0 -drive_power: 0.4 +drive_power: 0.3 mag_declination: 11.5 diff --git a/tools/requirements.txt b/tools/requirements.txt index d30b2c3..3b1cf35 100644 --- a/tools/requirements.txt +++ b/tools/requirements.txt @@ -3,6 +3,7 @@ chardet==3.0.4 idna==2.8 netifaces==0.10.6 protobuf==3.7.1 +PyCRC==1.21 pyserial==3.4 python-engineio==3.5.2 python-socketio==4.0.2 diff --git a/tools/ugv.py b/tools/ugv.py index 25727ea..6283e6d 100755 --- a/tools/ugv.py +++ b/tools/ugv.py @@ -8,6 +8,8 @@ from threading import Thread import time import binascii from base64 import b64decode, b64encode +from PyCRC.CRC32 import CRC32 +import struct import messages_pb2 as messages from google.protobuf.message import Message @@ -29,9 +31,13 @@ class UGVComms: self.last_status_time = None self.rx_thread = None self.is_running = False + self.log_file = None def write_base64(self, data: bytes): - encoded = b64encode(data) + crc = CRC32().calculate(data) + data_with_checksum = bytearray(data) + data_with_checksum.extend(struct.pack('