File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed
src/reachy_mini/daemon/app/routers Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change 55and other kinematics-related information.
66"""
77
8+ from pathlib import Path
89from typing import Any
910
10- from fastapi import APIRouter , Depends
11+ from fastapi import APIRouter , Depends , HTTPException , Response
1112
1213from ....daemon .backend .abstract import Backend
1314from ..dependencies import get_backend
1617 prefix = "/kinematics" ,
1718)
1819
20+ STL_ASSETS_DIR = (
21+ Path (__file__ ).parent .parent .parent .parent
22+ / "descriptions"
23+ / "reachy_mini"
24+ / "urdf"
25+ / "assets"
26+ )
27+
1928
2029@router .get ("/info" )
2130async def get_kinematics_info (
@@ -34,3 +43,15 @@ async def get_kinematics_info(
3443async def get_urdf (backend : Backend = Depends (get_backend )) -> dict [str , str ]:
3544 """Get the URDF representation of the robot."""
3645 return {"urdf" : backend .get_urdf ()}
46+
47+
48+ @router .get ("/stl/{filename}" )
49+ async def get_stl_file (filename : Path ) -> Response :
50+ """Get the path to an STL asset file."""
51+ file_path = STL_ASSETS_DIR / filename
52+ try :
53+ with open (file_path , "rb" ) as file :
54+ content = file .read ()
55+ return Response (content , media_type = "model/stl" )
56+ except FileNotFoundError :
57+ raise HTTPException (status_code = 404 , detail = f"STL file not found { file_path } " )
You can’t perform that action at this time.
0 commit comments