cobotta2.pad package
Submodules
cobotta2.pad.input_grpc_client module
cobotta2.pad.input_grpc_server module
K.NKADA, kengo.nakada@gmail.com, kengo.nakada@mat.shimane-u.ac.jp
gRPC サーバー側入力バッファ(pull 型)。
本モジュールは、gRPC ハンドラから push された入力データを一時的に保持し、 Runtime 側から pull 形式で取得される入力インターフェースを提供する。
Notes
本モジュールは物理入力デバイスを扱わない。
local input と同一の Input I/F 契約を満たすことを目的とする。
入力は最新値のみを保持し、履歴は保持しない。
- class InputGrpcServer(logger=None, log_level=None)[source]
Bases:
objectgRPC サーバー側の入力境界オブジェクト。
gRPC 経由で受信した入力データを Runtime 向けに中継するための pull 型入力バッファとして機能する。
Notes
物理入力デバイスは扱わない。
Runtime 側とは Input I/F 契約を通じて接続される。
内部的には最新の入力のみを保持する。
- Parameters:
logger (Any | None)
log_level (str | None)
- get_dpose()[source]
Runtime 向けの pull 型入力取得インターフェース。
- Returns:
新しい dpose が存在する場合はその値。 新しい入力が存在しない場合は None。
- Return type:
Optional[List[float]]
Notes
新しい入力が到着した場合のみ値を返す。
入力は保持せず、取得後は破棄される。
local input と意味論を揃えるため、last 値は保持しない。
- pump()[source]
input_device の pump メソッドを呼び出すのにたいおうするダミーメソッド。
Notes
local input との I/F 対称性を保つために存在する。
gRPC 入力では実際の処理は行わない。
- Return type:
None
- put_dpose(dpose)[source]
gRPC ハンドラから移動入力を push する。
- Parameters:
dpose (List[float]) – Runtime に渡す移動入力データ。
- Return type:
None
Notes
STOP / HALT 系の制御は本メソッドには渡されない。
内部キューは最新の入力のみを保持する。
- request_quit()[source]
サーバー側から Runtime に終了要求を通知する。
Notes
local input と契約を揃えるために用意されたインターフェース。
- Return type:
None
- property should_quit: bool
Runtime 側から参照される終了フラグ。
- Returns:
Runtime に終了を通知する場合は True。
- Return type:
bool
cobotta2.pad.input_joypad_local module
cobotta2.pad.joypad_core module
K.NKADA, kengo.nakada@gmail.com, kengo.nakada@mat.shimane-u.ac.jp
JoyPad を含む bcap でのロボットの高速 *制御API集* (一種のドライバ層)
- class JoyPadCore(bcap=None, host=None, port=None, manage_bcap_lifecycle=True, logger=None, log_level=None)[source]
Bases:
objectロボット制御の中核クラス(ローカル / gRPC 共通)
- 設計方針:
open / close でロボットのライフサイクルを管理
入力デバイスは外部注入
- Parameters:
bcap (Optional[CobottaBcap])
host (Optional[str])
port (Optional[int])
manage_bcap_lifecycle (bool)
logger (Optional[Any])
log_level (Optional[str])
- drive(pairs, *, relative=False)[source]
J モードで指定軸のみを相対/絶対で移動させる薄いラッパ。
- Parameters:
pairs (Sequence[Tuple[int, float]]) – [(axis, value), …] axis は 1-based (J1=1)
relative (bool) – True なら相対、False なら絶対
- Return type:
bool
- get_current_angle()[source]
現在のジョイント角度 [j1, j2, j3, j4, j5, j6] を b-cap (CurJnt) 経由で取得する薄いラッパ。
- Return type:
List[float] | None
- get_current_error_info()[source]
RC8 が保持している current Error Infoを読み出す。 [エラーコード (VT_I4),エラーメッセージ (VT_BSTR),サブコード (VT_I4),ファイルID+行番号 (VT_I4),プログラム名 (VT_BSTR),行番号 (VT_I4),ファイルID (VT_I4)]
- Return type:
List | None
- get_current_position()[source]
現在位置を b-cap から取得して返す。 gRPC / GUI が利用する公開メソッド。
- Return type:
List[float] | None
- get_error_count()[source]
RC8 に現在蓄積しているエラー件数を返す。 bcap の GetCurErrorCount をそのまま委譲する。
- Return type:
int
- get_error_description(error_code)[source]
エラーコードから RC8 の説明文字列を返す。
- Parameters:
error_code (int)
- Return type:
str
- get_error_info(index)[source]
index 番目のエラー詳細を返す。 (エラーコードではない)
RC8 が保持している履歴を読み出す。
error_info [エラーコード (VT_I4),エラーメッセージ (VT_BSTR),サブコード (VT_I4),ファイルID+行番号 (VT_I4),プログラム名 (VT_BSTR),行番号 (VT_I4),ファイルID (VT_I4)]
- Parameters:
index (int) – 何番目のエラーか?
- Return type:
List | None
Returns:
- get_value(value_type, index)[source]
RC8 グローバル変数の取得 (CobottaBcap.get_value の薄いラッパ)
- Parameters:
value_type (str) – “I”, “F”, “P”, “J”, “T”, “S”, “V” など
index (int) – 変数番号
- Returns:
スカラ値、もしくは list[float](P/Jなど)
- Return type:
float | List[float] | None
- halt()[source]
JoyPadCore 経由で RC8 に即時 HALT をかける。 queue / NEXT をすべて破棄する。
(*) Queue Clear は runtime –> mover –> bcap –> HALT (*) core halt は bcap –> HALT
- Return type:
bool
- hand(*, position=None, force=None, direction=True, relative=False, speed=None)[source]
- Parameters:
position (int | None)
force (int | None)
direction (bool | int)
relative (bool)
speed (int | None)
- Return type:
bool
- hand_move_A(position, speed)[source]
ハンドの位置・速度指定 (CobottaBcap.HandMoveA の薄いラッパ)
- Parameters:
position (float) – 位置
speed (float) – 速度
- Return type:
bool
- hand_move_H(force, direction)[source]
ハンドの力制御開閉 (CobottaBcap.HandMoveH の薄いラッパ)
- Parameters:
force (float) – 把持力(CobottaBcap.HandMoveH の pow に対応)
direction (int) – 1: close, 0: open
- Return type:
bool
- move(target)[source]
高機能版 Move。 - int: P 番号として move_p_index - str: P 番号として move_p_index - Sequence[float]: Pose として move_pose - dict:
‘pose’ キーがあれば Pose
- Parameters:
target (int | str | Sequence[float]) – P 番号 or Pose or dict
- Returns:
成功, False: 失敗
- Return type:
True
- move_P(p_index=10)[source]
move_p_index の別名 (ORiN互換)
- Parameters:
p_index (int | str)
- Return type:
bool
- move_p_index(p_index)[source]
P 番号指定での Move。
- Parameters:
p_index (int | str) – RC8 グローバル変数 P のインデックス(P10 なら 10)
- Returns:
成功, False: 失敗
- Return type:
True
- move_pose(pose)[source]
絶対座標指定での Move。
- Parameters:
pose (Sequence[float]) – [x, y, z, rx, ry, rz] などの配列(6 要素以上を想定)
- Returns:
成功, False: 失敗
- Return type:
True
- open()[source]
JoyPadCore が b-CAP を「操作可能状態」にする。
- 責務:
bcap.connect()
エラーが出る前提条件を満たす
- Return type:
None
- put_value(value_type, index, newval)[source]
RC8 グローバル変数の設定 (CobottaBcap.put_value の薄いラッパ)
- Parameters:
value_type (str)
index (int)
newval (float | Sequence[float])
- Return type:
bool
cobotta2.pad.joypad_mover module
K.NAKADA, kengo.nakada@gmail.com
dpose (移動量) を受け取って、現在地の差分から 移動指定を出すメソッドを呼び出す。
その際に queue に一度積ませてから処理をするのを前提とする gRPCなどの遅延対策
- class JoyPadMover(bcap, interval=0.02, scale=5, logger=None, log_level=None)[source]
Bases:
objectJoyPadCore 用 mover(queue 版)
dpose はすべて 1 モーションとして queue に積む
- halt() は
RC8 HALT
queue を物理破棄
- エラー処理は MoveWorker(旧実装)と同じ思想:
毎回 move 前に get_error_count()
エラーがあれば reset_error() してその周期は捨てる
例外時も reset_error()
- Parameters:
bcap (CobottaBcap)
interval (float)
scale (int)
logger (Any | None)
log_level (str | None)