11import logging
2+ from pathlib import Path
23import threading
34import typing
45from time import sleep
1011from rcs .camera .hw import CalibrationStrategy
1112from rcs .camera .interface import Frame
1213from tqdm import tqdm
14+ import diskcache as dc
1315
1416logger = logging .getLogger (__name__ )
1517
@@ -19,7 +21,8 @@ class FR3BaseArucoCalibration(CalibrationStrategy):
1921
2022 def __init__ (self , camera_name : str ):
2123 # base frame to camera, world to base frame
22- self ._extrinsics : np .ndarray [tuple [typing .Literal [4 ], typing .Literal [4 ]], np .dtype [np .float64 ]] | None = None
24+ self ._cache = dc .Cache (Path .home () / ".cache" / "rcs" )
25+ self ._extrinsics : np .ndarray [tuple [typing .Literal [4 ], typing .Literal [4 ]], np .dtype [np .float64 ]] | None = self ._cache .get (f"{ camera_name } _extrinsics" ) # None
2326 self .camera_name = camera_name
2427 self .tag_to_world = common .Pose (
2528 rpy_vector = np .array ([np .pi , 0 , - np .pi / 2 ]), translation = np .array ([0.145 , 0 , 0 ])
@@ -53,6 +56,7 @@ def calibrate(
5356 cam_to_world = self .tag_to_world @ np .linalg .inv (tag_to_cam )
5457 world_to_cam = np .linalg .inv (cam_to_world )
5558 self ._extrinsics = world_to_cam # type: ignore
59+ self ._cache .set (f"{ self .camera_name } _extrinsics" , world_to_cam , expire = 3600 )
5660 return True
5761
5862 def get_extrinsics (self ) -> np .ndarray [tuple [typing .Literal [4 ], typing .Literal [4 ]], np .dtype [np .float64 ]] | None :
0 commit comments