41 lines
774 B
Python
41 lines
774 B
Python
from typing import Union
|
|
from fastapi import FastAPI
|
|
from pydantic import BaseModel
|
|
import time
|
|
|
|
# OUR MODULES
|
|
import apriltag_detector
|
|
|
|
app = FastAPI()
|
|
|
|
|
|
@app.get("/")
|
|
async def root():
|
|
return {"message": "Hello World"}
|
|
|
|
|
|
@app.get("/api/v1/ping")
|
|
async def ping():
|
|
return {"status": "ok"}
|
|
|
|
|
|
class ControlBody(BaseModel):
|
|
X: Union[int, None] = None
|
|
Y: Union[int, None] = None
|
|
Z: Union[int, None] = None
|
|
ToolHead: Union[int, None] = None
|
|
AprilTagId: Union[int, None] = None
|
|
|
|
|
|
@app.post("/api/v1/control")
|
|
async def control(item: ControlBody):
|
|
time.sleep(1)
|
|
print("control", item)
|
|
|
|
if item.AprilTagId != None:
|
|
print("AprilTag detected:", item.AprilTagId)
|
|
|
|
# apriltag_detector.open_camera()
|
|
|
|
return {"status": "ok"}
|