renamed /getMeteoroid to /getMeteoroids
small corrections in ip daemon
This commit is contained in:
parent
89d681d10f
commit
436ef35d46
7 changed files with 30 additions and 16 deletions
|
@ -34,7 +34,7 @@ fpm -s python --python-bin python3 --python-pip pip3 --python-package-name-prefi
|
||||||
-d "python3-pigpio" \
|
-d "python3-pigpio" \
|
||||||
-d "python3-numpy" \
|
-d "python3-numpy" \
|
||||||
-d "ffmpeg" \
|
-d "ffmpeg" \
|
||||||
-v 0.2.5-0 -t deb setup.py
|
-v 0.2.6-0 -t deb setup.py
|
||||||
|
|
||||||
# --deb-changelog changelog \
|
# --deb-changelog changelog \
|
||||||
# --deb-upstream-changelog changelog \
|
# --deb-upstream-changelog changelog \
|
||||||
|
|
|
@ -194,18 +194,18 @@ class DoubleElim:
|
||||||
return response, res.status_code
|
return response, res.status_code
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_meteoroid() -> Tuple[List[Dict], int]:
|
def get_meteoroids() -> Tuple[List[Dict], int]:
|
||||||
"""Makes the /api/getMeteoroid call to the api.
|
"""Makes the /api/getMeteoroids call to the api.
|
||||||
|
|
||||||
:return: A list will all meteoroids currently on the game field. Meteoroids are dictionaries that look like: {"x": 0, "y": 0}
|
:return: A list will all meteoroids currently on the game field. Meteoroids are dictionaries that look like: {"x": 0, "y": 0}
|
||||||
:rtype: Tuple[List[Dict], int]
|
:rtype: Tuple[List[Dict], int]
|
||||||
"""
|
"""
|
||||||
res = requests.get(API_URL_GET_METEOROID)
|
res = requests.get(API_URL_GET_METEOROID)
|
||||||
if res.status_code == 408:
|
if res.status_code == 408:
|
||||||
Logging.get_logger().error(f"DoubleElim.get_meteoroid timeout!")
|
Logging.get_logger().error(f"DoubleElim.get_meteoroids timeout!")
|
||||||
time.sleep(0.01)
|
time.sleep(0.01)
|
||||||
return DoubleElim.get_meteoroid()
|
return DoubleElim.get_meteoroids()
|
||||||
|
|
||||||
response = json.loads(res.content)
|
response = json.loads(res.content)
|
||||||
Logging.get_logger().debug(f"DoubleElim.get_meteoroid = {response}, status code = {res.status_code}")
|
Logging.get_logger().debug(f"DoubleElim.get_meteoroids = {response}, status code = {res.status_code}")
|
||||||
return response, res.status_code
|
return response, res.status_code
|
|
@ -1,14 +1,13 @@
|
||||||
import os
|
import os
|
||||||
import queue
|
import queue
|
||||||
from queue import Queue
|
import socket
|
||||||
|
import threading
|
||||||
|
|
||||||
import cv2
|
import cv2
|
||||||
import logging
|
|
||||||
import threading
|
|
||||||
from compLib.LogstashLogging import Logging
|
|
||||||
|
|
||||||
from flask import Flask, Response
|
from flask import Flask, Response
|
||||||
|
|
||||||
|
from compLib.LogstashLogging import Logging
|
||||||
|
|
||||||
RTMP_SERVER = os.getenv("RTMP_SERVER", "rtmp://localhost/live/stream")
|
RTMP_SERVER = os.getenv("RTMP_SERVER", "rtmp://localhost/live/stream")
|
||||||
SERVE_VIDEO = os.getenv("SERVER_SRC", "/live")
|
SERVE_VIDEO = os.getenv("SERVER_SRC", "/live")
|
||||||
BUILDING_DOCS = os.getenv("BUILDING_DOCS", "false")
|
BUILDING_DOCS = os.getenv("BUILDING_DOCS", "false")
|
||||||
|
@ -161,6 +160,18 @@ def __index():
|
||||||
return HTML
|
return HTML
|
||||||
|
|
||||||
|
|
||||||
|
def get_ip():
|
||||||
|
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||||
|
try:
|
||||||
|
s.connect(('10.255.255.255', 1))
|
||||||
|
IP = s.getsockname()[0]
|
||||||
|
except Exception:
|
||||||
|
IP = '127.0.0.1'
|
||||||
|
finally:
|
||||||
|
s.close()
|
||||||
|
return IP
|
||||||
|
|
||||||
|
|
||||||
def __start_flask():
|
def __start_flask():
|
||||||
"""
|
"""
|
||||||
Function for running flask server in a thread.
|
Function for running flask server in a thread.
|
||||||
|
@ -169,6 +180,9 @@ def __start_flask():
|
||||||
"""
|
"""
|
||||||
Logging.get_logger().info("starting flask server")
|
Logging.get_logger().info("starting flask server")
|
||||||
app.run(host="0.0.0.0", port=9898, debug=True, threaded=True, use_reloader=False)
|
app.run(host="0.0.0.0", port=9898, debug=True, threaded=True, use_reloader=False)
|
||||||
|
ip = get_ip()
|
||||||
|
Logging.get_logger().info(f"Vision stream started and can be viewed on: {ip}:9898")
|
||||||
|
print(f"\033[92mVision stream started and can be viewed on: {ip}:9898\033[0m")
|
||||||
|
|
||||||
|
|
||||||
if BUILDING_DOCS == "false":
|
if BUILDING_DOCS == "false":
|
||||||
|
|
|
@ -60,7 +60,7 @@ def write_ip_to_screen():
|
||||||
Logging.get_logger().info(f"writing {ip} to display")
|
Logging.get_logger().info(f"writing {ip} to display")
|
||||||
Display.write(1, "Current IP:")
|
Display.write(1, "Current IP:")
|
||||||
Display.write(2, ip)
|
Display.write(2, ip)
|
||||||
time.sleep(60)
|
time.sleep(5)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
__version__ = "0.2.5-0"
|
__version__ = "0.2.6-0"
|
||||||
|
|
||||||
import importlib
|
import importlib
|
||||||
import compLib.LogstashLogging
|
import compLib.LogstashLogging
|
||||||
|
|
|
@ -101,7 +101,7 @@ Calling Double Elimination API
|
||||||
score, status = DoubleElim.get_score()
|
score, status = DoubleElim.get_score()
|
||||||
print(f"The current score of the game is {score}, the server responded with status code: {status}")
|
print(f"The current score of the game is {score}, the server responded with status code: {status}")
|
||||||
|
|
||||||
meteoroids, status = DoubleElim.get_meteoroid()
|
meteoroids, status = DoubleElim.get_meteoroids()
|
||||||
print(f"The current meteoroids in the game are {meteoroids}, the server responded with status code: {status}")
|
print(f"The current meteoroids in the game are {meteoroids}, the server responded with status code: {status}")
|
||||||
|
|
||||||
In this second example we wait until the game is started by the judges and then make all possible requests once. You should use the wait_for_start function in your double elimination program. If your robot starts too soon your run will not count!
|
In this second example we wait until the game is started by the judges and then make all possible requests once. You should use the wait_for_start function in your double elimination program. If your robot starts too soon your run will not count!
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -12,7 +12,7 @@ else:
|
||||||
|
|
||||||
setuptools.setup(
|
setuptools.setup(
|
||||||
name="complib",
|
name="complib",
|
||||||
version="0.2.5-0",
|
version="0.2.6-0",
|
||||||
author="F-WuTs",
|
author="F-WuTs",
|
||||||
author_email="--",
|
author_email="--",
|
||||||
description="",
|
description="",
|
||||||
|
|
Reference in a new issue