Add Odometry, Add Robot class, Change SPI Speed, Change Motor to old speeds

This commit is contained in:
root 2022-01-09 16:48:06 +00:00
parent c70ac8fd03
commit c800b30e31
6 changed files with 163 additions and 37 deletions

View file

@ -2,12 +2,13 @@ from influxdb_client import InfluxDBClient, Point, WritePrecision
import socket
import uuid
import os
import queue
import multiprocessing
import faster_fifo
import datetime
import threading
import requests
import time
CONCURRENCY = 2
CONCURRENCY = 1
HOSTNAME = socket.gethostname()
RUN_TRACE = str(uuid.uuid4())
@ -28,7 +29,7 @@ else:
influx_client = InfluxDBClient(url=INFLUX_HOST, token=TOKEN)
write_api = influx_client.write_api()
point_queue = queue.Queue()
point_queue = faster_fifo.Queue()
workers = []
class MetricsLogging():
@ -72,23 +73,22 @@ class MetricsLogging():
@staticmethod
def worker():
while True:
point = point_queue.get()
if point is None: # Kill signal
return
try:
write_api.write(BUCKET, ORG, point)
points = point_queue.get_many()
write_api.write(BUCKET, ORG, points)
time.sleep(0.1)
except Exception as e:
pass
finally:
point_queue.task_done()
pass
@staticmethod
def start_workers():
global EXTENSIVE_LOGGING
if EXTENSIVE_LOGGING:
if MetricsLogging.is_influx_reachable():
for i in range(CONCURRENCY):
worker = threading.Thread(target=MetricsLogging.worker, daemon=True)
worker = multiprocessing.Process(target=MetricsLogging.worker, daemon=True)
worker.start()
workers.append(worker)
else: