Utils API¤
このページでは、Robopyのユーティリティ機能に関連するAPIを説明します。
実験ハンドラー¤
RakudaExpHandler¤
RakudaExpHandler
¤
RakudaExpHandler(rakuda_config: RakudaConfig, metadata_config: MetaDataConfig, fps: int = 10)
Bases: ExpHandler
This class handles the experimental interface for the Rakuda robot.
Sensors: 1x Realsense, 2x Digit,
Example:
from robopy.utils.exp_interface import RakudaExpHandler
handler = RakudaExpHandler(
leader_port="/dev/ttyUSB0",
follower_port="/dev/ttyUSB1",
left_digit_serial="D20542",
right_digit_serial="D20537",
fps=20,
)
handler.record_save(max_frames=150, save_path="test_01", if_async=True)
init initialize Rakuda experimental handler
| PARAMETER | DESCRIPTION |
|---|---|
leader_port
|
leader serial port
TYPE:
|
follower_port
|
follower serial port
TYPE:
|
left_digit_serial
|
left digit serial number
TYPE:
|
right_digit_serial
|
right digit serial number
TYPE:
|
fps
|
The frequency to capture obs. Defaults to 10
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
fps must be between 1 and 20 |
RuntimeError
|
failed to connect to Rakuda robot |
| METHOD | DESCRIPTION |
|---|---|
record_save |
record and save data from Rakuda robot |
record_save
¤
record_save(max_frames: int, save_path: str, if_async: bool = True, save_gif: bool = True, warmup_time: int = 5) -> None
record and save data from Rakuda robot
| PARAMETER | DESCRIPTION |
|---|---|
max_frames
|
maximum number of frames to record
TYPE:
|
save_path
|
path to save the recorded data:
TYPE:
|
if_async
|
If use parallel. Defaults to True.
TYPE:
|
save_gif
|
if save gif. Defaults to True.
TYPE:
|
warmup_time
|
warm up time before recording. Defaults to 5.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
RuntimeError
|
failed to record from Rakuda robot |
RuntimeError
|
failed to save data |
データ処理¤
H5Handler¤
H5Handler
¤
Handler for saving and loading data using HDF5 format with h5py.
| METHOD | DESCRIPTION |
|---|---|
get_info |
Get information about HDF5 file structure. |
load_hierarchical |
Load hierarchical data structure from HDF5 file. |
get_info
staticmethod
¤
Get information about HDF5 file structure.
| PARAMETER | DESCRIPTION |
|---|---|
file_path
|
Path to the HDF5 file.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Dict[str, Any]
|
Dict[str, Any]: Information about file structure and sizes. |
load_hierarchical
staticmethod
¤
Load hierarchical data structure from HDF5 file.
| PARAMETER | DESCRIPTION |
|---|---|
file_path
|
Path to the HDF5 file.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Dict[str, Any]
|
Dict[str, Any]: Hierarchical dictionary containing loaded data. |
Example
data = H5Handler.load_hierarchical('output.h5') camera_data = data['camera']['main'] # Access nested data
BlocsHandler¤
BLOSCHandler
¤
ユーティリティ関数¤
find_usb_port¤
find_usb_port
¤
| FUNCTION | DESCRIPTION |
|---|---|
find_available_ports |
Find available USB ports on the system. |
find_available_ports
¤
Find available USB ports on the system.
| RETURNS | DESCRIPTION |
|---|---|
list[str]
|
list[str]: A list of available USB port names. |
使用例¤
実験データの記録と保存¤
from robopy.config import RakudaConfig, RakudaSensorParams, TactileParams
from robopy.utils.exp_interface import RakudaExpHandler
# 設定
config = RakudaConfig(
leader_port="/dev/ttyUSB0",
follower_port="/dev/ttyUSB1",
sensors=RakudaSensorParams(
tactile=[
TactileParams(serial_num="D20542", name="left"),
TactileParams(serial_num="D20537", name="right"),
],
),
)
# ハンドラー作成
handler = RakudaExpHandler(
rakuda_config=config,
fps=20
)
# データ記録と保存
handler.record_save(
max_frames=1000,
save_path="experiment_001",
if_async=True
)