cobotta2 package

Subpackages

Submodules

cobotta2.cobotta_bcap module

ゲームパッドからの操作を前提としてるために 「即応性」が求められるために、ORiNを使わない b-cap で使う(広い意味ではORiNのプロトコルの一つなので枠組みはORiNといえる) b-cap を使うための支援クラス(ベースはデンソー?と上椙さんのコード)

上椙コードを無理に直して、しかもなるべくメソッド名とか機能はの押しているので 割とカオス

ORiN: Python → COM → ORiN → Provider → RC8(遅い)

b-CAP: Python → TCP → RC8(速い)

class CobottaBcap(host=None, port=None, logger=None, log_level=None, config=None)[source]

Bases: object

Parameters:
  • host (str | None)

  • port (int | None)

  • logger (Any | None)

  • log_level (str | None)

  • config (Config | None)

Machine = 'localhost'
Name = 'rc'
Option = '@IfNotMember'
Provider = 'CaoProv.DENSO.VRC'
static _change_str_pose(value_type, data)[source]
_error_handle(e)[source]
Parameters:

e (Any)

Return type:

None

_get_state_value(key)[source]
Parameters:

key (str)

Return type:

Any

_get_var_data(key, default=None)[source]
Parameters:
  • key (str)

  • default (Any)

Return type:

Any

static _make_file_content(evp_script_name)[source]

この evp_script_name は、画像モデル(モデルを作った時に最後にコボッタに転送した名前) である

Parameters:

evp_script_name (str)

Return type:

str

Returns:

_make_move_offset_target(target, offset, coord_type=None, path_blend=None, pose=None)[source]

move(…, offset=…) 用 target を作る。

旧 _build_move_target の offset 部分のみを分離したもの。

offset 計算は RC8 Dev 命令を使用する。

Dev は常に P座標 6軸のみを扱う。 fig は Dev の外側で処理する。

_make_move_target(target, coord_type=None, path_blend=None, pose=None)[source]

通常 move 用 target を作る。

旧 _build_move_target の責務のうち offset 処理を除いた部分のみを担当する。

・str target はそのまま使う ・list target は vntPose に変換する ・pose(fig) の追加・上書きをここで行う

offset は扱わない

_make_pacscript_offset_target(target, path_blend=None)[source]

target が str のとき PacScript風 + オフセット構文を処理する。

PacScript風のオフセット書式が move 命令に一緒に来た時に、target を作る

例:

“P10+(10,0,0,0,0,0)” “@P P10+(10,0,0,0,0,0)”

文字列構文では内部 P 番号に保持された fig 情報を使う経路を維持するため、

pose(fig) 解釈を追加しない。

Parameters:
  • target (str)

  • path_blend (str | None)

_move_core(comp, target, coord_type, path_blend, offset, pose, bstrOpt, speed, accel, decel, is_async)[source]

move 実行の分岐のみ担当。

target の解釈は make_* 系へ委譲する。

bstrOpt / speed / accel / decel / is_async はここで b-CAP の robot_move に渡す option 文字列へ確定する。

Parameters:
  • comp (int)

  • coord_type (str | None)

  • path_blend (str | None)

  • offset (tuple | list | None)

  • pose (int | None)

  • bstrOpt (str | int | None)

  • speed (int | None)

  • accel (float | None)

  • decel (float | None)

  • is_async (bool | None)

Return type:

bool

static _normalize_offset(offset)[source]

(0,0,10) のときに (0,0,10,0,0,0) として、rx,ry,yzを暗黙にしないで加える

(0,0,0,10) のときに (0,0,0,10,0,0) となる

Parameters:

offset (list | tuple)

Return type:

list

_release_loaded_task()[source]
Return type:

None

_resolve_bstrOpt(bstrOpt, speed=None, is_async=True, accel=None, decel=None)[source]
Parameters:
  • bstrOpt (str | int | None)

  • speed (int | None)

  • is_async (bool | None)

  • accel (float | None)

  • decel (float | None)

Return type:

str | bool | None

_resolve_hand_bstrOpt(bstrOpt=None, is_async=False)[source]
Parameters:
  • bstrOpt (str | int | None)

  • is_async (bool | None)

Return type:

str | bool | None

_resolve_move_comp(motion_mode=None)[source]
Parameters:

motion_mode (int | str | MotionMode | None)

Return type:

int

static _strip_path_prefix(value)[source]
Parameters:

value (str)

Return type:

str

static _to_bstrOpt_string(opt)[source]
Parameters:

opt (str | int | None)

Return type:

str | None

_to_p_string(offset)[source]

6軸表示 str ならそのまま、list ならば offset 値の書式(P書式)にする

Parameters:

offset (str | list | tuple)

Return type:

str | bool

property accel: float | None
approach(lComp, vntPoseBase, vntPoseLen, bstrOpt)[source]
property asp_mode
autocal(origin=False)[source]

いつでもautocal()

Parameters:

origin (bool)

Return type:

bool

property busy_status
change_tool(no)[source]
Parameters:

no (int)

Return type:

bool

change_work(work_no)[source]
Parameters:

work_no (int)

Return type:

bool

clear_log()[source]
clear_servo_log()[source]
connect(host=None, port=None)[source]
Parameters:
  • host (str)

  • port (int)

Return type:

bool

Returns:

property coord_type: str
property current_angle: list | tuple | bool
property current_position: list | tuple | bool
property decel: float | None
delete()[source]
Return type:

bool

dev(base, offset)[source]

基準位置にたいするオフセットで、座標を作る。

RC8 Dev 命令のラッパ。

Dev は常に P座標 6軸のみを扱う。 pose(fig) は扱わない。

Parameters:
  • base (str | list | tuple)

  • offset (str | list | tuple)

Return type:

list | tuple | bool

property direct_mode
disconnect()[source]
Return type:

bool

download_all_files_from_cobotta(output_dir=None, skip_filenames=None)[source]
Parameters:

skip_filenames (List[str] | Set[str] | Tuple[str, ...] | str | None)

Return type:

bool

download_file_from_cobotta(cobotta_filename, output_dir=None)[source]
Parameters:

cobotta_filename (str)

Return type:

bool

drive(target, *, relative=False, path_blend=None, speed=None, is_async=False, bstrOpt=None)[source]
Parameters:
  • relative (bool)

  • path_blend (str | None)

  • speed (int | None)

  • is_async (bool | None)

  • bstrOpt (str | int | None)

Return type:

bool

drive_A(target, *, path_blend=None, speed=None, is_async=True, bstrOpt=None)[source]
Parameters:
  • path_blend (str | None)

  • speed (int | None)

  • is_async (bool | None)

  • bstrOpt (str | int | None)

Return type:

bool

drive_AEX(target, *, path_blend=None, speed=None, is_async=True, bstrOpt=None)[source]
Parameters:
  • path_blend (str | None)

  • speed (int | None)

  • is_async (bool | None)

  • bstrOpt (str | int | None)

Return type:

bool

drive_EX(target, *, path_blend=None, speed=None, is_async=True, bstrOpt=None)[source]
Parameters:
  • path_blend (str | None)

  • speed (int | None)

  • is_async (bool | None)

  • bstrOpt (str | int | None)

Return type:

bool

property error_code
property error_description
property extaccel: float | None
property extdecel: float | None
property extspeed: int | None
get_F(id_num)[source]
Parameters:

id_num (int)

Return type:

float | bool

get_I(id_num)[source]
Parameters:

id_num (int)

Return type:

int | bool

get_IO(id_num)[source]
Parameters:

id_num (int)

Return type:

Any

get_P(id_num)[source]
Parameters:

id_num (int)

Return type:

List[float] | bool

get_accel()[source]
Return type:

float | bool

get_all_var()[source]
get_base_information()[source]
get_cobotta_all_files_content(skip_filenames=None)[source]
Parameters:

skip_filenames (List[str] | Set[str] | Tuple[str, ...] | str | None)

Return type:

List[Dict[str, str]] | None

get_cobotta_file_content(cobotta_filename)[source]
Parameters:

cobotta_filename (str)

Return type:

Dict[str, str] | None

get_cobotta_file_names()[source]
Return type:

List[str] | Tuple[str, …] | None

get_coord_type()[source]
Return type:

str

get_curjnt()[source]

b-cap での位置・姿勢問い合わせ Uesugi 互換API

Return type:

bool | list | tuple

get_curpos()[source]

b-cap での位置・姿勢問い合わせ Uesugi 互換API

Return type:

bool | list | tuple

get_current_angle()[source]
Return type:

bool | list | tuple

get_current_error_info()[source]

最新のエラー 1 件の情報を取得する。

[ エラーコード (VT_I4), エラーメッセージ (VT_BSTR), サブコード (VT_I4), ファイルID+行番号 (VT_I4), プログラム名 (VT_BSTR), 行番号 (VT_I4), ファイルID (VT_I4) ]

GetCurErrorInfo の「インデックス省略版」に対応し、 現在のエラー情報だけを返す。

get_current_jnt()[source]
Return type:

list | tuple | bool

get_current_pose()[source]

現在の P座標の fig(pose) を取得する。

Return type:

bool | int

get_current_position()[source]
Return type:

list | tuple | bool

get_current_tool()[source]
get_current_tool_no()[source]
get_current_work_no()[source]
get_decel()[source]
Return type:

float | bool

get_direct_mode()[source]
get_error()[source]

現在 RC8 に蓄積しているエラー情報をすべて取得して返す。

戻り値は、各要素が [code, message, subcode, file_line, progname, line, file_id] という形のリストのリスト。

Return type:

List[List[Any]]

get_error_code()[source]
get_error_count()[source]

エラーカウントと言いつつこのカウント情報は

[ エラーコード (VT_I4), エラーメッセージ (VT_BSTR), サブコード (VT_I4), ファイルID+行番号 (VT_I4), プログラム名 (VT_BSTR), 行番号 (VT_I4), ファイルID (VT_I4) ] カウント番号を与えれば、上記情報を返す。つまりトータルカウント数2ならば 0,1 という数字だけで指定すれば二つのエラー情報としてこのリストを取り出せる つまり、エラーカウントとはエラー履歴情報も兼ねる ただし、このカウント情報をよびだすためには、後述の ErrorInfo が必要となる

get_error_description(error_code)[source]

「error_code 番号」から RC8 のエラー説明文字列を取得する。

Parameters:

error_code (int)

Return type:

str | bool

get_error_info(index)[source]
Parameters:

index (int)

get_ext_speed()[source]
Return type:

int | bool

get_extaccel()[source]
Return type:

float | bool

get_extdecel()[source]
Return type:

float | bool

get_extspeed()[source]
Return type:

int | bool

get_file_object(filename)[source]
get_file_value(filename)[source]
get_jspeed()[source]
Return type:

int | bool

get_log_count()[source]
Return type:

int

get_log_record(index)[source]
Parameters:

index (int)

get_motion_complete()[source]
get_motion_mode()[source]
get_motion_preparation()[source]
get_path_blend()[source]
Return type:

str

get_speed()[source]
Return type:

int | bool

get_task_status()[source]

status とかぶるので例外は None とする

get_tasknames()[source]
get_tool(tool_no)[source]
Parameters:

tool_no (int)

get_tool_define(tool_no)[source]
Parameters:

tool_no (int)

get_value(value_type, index)[source]

グローバル変数の値を返します。

value_typestr

変数の型を文字列で指定 (S,I,T,…)

indexint

取得する変数のインデックス番号を指定

get_value_len(value_type)[source]

グローバル変数のサイズを返します。 value_type :str

変数の型を文字列で入力します。(S,V,I, ….)

get_var(kind_or_combined, id_num=None)[source]
Parameters:
  • kind_or_combined (str)

  • id_num (int | None)

Return type:

Any

get_version()[source]
cobotta-ORiN2互換:

コントローラ側のバージョン文字列を返します。

Return type:

str

get_work(work_no=None)[source]
Parameters:

work_no (int | None)

give_arm()[source]
Return type:

bool

halt()[source]

RC8 に対して即時停止 (HALT) をかける 先行入力された NEXT モーションをすべて無効化する

JoyPad などでは、高頻度で使われるので余計な制御入れない

Return type:

bool

hand(pos=None, *, position=None, force=None, direction=True, relative=False, speed=None, is_async=False, bstrOpt=None)[source]
Parameters:
  • pos (int | None)

  • position (int | None)

  • force (int | None)

  • direction (bool | int)

  • relative (bool)

  • speed (int | None)

  • is_async (bool | None)

  • bstrOpt (str | int | None)

Return type:

bool

hand_move_A(pos=None, *, position=None, speed=None, is_async=False, bstrOpt=None)[source]
Parameters:
  • pos (int | None)

  • position (int | None)

  • speed (int | None)

  • is_async (bool | None)

  • bstrOpt (str | int | None)

Return type:

bool

hand_move_H(*, force, direction=True, speed=None, is_async=False, bstrOpt=None)[source]
Parameters:
  • force (int)

  • direction (bool | int)

  • speed (int | None)

  • is_async (bool | None)

  • bstrOpt (str | int | None)

Return type:

bool

hand_move_R(pos=None, *, position=None, speed=None, is_async=False, bstrOpt=None)[source]
Parameters:
  • pos (int | None)

  • position (int | None)

  • speed (int | None)

  • is_async (bool | None)

  • bstrOpt (str | int | None)

Return type:

bool

hand_open(speed=None)[source]
Parameters:

speed (int | None)

Return type:

bool

hand_stop()[source]
Return type:

bool

ifnotm = '@IfNotMember'
init_hand()[source]
Return type:

bool

is_running()[source]
j2p(j_type_pos)[source]
Parameters:

j_type_pos (list | tuple)

Return type:

list | tuple | bool

property jspeed: int | None
property lock
property manual_move_mode
motion_complete()[source]
Return type:

str | bool

property motion_mode
motor_off()[source]

b-CAP 経由で RC8 のモータを OFF にする。

Robot_Execute(“Motor”, [0, 0]) を呼び出す。

Return type:

bool

motor_on()[source]

b-CAP 経由で RC8 のモータを ON にする。

Robot_Execute(“Motor”, [1, 0]) を呼び出す。

Return type:

bool

move(target, *, motion_mode=None, coord_type=None, path_blend=None, offset=None, pose=None, speed=None, accel=None, decel=None, is_async=True, bstrOpt=None)[source]

ロボット移動。

target の解釈は make_* 系へ委譲する。

ctrl から共通 I/F で呼ばれる前提。 orin2 / bcap で同一仕様。

Parameters:
  • motion_mode (int | str | MotionMode | None)

  • coord_type (str | None)

  • path_blend (str | None)

  • offset (tuple | list | None)

  • pose (int | None)

  • speed (int | None)

  • accel (float | None)

  • decel (float | None)

  • is_async (bool)

  • bstrOpt (str | int | None)

Return type:

bool

move_C(target, *, coord_type=None, path_blend=None, offset=None, pose=None, speed=None, accel=None, decel=None, is_async=True, bstrOpt=None)[source]
Parameters:
  • coord_type (str | None)

  • path_blend (str | None)

  • offset (tuple | list | None)

  • pose (int | None)

  • speed (int | None)

  • accel (float | None)

  • decel (float | None)

  • is_async (bool)

  • bstrOpt (str | int | None)

Return type:

bool

move_L(target, *, coord_type=None, path_blend=None, offset=None, pose=None, speed=None, accel=None, decel=None, is_async=True, bstrOpt=None)[source]
Parameters:
  • coord_type (str | None)

  • path_blend (str | None)

  • offset (tuple | list | None)

  • pose (int | None)

  • speed (int | None)

  • accel (float | None)

  • decel (float | None)

  • is_async (bool)

  • bstrOpt (str | int | None)

Return type:

bool

move_P(target, *, coord_type=None, path_blend=None, offset=None, pose=None, speed=None, accel=None, decel=None, is_async=True, bstrOpt=None)[source]
Parameters:
  • coord_type (str | None)

  • path_blend (str | None)

  • offset (tuple | list | None)

  • pose (int | None)

  • speed (int | None)

  • accel (float | None)

  • decel (float | None)

  • is_async (bool)

  • bstrOpt (str | int | None)

Return type:

bool

move_S(target, *, coord_type=None, path_blend=None, offset=None, pose=None, speed=None, accel=None, decel=None, is_async=True, bstrOpt=None)[source]
Parameters:
  • coord_type (str | None)

  • path_blend (str | None)

  • offset (tuple | list | None)

  • pose (int | None)

  • speed (int | None)

  • accel (float | None)

  • decel (float | None)

  • is_async (bool)

  • bstrOpt (str | int | None)

Return type:

bool

move_func(mode, dist_len, flg)[source]

for gamepad XYZ / Tool / 各軸モードの相対移動1

Parameters:
  • mode

  • dist_len

  • flg

Returns:

open_hand(speed=None)[source]
Parameters:

speed (int | None)

Return type:

bool

p2j(p_type_pos)[source]
Parameters:

p_type_pos (list | tuple)

Return type:

list | tuple | bool

property path_blend: str
print_error(e)[source]

通常例外、ORiNException、文字列をログ出力する。

Parameters:

e (Any)

Return type:

bool

print_error_info(e)[source]

互換性維持

Parameters:

e (Any)

Return type:

bool

put_value(value_type, index, newval)[source]
property rc8_type
property rc8_type_name
release_arm()[source]
Return type:

bool

static remove_extension(filename)[source]
Parameters:

filename (str)

Return type:

str

reset_error()[source]

RC8 のエラーを安全にリセットするための統合処理 b-CAP には ResetError の専用APIは無いため、 ManualResetPreparation → ClearError を組み合わせて実装する。

  1. 現在のエラー状態を取得

  2. エラー解除の前提状態に遷移させるための内部プロシージャA

  3. エラーリセット

  4. モーション準備

Return type:

bool

rewrite_file_value(filename, data)[source]
robo_clear()[source]

エラーを消す。

Return type:

bool

robo_dmove(dPose, *, coord_mode='P')[source]
Parameters:

coord_mode (str)

robo_dmove_J(dpose)[source]

関節空間(J モード)での差分移動。

dev は使用しない。 現在関節角を取得し、差分を加算して目標角を作成し、 robot_move([target_J, “J”], “NEXT”) を直接発行する。

Parameters:

dpose (Sequence[float])

Return type:

bool

robo_dmove_P(dPose)[source]

for GamePad XYZ/RxRyRz の相対移動(増分指定) Pモード専用

現在と新しい位置の差分(ret_dev)を作ってそれを新しいポーズとして動かす

現在位置(CurPos)と与えられた dPose との差分から Dev を計算し、その結果を次のモーション(NEXT)として投入する。

Parameters:

dPose (Sequence[float]) – 相対移動量。[dx, dy, dz, drx, dry, drz]

Return type:

bool

Notes

  • NEXT 指定のため、RC8 側のモーションキュー状態に依存する。

robo_move(dPose, *, coord_mode='P')[source]
Parameters:

coord_mode (str)

robo_move_J(dPose)[source]

J への絶対位置座標 move

関節空間(J モード)で指定された関節角度配列に基づき、 ロボットを次のモーションとして移動させる。

本メソッドは b-CAP 経由で RC8 に対して Joint(J)指定の Move 命令を発行する低レベル操作 RC8 側のキュー(NEXT モーション)にそのまま関節指令を積む。

Parameters:

dPose (Sequence[float]) – 関節角度の配列。 RC8 が要求する関節数・順序(例: J1〜J6)に対応している必要がある。

Raises:

ORiNException – b-CAP / RC8 側でエラーが発生した場合に送出される。 内部でエラーコードを取得し、RC8 のエラー説明をログ出力する。

Return type:

bool

Notes

  • NEXT 指定のため、既存のモーションキュー状態に依存する。

robo_move_P(Pose)[source]

P への絶対位置座標 move

RC8 コントローラに対して b-CAP 経由で移動命令(Move)を発行する

Parameters:

Pose (Sequence[Any]) –

移動先を表す配列。 以下の形式を取ることを想定する。

Cartesian 指定の場合:

[ [x, y, z, rx, ry, rz], “P” ]

Return type:

bool

Notes

  • NEXT 指定のため、既存のモーションキュー状態に依存する。

Raises:

ORiNException – b-CAP / RC8 側で Move 命令が拒否された場合に送出される。 エラーコードおよび RC8 側のエラー内容は呼び出し元でログ取得可能。

Return type:

bool

rotate(plane, angle, center, *, path_blend=None, speed=None, is_async=True, bstrOpt=None)[source]
Parameters:
  • plane (str)

  • angle (float)

  • center (list)

  • path_blend (str | None)

  • speed (int | None)

  • is_async (bool | None)

  • bstrOpt (str | int | None)

Return type:

bool

rotate_H(angle, *, path_blend=None, speed=None, is_async=True, bstrOpt=None)[source]
Parameters:
  • path_blend (str | None)

  • speed (int | None)

  • is_async (bool | None)

  • bstrOpt (str | int | None)

Return type:

bool

run_script()[source]
Return type:

bool

property servo_on
set_F(id_num, value)[source]
Parameters:
  • id_num (int)

  • value (float)

Return type:

bool

set_I(id_num, value)[source]
Parameters:
  • id_num (int)

  • value (int)

Return type:

bool

set_IO(id_num, value)[source]
Parameters:
  • id_num (int)

  • value (float)

Return type:

bool

set_P(id_num, value)[source]
Parameters:
  • id_num (int)

  • value (List[float] | Tuple[float, ...])

Return type:

bool

set_accel(accel)[source]
Parameters:

accel (float)

Return type:

bool

set_coord_type(value)[source]
Parameters:

value (str)

Return type:

bool

set_decel(decel)[source]
Parameters:

decel (float)

Return type:

bool

set_ext_speed(ext_sp_val)[source]
Parameters:

ext_sp_val (int)

Return type:

bool

set_extaccel(extaccel)[source]
Parameters:

extaccel (float)

Return type:

bool

set_extdecel(extdecel)[source]
Parameters:

extdecel (float)

Return type:

bool

set_extspeed(speed)[source]
Parameters:

speed (int)

Return type:

bool

set_jspeed(speed)[source]
Parameters:

speed (int)

Return type:

bool

set_motion_mode(mode)[source]
Parameters:

mode (int | str | MotionMode)

Return type:

bool

set_path_blend(value)[source]
Parameters:

value (str)

Return type:

bool

set_speed(speed)[source]
Parameters:

speed (int)

Return type:

bool

set_tool_define(tool_no, tool_define)[source]
Parameters:
  • tool_no (int)

  • tool_define (tuple | list | str)

Return type:

bool

set_var(kind_or_combined, id_or_value, value=None)[source]
Parameters:
  • kind_or_combined (str)

  • id_or_value (Any)

  • value (Any)

Return type:

bool

set_work(work_no, work_define, work_attribute=0)[source]
Parameters:
  • work_no (int)

  • work_define (tuple | list | str)

  • work_attribute (int)

Return type:

bool

property speed: int | None
start_log()[source]
start_servo_log()[source]
state()[source]
stop()[source]
stop_log()[source]
stop_servo_log()[source]
take_arm()[source]
Return type:

bool

take_camera(evp_script_name, pac_script_name=None)[source]
Parameters:
  • evp_script_name (str)

  • pac_script_name (str | None)

Return type:

bool

take_script(script='pro1')[source]
Parameters:

script (str)

Return type:

bool

property task
property task_state
task_stop()[source]
Return type:

bool

timeout = 2000
turn_off_motor()[source]
Return type:

bool

turn_on_motor()[source]
Return type:

bool

upload_content_to_cobotta(file_content, cobotta_filename)[source]
Parameters:
  • file_content (str)

  • cobotta_filename (str)

Return type:

bool

upload_file_to_cobotta(upload_filename, cobotta_filename)[source]
Parameters:

cobotta_filename (str)

Return type:

bool

wait_for_complete()[source]
Return type:

bool

main0()[source]
main1()[source]

cobotta2.cobotta_bcap_dummy module

DummyBcap

  • CobottaBcap と同じ I/F を「落ちない」ために揃える最小ダミー

  • 実機には触らない

  • 引数の存在・戻り値型の整合だけを担保する

class CobottaBcapDummy(host=None, port=None, logger=None, log_level=None)[source]

Bases: object

Parameters:
  • host (Optional[str])

  • port (Optional[int])

  • logger (Optional[XLogger])

  • log_level (Optional[str])

HandMoveA(position, speed)[source]
Parameters:
  • position (Any)

  • speed (Any)

Return type:

Any

HandMoveH(force, direction)[source]
Parameters:
  • force (Any)

  • direction (int)

Return type:

Any

Machine: str = 'localhost'
Name: str = 'rc'
Option: str = '@IfNotMember'
Provider: str = 'CaoProv.DENSO.VRC'
static _change_str_pose(value_type, data)[source]
Parameters:
  • value_type (Any)

  • data (Any)

Return type:

str

_error_handle(e)[source]
Parameters:

e (Any)

Return type:

None

_error_message(e)[source]
Parameters:

e (Any)

Return type:

None

autocal()[source]
Return type:

bool

connect(host=None, port=None)[source]
Parameters:
  • host (str | None)

  • port (int | None)

Return type:

bool

disconnect()[source]
Return type:

str

get_accel()[source]
Return type:

float

get_base_information()[source]
Return type:

Any

get_curjnt()[source]
Return type:

List[float]

get_curpos()[source]
Return type:

List[float]

get_current_error_info()[source]
Return type:

List[Any]

get_decel()[source]
Return type:

float

get_error()[source]
Return type:

List[List[Any]]

get_error_count()[source]
Return type:

int

get_error_description(error_code)[source]
Parameters:

error_code (int)

Return type:

str

get_error_info(count)[source]
Parameters:

count (Any)

Return type:

List[Any]

get_ext_speed()[source]
Return type:

float

get_file_value(filename)[source]
Parameters:

filename (Any)

Return type:

Any

get_speed()[source]
Return type:

float

get_tasknames()[source]
Return type:

Any

get_value(value_type, index)[source]
Parameters:
  • value_type (str)

  • index (int)

Return type:

Any

get_value_len(value_type)[source]
Parameters:

value_type (Any)

Return type:

int

give_arm()[source]
Return type:

bool

ifnotm: str = '@IfNotMember'
motor_off()[source]
Return type:

bool

motor_on()[source]
Return type:

bool

move_func(mode, dist_len, flg)[source]
Parameters:
  • mode (Any)

  • dist_len (Any)

  • flg (Any)

Return type:

None

put_value(value_type, index, newval)[source]
Parameters:
  • value_type (str)

  • index (int)

  • newval (Any)

Return type:

None

reset_error()[source]
Return type:

bool

rewrite_file_value(filename, data)[source]
Parameters:
  • filename (Any)

  • data (Any)

Return type:

bool

robo_Jmove(dPose)[source]
Parameters:

dPose (Any)

Return type:

None

robo_clear()[source]
Return type:

None

robo_dmove(dPose)[source]
Parameters:

dPose (Any)

Return type:

None

robo_move(Pose)[source]
Parameters:

Pose (Any)

Return type:

None

set_accel(accel)[source]
Parameters:

accel (Any)

Return type:

bool

set_decel(decel)[source]
Parameters:

decel (Any)

Return type:

bool

set_ext_speed(ext_sp_val)[source]
Parameters:

ext_sp_val (Any)

Return type:

bool

set_speed(speed)[source]
Parameters:

speed (Any)

Return type:

bool

take_arm()[source]
Return type:

bool

timeout: int = 2000

cobotta2.cobotta_ctrl module

Kengo NAKADA: https://github.com/shimane-dev, https://github.com/kengo-nakada kengo.nakada@mat.shimane-u.ac.jp, kengo.nakada@gmail.com

class CobottaCtrl(cobotta_ip='192.168.0.1', arm_name='Arm', instance_name='Ctrl', logger=None, log_level=None, backend='bcap', bcap_port=5007, config=None)[source]

Bases: object

ORiN2 の COM を用いて、python から制御する そのための簡単なラッパークラス

Parameters:
  • cobotta_ip (str)

  • arm_name (str)

  • instance_name (str)

  • logger (Any | None)

  • log_level (str | None)

  • backend (str)

  • bcap_port (int)

  • config (Config | Any | None)

_VAR_NAME_RE = re.compile('(P|F|I|IO)(\\d+)$')
static _make_file_content(evp_script_name)[source]
Parameters:

evp_script_name (str)

Return type:

str

property accel: float | None
approach(lComp, vntPoseBase, vntPoseLen, bstrOpt)[source]
autocal(origin=False)[source]
Parameters:

origin (bool)

property busy_status
change_tool(work_no)[source]
Parameters:

work_no (int)

Return type:

bool

change_work(work_no)[source]
Parameters:

work_no (int)

Return type:

bool

clear_log()[source]
clear_servo_log()[source]
connect()[source]
property coord_type
property current_angle: list | tuple | bool
property current_position: list | tuple | bool
property decel: float | None
delete()[source]
Return type:

bool

dev(base, offset)[source]
Parameters:
  • base (str | list | tuple)

  • offset (str | list | tuple)

Return type:

list | tuple | bool

property direct_mode

どうしてもORiN2っぽいモードに縛られる

disconnect()[source]
Return type:

bool

download_all_files_from_cobotta(output_dir=None, skip_filenames=None)[source]
Parameters:
  • output_dir (str | Path | None)

  • skip_filenames (List[str] | Set[str] | Tuple[str, ...] | str | None)

Return type:

bool

download_file_from_cobotta(cobotta_filename, output_dir=None)[source]
Parameters:
  • cobotta_filename (str)

  • output_dir (str | Path | None)

Return type:

bool

drive(target, *, relative=False, path_blend=None, speed=None, is_async=False, bstrOpt=None)[source]
Parameters:
  • target (str | list | tuple | None)

  • relative (bool)

  • path_blend (str | None)

  • speed (int | None)

  • is_async (bool | None)

  • bstrOpt (str | int | None)

Return type:

bool

property error_code
property error_description

last の error description

property extaccel: float | None
property extdecel: float | None
property extspeed: int | None
get_F(id_num)[source]
Parameters:

id_num (int)

Return type:

float | bool

get_I(id_num)[source]
Parameters:

id_num (int)

Return type:

int | bool

get_IO(id_num)[source]
Parameters:

id_num (int)

Return type:

Any

get_P(id_num)[source]
Parameters:

id_num (int)

Return type:

List[float] | bool

get_accel()[source]
Return type:

float | bool

get_all_var()[source]
get_cobotta_all_files_content(skip_filenames=None)[source]
Parameters:

skip_filenames (List[str] | Set[str] | Tuple[str, ...] | str | None)

get_cobotta_file_content(cobotta_filename)[source]
Parameters:

cobotta_filename (str)

get_cobotta_file_names()[source]
get_coord_type()[source]
Return type:

str

get_current_angle()[source]
Return type:

list | tuple | bool

get_current_error_info()[source]

現在のエラー全ての情報

get_current_pose()[source]
Return type:

int | bool

get_current_position()[source]
Return type:

list | tuple | bool

get_current_tool()[source]
get_current_tool_no()[source]
get_current_work_no()[source]
get_decel()[source]
Return type:

float | bool

get_direct_mode()[source]
get_error()[source]
get_error_code()[source]
get_error_count()[source]

エラー数

get_error_description(error_code)[source]
Parameters:

error_code (int)

Return type:

str

get_error_info(index)[source]
Parameters:

index (int)

get_extaccel()[source]
Return type:

float | bool

get_extdecel()[source]
Return type:

float | bool

get_extspeed()[source]
Return type:

int | bool

get_file_object(filename)[source]
get_jspeed()[source]
Return type:

int | bool

get_log_count()[source]
Return type:

int

get_log_record(index)[source]
Parameters:

index (int)

Return type:

int

get_motion_complete()[source]
get_motion_mode()[source]
get_motion_preparation()[source]
get_path_blend()[source]
Return type:

str

get_speed()[source]
Return type:

int | bool

get_task_status()[source]
get_tool(tool_no)[source]
Parameters:

tool_no (int)

get_tool_define(tool_no)[source]
Parameters:

tool_no (int)

get_var(kind_or_combined, id_num=None)[source]
Parameters:
  • kind_or_combined (str)

  • id_num (int | None)

Return type:

Any

get_version(rel_toml_path)[source]
get_work(work_no=None)[source]
Parameters:

work_no (int | None)

give_arm()[source]
Return type:

bool

halt()[source]
Return type:

bool

hand(pos=None, *, position=None, force=None, direction=True, relative=False, speed=None, is_async=False, bstrOpt=None)[source]
Parameters:
  • pos (int | None)

  • position (int | None)

  • force (int | None)

  • direction (bool | int)

  • relative (bool)

  • speed (int | None)

  • is_async (bool | None)

  • bstrOpt (str | int | None)

Return type:

bool

hand_open(speed=None)[source]
Parameters:

speed (int | None)

Return type:

bool

hand_stop()[source]
Return type:

bool

init_hand()[source]
Return type:

bool

is_empty_position(id_num, coord_type=None, tol=None)[source]
Parameters:
  • id_num (int | str)

  • coord_type (str | None)

  • tol (float | None)

Return type:

bool

is_running()[source]
j2p(j_type_pos)[source]
Parameters:

j_type_pos (list | tuple)

Return type:

list | tuple | bool

jog(axis, direction, speed, step=None)[source]

指定軸をジョグする。

Parameters:
  • axis (str) – "J1" ~ "J6"。

  • direction (int) – 正方向は 1、負方向は -1。

  • speed (float) – ジョグ速度。負値は絶対値で扱う。

  • step (float | None) – ジョグ移動量。None は連続ジョグ。

Returns:

ジョグを開始できた場合 True。

Return type:

bool

jog_stop()[source]

現在のジョグを停止する。

Return type:

bool

property jspeed: int | None
property lock
motion_complete()[source]
Return type:

str | bool

property motion_mode
move(target, *, motion_mode=None, coord_type=None, path_blend=None, offset=None, pose=None, speed=None, accel=None, decel=None, is_async=True, bstrOpt=None)[source]
Parameters:
  • target (str | list | tuple)

  • motion_mode (int | str | MotionMode | None)

  • coord_type (str | None)

  • path_blend (str | None)

  • offset (tuple | list | None)

  • pose (int | None)

  • speed (int | None)

  • accel (float | None)

  • decel (float | None)

  • is_async (bool | None)

  • bstrOpt (str | int | None)

Return type:

bool

open_hand(speed=None)[source]
Parameters:

speed (int | None)

Return type:

bool

p2j(p_type_pos)[source]
Parameters:

p_type_pos (list | tuple)

Return type:

list | tuple | bool

property path_blend
print_error(e)[source]
Return type:

bool

print_error_info(e)[source]
Return type:

bool

release_arm()[source]
Return type:

bool

remove_extension(filename)[source]
Parameters:

filename (str)

Return type:

str

reset_error()[source]
Return type:

bool

rotate(plane, angle, center, *, path_blend=None, speed=None, is_async=True, bstrOpt=None)[source]
Parameters:
  • plane (str)

  • angle (float)

  • center (list)

  • path_blend (str | None)

  • speed (int | None)

  • is_async (bool | None)

  • bstrOpt (str | int | None)

Return type:

bool

run_script()[source]
Return type:

bool

property servo_on
set_F(id_num, value)[source]
Parameters:
  • id_num (int)

  • value (float)

Return type:

bool

set_I(id_num, value)[source]
Parameters:
  • id_num (int)

  • value (int)

Return type:

bool

set_IO(id_num, value)[source]
Parameters:
  • id_num (int)

  • value (float)

Return type:

bool

set_P(id_num, value)[source]
Parameters:
  • id_num (int)

  • value (List[float] | Tuple[float, ...])

Return type:

bool

set_accel(accel)[source]
Parameters:

accel (float)

Return type:

bool

set_coord_type(coord_type)[source]
Parameters:

coord_type (str)

Return type:

bool

set_decel(decel)[source]
Parameters:

decel (float)

Return type:

bool

set_extaccel(extaccel)[source]
Parameters:

extaccel (float)

Return type:

bool

set_extdecel(extdecel)[source]
Parameters:

extdecel (float)

Return type:

bool

set_extspeed(speed)[source]
Parameters:

speed (int)

Return type:

bool

set_jspeed(speed)[source]
Parameters:

speed (int)

Return type:

bool

set_motion_mode(mode)[source]
Parameters:

mode (int | str | MotionMode)

Return type:

bool

set_path_blend(path_blend)[source]
Parameters:

path_blend (str)

Return type:

bool

set_speed(speed)[source]
Parameters:

speed (int)

Return type:

bool

set_tool(tool_no, tool_define)[source]
Parameters:
  • tool_no (int)

  • tool_define (tuple | list | str)

Return type:

bool

set_tool_define(tool_no, tool_define)[source]
Parameters:
  • tool_no (int)

  • tool_define (tuple | list | str)

Return type:

bool

set_var(kind_or_combined, id_or_value, value=None)[source]
Parameters:
  • kind_or_combined (str)

  • id_or_value (Any)

  • value (Any)

Return type:

bool

set_work(work_no, work_define, work_attribute=0)[source]
Parameters:
  • work_no (int)

  • work_define (tuple | list | str)

  • work_attribute (int)

Return type:

bool

property speed: int | None
start_log()[source]
start_servo_log()[source]
state()[source]
stop()[source]
stop_log()[source]
stop_servo_log()[source]
take_arm()[source]
Return type:

bool

take_camera(evp_script_name, pac_script_name=None)[source]
Parameters:
  • evp_script_name (str)

  • pac_script_name (str | None)

Return type:

bool

take_script(script='pro1')[source]
Parameters:

script (str)

Return type:

bool

property task
property task_state
task_stop()[source]
Return type:

bool

teach(kind_or_combined='P', id_num=None, *, save=True)[source]

現在のロボット状態を指定変数へ教示する。

set_P() は与えられた値を変数へ代入する通常の setter である。 teach() は実機の現在状態を読み取り、指定した P10 や J1 に 記録する教示操作である。

現時点では P/J のローカル保存を行う。COBOTTA/RC8 の内部 P 変数へ 同時に書くかどうかは後段の設計課題とし、ここでは RobotVarManager への JSON 保存を共通動作とする。

Parameters:
  • kind_or_combined (str) – “P”, “J”, “P10”, “J1” 形式の変数指定。

  • id_num (int | None) – 変数番号。結合済み名の場合は省略可。

  • save (bool) – True の場合、教示後に JSON へ即保存する。

Returns:

成功時 True、失敗時 False。

Return type:

bool

turn_off_motor()[source]
Return type:

bool

turn_on_motor()[source]
Return type:

bool

upload_content_to_cobotta(file_content, cobotta_filename)[source]
Parameters:
  • file_content (str)

  • cobotta_filename (str)

Return type:

bool

upload_file_to_cobotta(upload_filename, cobotta_filename)[source]
Parameters:
  • upload_filename (str | Path)

  • cobotta_filename (str)

Return type:

bool

wait_for_complete()[source]
Return type:

bool

cobotta2.cobotta_ctrl_joypad module

cobotta2.cobotta_orin2 module

スピードの設定が100になってないと 動いていないように見えるので注意

Kengo NAKADA: https://github.com/shimane-dev, https://github.com/kengo-nakada kengo.nakada@mat.shimane-u.ac.jp, kengo.nakada@gmail.com

class CobottaOrin2(cobotta_ip='192.168.0.1', arm_name='Arm', instance_name='Ctrl', *, logger=None, log_level=None, init_com=True, config=None)[source]

Bases: object

ORiN2 の COM を用いて、python から制御する そのための簡単なラッパークラス

Parameters:
  • cobotta_ip (str)

  • arm_name (str)

  • instance_name (str)

  • logger (Any | None)

  • log_level (str | None)

  • init_com (bool | None)

  • config (Config | Any | None)

Provider = 'CaoProv.DENSO.RC8'
_drive_core(target, *, path_blend=None, speed=None, is_async=False, bstrOpt=None)[source]

Drive は存在せずに DriveEX, DriveAEX を使う (Ex 拡張) 6軸指定は、J で指定

target: list of (target, pos) or string “(1,100),(3,200)”

v1 = [(1,10), -1, “@P”] v2 = [(2,10), -1] vntPose = [v1, v2] Execute(“DriveAEX”, [vntPose, “Speed=10, Next]) Execute(“DriveAEX”, [“@0 (1,10), (2,10), “Speed=10, Next])

PacScript:
DriveA(1,60)

DriveA(2,20),(3,135),(4,-10),(5, 25)

Parameters:
  • target (str | list | tuple)

  • path_blend (str | None)

  • speed (int | None)

  • is_async (bool | None)

  • bstrOpt (str | int | None)

Return type:

list | str | bool

_error_handle(e)[source]

b-cap制御側と仕組みを合わせる

Parameters:

e – エラーコード番号

Return type:

bool

Returns:

_get_var_data(message, default=None)[source]

@current_positon などの @型内部変数を取得する

Parameters:
  • message

  • default

Return type:

Any

Returns:

_initialize_com()[source]

主にgRPCの自動スレッド化対策 gRPCが制御のインスタンスとインスから呼び出されるメソッドを別スレッドで動かすセンスのために windows の COM モデルだと __init__ で COM 初期化すると崩壊する。 COMは同一スレッドである必要がある そのためにCOM init は外部化するつ必要がある。

ローカルで使うときは、この _initialize_com を動かす。 それ以外は COM ロードを外部のものを使う

Returns:

Return type:

None

static _make_file_content(evp_script_name)[source]
Parameters:

evp_script_name (str)

Return type:

str

_make_move_offset_target(target, offset, coord_type=None, path_blend=None, pose=None)[source]

move(…, offset=…) 用 target を作る。

dev は常に P座標 6軸のみを扱う。

pose(fig) は dev の外側で扱う。

規則:

move(“P10”, offset=…)

-> dev(“P10”, offset)

move([6軸], offset=…)

-> 6軸 dev

move([6軸], pose=3, offset=…)

-> dev 後に 7要素目=3 を追加

move([7軸], offset=…)

-> 7要素目 fig を保持

move([7軸], pose=5, offset=…)

-> 7要素目を 5 に置換

Parameters:
  • target (str | list | tuple)

  • offset (str | list | tuple)

  • coord_type (str | None)

  • path_blend (str | None)

  • pose (int | None)

Return type:

list | bool

_make_move_target(target, coord_type=None, path_blend=None, pose=None)[source]

target: str, list, tuple

move 用の target を ORiN2 Move API に渡す形式へ正規化する

ここでは offset 演算は扱わない。 offset 付き move は _move_core() 側で dev を通してから、 その結果を move target に組み立てる。

pose(fig) を解釈するのは list / tuple target のみである。 str target は既存の文字列構文として扱い、

Parameters:
  • target (str | list | tuple)

  • coord_type (str | None)

  • path_blend (str | None) – オプションのパスブレンド値。明示指定があればこれを最優先で使う。

  • pose (int | None)

Return type:

str | list | bool

Returns:

_make_pacscript_offset_target(target, path_blend=None)[source]

target が str のとき PacScript風 + オフセット構文を処理する。

PacScript風のオフセット書式が move 命令に一緒に来た時に、VntPose を作る

例:

“P10+(10,0,0,0,0,0)” “@P P10+(10,0,0,0,0,0)”

文字列構文では内部 P 番号に保持された fig 情報を使う経路を維持するため、

pose(fig) 解釈を追加しない。

Parameters:
  • target (str)

  • path_blend (str | None)

Return type:

list | bool

_move(lComp, vntPose, bstrOpt=None)[source]

LOW level API. ポーズ: P型, J型(6軸指定), T型。 @から始まるのはパス開始変位: “@0”, “@P”, “@E”, “@<数値>”, “@A<数値>” のいずれか。

@P Pose(登録済みポーズ名) @E External pose(外部ポーズ) @L ローカルポーズ @T Tool座標系 @W Work座標系

これが “@P P2” とあると、P2 がポーズなのか何なのかわからないので必要。

“<変数型><番号>” または “[<変数型>](<要素1>,<要素2>,…)” の形式。

lComp1,2: PTP/Line

[<@パス開始変位>]<ポーズ> [<付加軸オプション>] 例: “P1”, “@P T100”, “@E J520”

lComp3: Circle 円弧補完

<ポーズ1>, [<@パス開始変位>] <ポーズ2> [<付加軸オプション>] ※ ポーズ1,2は必ず同じ変数型でなくてはなりません。 例: “P1, @E P2”, “T100, @P T101”

lComp4: Spline

[<@パス開始変位>]<自由曲線軌道番号> [<付加軸オプション>] 例: “1”, “@P 20”, “@E 5”

Parameters:
  • lComp (int) – 保管方法。

  • vntPose – ポーズ列。

  • bstrOpt (str | int) – 動作オプション。

Returns:

戻り値はありません。

Return type:

None

_move_core(lComp, target, coord_type, path_blend, offset, pose, bstrOpt)[source]

move 実行の分岐のみ担当。

target の解釈は make_* 系へ委譲する。

Parameters:
  • lComp (int)

  • target (str | list | tuple)

  • coord_type (str | None)

  • path_blend (str | None)

  • offset (str | tuple | list | None)

  • pose (int | None)

  • bstrOpt (str | int | None)

Return type:

bool

static _normalize_offset(offset)[source]

(0,0,10) のときに (0,0,10,0,0,0) として、rx,ry,yzを暗黙にしないで加える

(0,0,0,10) のときに (0,0,0,10,0,0) となる

Parameters:

offset (list | tuple)

Return type:

list

_release_loaded_file(cobotta_filename)[source]
Parameters:

cobotta_filename (str)

Return type:

None

_release_loaded_task()[source]
Return type:

None

_resolve_bstrOpt(bstrOpt, speed=None, is_async=True, accel=None, decel=None)[source]
Parameters:
  • bstrOpt (str | int | None)

  • speed (int | None)

  • is_async (bool | None)

  • accel (float | None)

  • decel (float | None)

Return type:

str | bool | None

_resolve_hand_bstrOpt(bstrOpt=None, is_async=False)[source]
Parameters:
  • bstrOpt (str | int | None)

  • is_async (bool | None)

Return type:

str | bool | None

_resolve_motion_mode(mode)[source]
Parameters:

mode (int | str | MotionMode | None)

Return type:

MotionMode

static _strip_path_prefix(base)[source]

@ステートメントを消す: @P P1 → P1, @0 P14 → P14 などに変換

Parameters:

base (str)

Return type:

str

static _to_bstrOpt_string(opt)[source]
Parameters:

opt (str | int | None)

Return type:

str | None

_to_p_string(offset)[source]

6軸表示 str ならそのまま、list ならば offset 値の書式(P書式)にする

Parameters:

offset (str | list | tuple)

Return type:

str | bool

property accel
approach(lComp, vntPoseBase, vntPoseLen, bstrOpt)[source]
property asp_mode
autocal(origin=False)[source]

起動時のCALSETが有効になっていると動かない

Parameters:

origin (bool)

Return type:

bool

property busy_status

アーム動作中のならば True

change_tool(no)[source]
Parameters:

no (int)

Return type:

bool

Returns:

change_work(work_no)[source]
Parameters:

work_no (int) – 0=ベース座標系

Return type:

bool

Returns:

clear_log()[source]

ClearLog (clear and start ctrl log)

clear_servo_log()[source]

ClearServoLog

static connect()[source]

dummy

property coord_type
property current_angle: list | tuple | bool

J型で取得, @Current_Position と同等

property current_position: list | tuple | bool

P型で取得, @Current_Position と同等

property decel
delete()[source]

GiveArm

Return type:

bool

dev(base, offset)[source]

基準位置にたいするオフセットで、座標を作る P型が対象 そして、P型の座標だが、+1要素を返すので、move系とかに食わせるときは注意

# NG # ret = self._caoRob.Execute(“Dev”, [“@P P1222”, “P(-50,0,20)”]) # ret = self._caoRob.Execute(“Dev”, (“P1”, (1, 1, 1)))

# OK (省略時はお尻が全部ゼロ) # ret = self._caoRob.Execute(“Dev”, (“P1”, “P(0, 0, 0)”)) # ret = self._caoRob.Execute(“Dev”, (“P10”, “P(100, 200, 300, 180, 0, 180)”)) # ret = self._caoRob.Execute(“Dev”, (“P10”, “P(100, 200, 300, 180, 0, 180)”)) # ret = self._caoRob.Execute( # “Dev”, (“P(100, 200, 300, 180, 0, 180)”, “P(100, 200, 300, 180, 0, 180)”) # )

cobotta.dev(“P1”, [1.0, 0.0, 0.0, 0.0, 0.0, 0.0, -2.0]) cobotta.dev(“P1”, “P(0,0,0)”)

Parameters:
  • base (str | list | tulpe)

  • offset (str | list | tuple)

Return type:

list | tuple | bool

Returns:

property direct_mode
disconnect()[source]
Return type:

bool

download_all_files_from_cobotta(output_dir=None, skip_filenames=None)[source]

COBOTTA内全ファイルをローカル保存

Parameters:
  • output_dir (str | Path | None) – 保存先ディレクトリ

  • skip_filenames (set or list) – 除外したいファイル名

Returns:

全ファイル保存成功でTrue、失敗が1つでもあればFalse

Return type:

bool

download_file_from_cobotta(cobotta_filename, output_dir=None)[source]

COBOTTA内部の指定ファイルをローカルに保存

Parameters:
  • cobotta_filename (str) – COBOTTA内部ファイル名( without .pcs)

  • output_dir (str | Path | None) – 保存先ディレクトリ

Returns:

成功すればTrue、失敗すればFalse

Return type:

bool

drive(target, *, relative=False, path_blend=None, speed=None, is_async=False, bstrOpt=None)[source]

単一APIで DriveEX(相対) / DriveAEX(絶対)を切り替えて実行する統合メソッド。

Parameters:
  • target (str | list | tuple | None) –

    文字列(PacScript書式)または (軸, 値) のペア、もしくはそのリスト / タプル。 例:

    ”(1,10),(2,20)” [(1,10), (2,20)] (1, 10)

  • relative (bool) – True のとき相対移動(DriveEX)、False のとき絶対移動(DriveAEX)。

  • path_blend (str | None) – 先頭に付与する経路ブレンド指定(例: “@0”, “Next” など)。 None の場合は self.path_blend を踏襲。

  • speed (int | None) – 速度指定(_resolve_bstrOpt に委譲して bstrOpt を構成)。

  • is_async (bool | None) – 非同期指定(_resolve_bstrOpt に委譲)。

  • bstrOpt (str | int | None) – 追加オプション指定。speed / is_async とマージされる。

Returns:

実行成功時 True、失敗時 False。

Return type:

bool

drive_A(target, *, path_blend=None, speed=None, is_async=True, bstrOpt=None)[source]
Parameters:
  • target (str | list)

  • path_blend (str | None)

  • speed (int | None)

  • is_async (bool | None)

  • bstrOpt (str | int | None)

Return type:

bool

drive_AEX(target, *, path_blend=None, speed=None, is_async=True, bstrOpt=None)[source]

絶対移動 POSEDATA 6軸

Parameters:
  • target (str | list | tuple | None)

  • path_blend (str | None)

  • speed (int | None)

  • is_async (bool | None)

  • bstrOpt (str | int | None)

Return type:

bool

drive_EX(target, *, path_blend=None, speed=None, is_async=True, bstrOpt=None)[source]

相対移動 POSEDATA 6軸

Parameters:
  • target (str | list | tuple)

  • path_blend (str | None)

  • speed (int | None)

  • is_async (bool | None)

  • bstrOpt (str | int | None)

Return type:

bool

property error_code
property error_description

最後のエラーの内容表示

property extaccel
property extdecel
property extspeed
get_F(id_num)[source]
Parameters:

id_num (int)

Return type:

float | bool

get_I(id_num)[source]
Parameters:

id_num (int)

Return type:

int | bool

get_IO(id_num)[source]
Parameters:

id_num (int)

Return type:

Any

get_P(id_num)[source]
Parameters:

id_num (int)

Return type:

List[float] | bool

get_accel()[source]
Return type:

float | bool

get_all_var()[source]

変数名の入手(@var)一覧

get_cobotta_all_files_content(skip_filenames=None)[source]

COBOTTA内全ファイル内容を [{‘filename’:…, ‘content’:…}, …] で返す(保存しない) クラス内に保存するだけ

Parameters:

skip_filenames (set or list) – 除外したいファイル名

Returns:

[{‘filename’:…, ‘content’:…}, …]

Return type:

list

get_cobotta_file_content(cobotta_filename)[source]
Parameters:

cobotta_filename (str)

Return type:

Optional[Dict[str, str]]

get_cobotta_file_names()[source]

cobotta 内部のファイル一覧(cao.fileName)

Returns:

Return type:

List[str] | Tuple[str, …] | None

get_coord_type()[source]
Return type:

str

get_current_angle()[source]
Return type:

list | tuple | bool

get_current_error_info()[source]

現在発生しているエラーの情報を返す(現在のエラー1件)

get_current_jnt()[source]

@CURRENT_ANGLE と同等

Return type:

list | tuple | bool

get_current_pose()[source]

現在の P座標の fig(pose) を取得する。

Return type:

int | bool

get_current_position()[source]

現在位置 P型で取得, @Current_Position と同等

Return type:

list | tuple | bool

get_current_tool()[source]

現在のツール(座標軸)番号

Return type:

bool

get_current_tool_no()[source]
get_current_work_no()[source]

CurWork

現在の work(座標軸) 番号を取得 Change で work 版ををそもそも定義してないと例外が出る

Returns:

Return type:

int | bool

get_decel()[source]
Return type:

float | bool

get_direct_mode()[source]

True:Move() など、False: PacScript

get_error()[source]

現在 RC8 に蓄積しているエラー情報をすべて取得して返す。

戻り値:
[

[error_code, message, subcode, file_line, progname, line, file_id], …

]

get_error_code()[source]
get_error_count()[source]

b-cap制御からの逆輸入 現在 RC8 に蓄積しているエラー件数を返す。

get_error_description(error_code)[source]

b-cap制御からの逆輸入 error_code から RC8 の説明文字列を取得する。

Parameters:

error_code (int)

Return type:

str | bool

get_error_info(index)[source]

b-cap制御からの逆輸入 index 番目のエラー詳細を返す。

Parameters:

index (int) – index 番目

Returns:

index 番目のエラー詳細

Return type:

str

get_extaccel()[source]
Return type:

float | bool

get_extdecel()[source]
Return type:

float | bool

get_extspeed()[source]
Return type:

int | bool

get_file_object(filename)[source]

同じファイル名のAddFileは一度きり。

Parameters:

filename

Returns:

get_jspeed()[source]
Return type:

int | bool

get_log_count()[source]

GetLogCount

Return type:

int

get_log_record(index)[source]

GetLogRecord

Parameters:

index (int)

Return type:

int

get_motion_complete()[source]

アームが停止しているのならば True (MotonComplete)

get_motion_mode()[source]
get_motion_preparation()[source]

動作準備完了状態を取得します. 動作準備完了状態でない場合,AutoCal 以外でロボット動作できません. 動作準備完了状態は,セーフティのエラー発生,非常停止 ON,防護停止 ON, セーフティパラメータの送信で,未完了状態になりま

Returns:

get_open_files()[source]

コボッタ内部のファイルを開いたりするのに使う

get_path_blend()[source]
Return type:

str

get_speed()[source]
Return type:

int | bool

get_task_status()[source]

task_state のbool値とかぶるので、None のままだと None, 例外でも None にする

get_tool(tool_no)[source]
Parameters:

tool_no (int)

Return type:

list | tuple | bool

get_tool_define(tool_no)[source]

現在のツール座標軸 取得

Parameters:

tool_no (int)

Return type:

list | tuple | bool

Returns:

get_var(kind_or_combined, id_num=None)[source]

kind_or_combined: ‘P’, ‘I’, ‘F’, ‘IO’ または ‘P40’, ‘IO0’ のような形式 id_num: 数値ID(省略可能)

get_var(‘P’, 40) get_var(‘IO’, 0) get_var(‘P40’) get_var(‘IO0’)

Parameters:
  • kind_or_combined (str)

  • id_num (int | None)

Return type:

Any

static get_version(rel_toml_path)[source]
Parameters:

rel_toml_path

Returns:

get_work(work_no=None)[source]

GetWorkDef

Parameters:

work_no (int | None)

Return type:

list | tuple | bool

Returns:

give_arm()[source]

Arm の解放(サーバー側で cobotta 側を解放) サーバーを使うマルチユーザーはまだ考慮してない

Returns:

可否(例外が出たら否)

Return type:

bool

halt()[source]

Robo 停止(moveとかと止めるとき)

Returns:

True/False

Return type:

bool

hand(pos=None, *, position=None, force=None, direction=True, relative=False, speed=None, is_async=False, bstrOpt=None)[source]
Parameters:
  • pos (int | None)

  • position (int | None)

  • force (int | None)

  • direction (bool | int)

  • relative (bool)

  • speed (int | None)

  • is_async (bool | None)

  • bstrOpt (str | int | None)

Return type:

bool

hand_move_A(pos=None, *, position=None, speed=None, is_async=False, bstrOpt=None)[source]
Parameters:
  • pos (int | None)

  • position (int | None)

  • speed (int | None)

  • is_async (bool | None)

  • bstrOpt (str | int | None)

Return type:

bool

hand_move_AH(pos=None, *, position=None, force, speed=None, is_async=False)[source]
Parameters:
  • pos (int | float | None)

  • position (int | float | None)

  • force (int | float)

  • speed (int | None)

  • is_async (bool | None)

Return type:

bool

hand_move_H(force, direction=True, *, speed=None, is_async=False, bstrOpt=None)[source]
Parameters:
  • force (int)

  • direction (bool | int)

  • speed (int | None)

  • is_async (bool | None)

  • bstrOpt (str | int | None)

Return type:

bool

hand_move_R(pos=None, *, position=None, speed=None, is_async=False, bstrOpt=None)[source]
Parameters:
  • pos (int | None)

  • position (int | None)

  • speed (int | None)

  • is_async (bool | None)

  • bstrOpt (str | int | None)

Return type:

bool

hand_open(speed=None)[source]
Parameters:

speed (int | None)

Return type:

bool

hand_stop()[source]
Return type:

bool

init_hand()[source]

hand の回転だけ初期位置へ

Return type:

bool

is_running()[source]
j2p(j_type_pos)[source]

j型をp型に変換する

Parameters:

j_type_pos (list | tuple)

Return type:

list | tuple | bool

property jspeed
property lock
property manual_move_mode
motion_complete()[source]

アームが停止しているのならば inactive

Return type:

str | bool

property motion_mode
move(target, *, motion_mode=None, coord_type=None, path_blend=None, offset=None, pose=None, speed=None, accel=None, decel=None, is_async=True, bstrOpt=None)[source]

Next は途中で止めるためというよりは、move() 事態を非同期にすることで move() move() がならんだときに、最初の move が終わってないときに次の move を読み込むことで モーションをつなげる意図がある。つまり、そのための非同期実行のオプション デフォルトで True としておく つまり、FINAL にするためには、MotionComplete が必要 というのをデフォルト動作にする –> Next を一般的ではない気がするので、async かな。

target:
  • list(6/7) → vntPose形式 [Pos, coord_type, path_blend] へ自動変換

    ※7要素なら先頭6要素だけ使う

  • list(3) → 既にvntPose形式

  • str → “@P P2”等はそのまま

Parameters:
  • target (str | list | tuple)

  • motion_mode (int | str | MotionMode | None)

  • coord_type (str | None)

  • path_blend (str | None)

  • offset (tuple | list | None)

  • pose (int | None)

  • speed (int | None)

  • accel (float | None)

  • decel (float | None)

  • is_async (bool | None)

  • bstrOpt (str | int | None)

Return type:

bool

move_C(target, *, coord_type=None, path_blend=None, offset=None, pose=None, speed=None, accel=None, decel=None, is_async=True, bstrOpt=None)[source]

Circle 円弧補完

Parameters:
  • target (str | list | tuple)

  • coord_type (str | None)

  • path_blend (str | None)

  • offset (tuple | list | None)

  • pose (int | None)

  • speed (int | None)

  • accel (float | None)

  • decel (float | None)

  • is_async (bool | None)

  • bstrOpt (str | int | None)

Return type:

bool

move_L(target, *, coord_type=None, path_blend=None, offset=None, pose=None, speed=None, accel=None, decel=None, is_async=True, bstrOpt=None)[source]

Line 直線補完

Parameters:
  • target (str | list | tuple)

  • coord_type (str | None)

  • path_blend (str | None)

  • offset (tuple | list | None)

  • pose (int | None)

  • speed (int | None)

  • accel (float | None)

  • decel (float | None)

  • is_async (bool | None)

  • bstrOpt (str | int | None)

Return type:

bool

move_P(target, *, coord_type=None, path_blend=None, offset=None, pose=None, speed=None, accel=None, decel=None, is_async=True, bstrOpt=None)[source]

PTP

Parameters:
  • target (str | list | tuple)

  • coord_type (str | None)

  • path_blend (str | None)

  • offset (tuple | list | None)

  • pose (int | None)

  • speed (int | None)

  • accel (float | None)

  • decel (float | None)

  • is_async (bool | None)

  • bstrOpt (str | int | None)

Return type:

bool

move_S(target, *, coord_type=None, path_blend=None, offset=None, pose=None, speed=None, accel=None, decel=None, is_async=True, bstrOpt=None)[source]

Spline 自由曲線補完

Parameters:
  • target (str | list | tuple)

  • coord_type (str | None)

  • path_blend (str | None)

  • offset (tuple | list | None)

  • pose (int | None)

  • speed (int | None)

  • accel (float | None)

  • decel (float | None)

  • is_async (bool | None)

  • bstrOpt (str | int | None)

Return type:

bool

property open_files

コボッタ内部のファイルを開いたりするのに使う

open_hand(speed=None)[source]
Parameters:

speed (int | None)

Return type:

bool

p2j(p_type_pos)[source]

P型をJ型に変換する

Parameters:

p_type_pos (list | tuple)

Return type:

list | tuple | bool

property path_blend
print_error(e)[source]
Return type:

bool

print_error_info(e)[source]
Return type:

bool

property rc8_type
property rc8_type_name
release_arm()[source]

リリースアーム

Returns:

成功か失敗か?

Return type:

bool

static remove_extension(filename)[source]

拡張子を除く

Parameters:

filename (str)

Return type:

str

reset_error()[source]
Returns:

成功か失敗か?

Return type:

bool

rotate("XY", 25[, 200, -20, 197])[source]
Parameters:
  • plane (str) – “XY”, “XZ”, “YZ”

  • angle (float) – 回転角(deg)

  • center (list) – 回転中心(V(xx,yy,zz)))

  • path_blend (str)

  • speed (int) – 速度%

  • is_async (bool | None)

  • bstrOpt (str | int | None)

Return type:

bool

Returns:

rotate_H(angle, *, path_blend=None, speed=None, is_async=True, bstrOpt=None)[source]

相対角度

(*) 相対なので、今いる角度によっては動かないことがある 今のポジションから目標ポジションで、ツールポイントの速度が決まるのでそれがハード限界を超えることがある

アプローチベクトルを軸とした回転動作 ふつうはエンドエフェクタの中心面に垂直がアプローチベクトル つまりJ座標で見れば J6 となる。のが普通

caoRob.Execute”RotateH”, Array(“@P 32.5” ,”S=50” )

Parameters:
  • angle (str | float | int)

  • path_blend (str | None)

  • speed (int | None)

  • is_async (bool | None)

  • bstrOpt (str | int | None)

Return type:

bool

run_script()[source]
Return type:

bool

property servo_on
set_F(id_num, value)[source]
Parameters:
  • id_num (int)

  • value (float)

Return type:

bool

set_I(id_num, value)[source]
Parameters:
  • id_num (int)

  • value (int)

Return type:

bool

set_IO(id_num, value)[source]
Parameters:
  • id_num (int)

  • value (float)

Return type:

bool

set_P(id_num, value)[source]
Parameters:
  • id_num (int)

  • value (List[float] | Tuple[float, ...])

Return type:

bool

set_accel(accel)[source]

軸毎のセットはなく、0:全軸(JSPEED)、-1:合成速度(SPEED)のみ

Parameters:

accel (float)

Return type:

bool

set_coord_type(coord_type)[source]

self._coord_type = “J”

Parameters:

coord_type (str)

Return type:

bool

Returns:

set_decel(decel)[source]

軸毎のセットはなく、0:全軸(JSPEED)、-1:合成速度(SPEED)のみ

Parameters:

decel (float)

Return type:

bool

set_extaccel(extaccel)[source]
Parameters:

extaccel (float)

Return type:

bool

set_extdecel(extdecel)[source]
Parameters:

extdecel (float)

Return type:

bool

set_extspeed(speed)[source]

軸毎のセットはなく、0:全軸(JSPEED)、-1:合成速度(SPEED)のみ

Parameters:

speed (int)

Return type:

bool

set_jspeed(speed)[source]

軸毎のセットはなく、0:全軸(JSPEED)、-1:合成速度(SPEED)のみ

Parameters:

speed (int)

Return type:

bool

set_motion_mode(mode)[source]
Parameters:

mode (int | str | MotionMode)

Return type:

bool

set_path_blend(path_blend)[source]

self._path_blend = “@P” パス変異量、次のパスへつなぐ動作をいつ開始するのか?

Parameters:

path_blend (str)

Return type:

None

set_speed(speed)[source]

軸毎のセットはなく、0:全軸(JSPEED)、-1:合成速度(SPEED)のみ

Parameters:

speed (int)

Return type:

bool

set_tool(tool_no, tool_define)[source]
Parameters:
  • tool_no (int)

  • tool_define (tuple | list | str)

Return type:

bool

set_tool_define(tool_no, tool_define)[source]

ツール座標軸のセット

Parameters:
  • tool_no (int)

  • tool_define (tuple | list | str) – [X,Y,Z,RX,RY,RZ]

Returns:

セット成功か否か?

Return type:

bool | None

set_var(kind_or_combined, id_or_value, value=None)[source]

kind_or_combined: ‘P’, ‘I’, ‘F’, ‘IO’ または ‘P40’, ‘IO0’ のような形式 id_or_value: ID番号または(combined形式のときは)value value: 実際の値(combined形式のときに指定)

Parameters:
  • kind_or_combined (str)

  • id_or_value (Any)

  • value (Any)

Return type:

bool

set_work(work_no, work_define, work_attribute=0)[source]

1, “P2” 1, “P(100, 200, 300, 180, 0, 180)”

Parameters:
  • work_no (int)

  • work_define (tuple | list | str) – [X,Y,Z,RX,RY,RZ]

  • work_attribute (int)

Return type:

bool

property speed: int | None

内部スピード(100パーセント), take_arm で100に初期化, 実速度=内部x外部

start_log()[source]

StartLog

start_servo_log()[source]

StartServoLog

state()[source]
stop()[source]

それぞれの 停止命令(ハンド,move,タスク)を実行する

Returns:

stop_log()[source]

StopLog

stop_servo_log()[source]

StopServoLog

take_arm()[source]

AddRbot() and Take Arm() cobotta を追加して、手動動作する (PacScript動作ではない)

Return type:

bool

take_camera(evp_script_name, pac_script_name=None)[source]

一連の作業を省略するためだけのメソッド

  1. EVP2用のスクリプト名を入れる(事前にカメラ側で作っておく)

  2. 撮影用のPacScript自動作成(PacScript名だけを設定する)

  3. take_script

Parameters:
  • evp_script_name (str)

  • pac_script_name (str) – 内部でこっそり使うスクリプト名(なんでもいい)

Return type:

bool

take_script(script='pro1')[source]

AddTask() and AddVariable() PacScript を追加して、スクリプト動作する

Parameters:

script (str) – PacScript Name (拡張しありを入れる)

Return type:

bool

property task
property task_state
task_stop()[source]

Task 停止 個別の motor の停止とはことなって、task run を止める

Returns:

True/False

Return type:

bool

test(lComp=1, bstrOpt=None)[source]
Parameters:
  • lComp (int)

  • bstrOpt (int | str | None)

Return type:

bool

test1(lComp=1, bstrOpt=None)[source]
Parameters:
  • lComp (int)

  • bstrOpt (str | int | None)

Return type:

bool

test2(bstrOpt=None)[source]
Parameters:

bstrOpt (int | str | None)

Return type:

bool

test3(bstrOpt=None)[source]
Parameters:

bstrOpt (str | int | None)

Return type:

bool

turn_off_motor()[source]

モーター off

Returns:

可否

Return type:

bool

turn_on_motor()[source]

モーターON

Returns:

可否

Return type:

bool

upload_content_to_cobotta(file_content, cobotta_filename)[source]
Parameters:
  • file_content (str)

  • cobotta_filename (str)

Return type:

bool

Returns:

upload_file_to_cobotta(upload_filename, cobotta_filename)[source]
Parameters:
  • upload_filename (str|Path) – アップロードするローカルのファイル

  • cobotta_filename (str) – cobotta 内部でのファイル名

Return type:

bool

Returns:

wait_for_complete()[source]
Return type:

bool

cobotta2.cobotta_orin2_state module

cobotta2.cobotta_orin2_test module

cobotta2.config module

Kengo NAKADA: https://github.com/shimane-dev, https://github.com/kengo-nakada kengo.nakada@mat.shimane-u.ac.jp, kengo.nakada@gmail.com

class Config(yaml_path=None)[source]

Bases: object

BCAP_PORT = 5007
CLIENT_LOGGER_NAME = 'cobotta_client'
COBOTTA_IP = '10.170.10.35'
JOYPAD_INTERVAL = 0.01
JOYPAD_LOGGER_NAME = 'cobotta_joypad'
JOYPAD_PORT = 50051
LOGGER_LEVEL = 'debug'
SERVER_IP = '10.170.10.33'
SERVER_LOGGER_NAME = 'cobotta_server'
SERVER_PORT = 8002
TIMEOUT = 5
_load_yaml(*, yaml_path, depth)[source]

コンストラクタから呼び出す

Parameters:

depth (int)

static _resolve_path(*, yaml_path, depth)[source]

絶対パスならそのまま、相対パスならこのメソッドの呼び出し元を基準に解決する

Parameters:
  • yaml_path (str | Path)

  • depth (int)

Return type:

Path

classmethod load_yaml(yaml_path)[source]

クラスとして使う

cobotta2.robot_var_manager module

class RobotVarManager(robot_instance=None, logger=None, filename=None, autosave=False, autoload=False)[source]

Bases: object

Cobotta だけではなく一般的な Robot 向けの座標マネージャ

Parameters:
  • filename (str | None)

  • autosave (bool)

  • autoload (bool)

_autosave_if_enabled()[source]

autosave=True のときだけ現在のローカル変数を保存する。

static _make_key(kind_or_combined, num=None)[source]

(“P”, 10) と “P10” を同じキー表現へ正規化する。

Parameters:
  • kind_or_combined (str)

  • num (str | int | None)

Return type:

str

add_robot(cobotta)[source]
attach_robot(cobotta)[source]
get_robot(varname)[source]

Cobotta本体から値を取得し、managerにも反映

Parameters:

varname (str)

get_var(kind_or_combined, num=None, default=False)[source]

単一ローカル変数を取得する。

get_var(“P”, 10) と get_var(“P10”) は同じ意味である。 変数が存在しない場合は CobottaCtrl 側の慣例に合わせて False を返す。

Parameters:
  • kind_or_combined (str)

  • num (str | int | None)

  • default (Any)

list_vars()[source]
load(filename=None)[source]
read_var_from_robot(kind, num=None)[source]

cobotta本体 –> managerに反映

Parameters:
  • kind (str)

  • num (str | int | None)

read_vars_from_robot(kind, start, end=None)[source]

cobotta本体 –> managerに反映

Parameters:
  • kind (str)

  • start (str | int)

save(filename=None)[source]
set_var(kind, num, value=None, save=None)[source]

単一ローカル変数のセット。

set_var(“P”, 10, value) と set_var(“P10”, value) の両方を受け付ける。

Parameters:
  • kind (str) – 変数種別または結合済み変数名。例: “P”, “P10”。

  • num (str | int | Any) – 変数番号、または kind が結合済み変数名の場合の値。

  • value – 保存する値。

  • save (bool | None) – JSON保存制御。None の場合は autosave 設定に従う。 True の場合は即保存し、False の場合は保存しない。

set_vars(kind, start, end=None, value=None)[source]

ローカル変数の一括/範囲セット(cobotta本体には影響しない)

例::

set_vars(“P”, 10, value=[1,2,3,4,5,6]) set_vars(“P”, 10, 12, value=[ [1,2,3,4,5,6], … ])

Parameters:
  • kind

  • start

  • end

  • value

Returns:

write_all_to_robot()[source]

Manager に存在する全変数を robot_instance 本体に一斉反映(超危険)

write_var_to_robot(kind, num=None)[source]

end 省略と同じ意味 manager –> cobotta本体へ反映(危険!)

Parameters:
  • kind (str)

  • num (str | int | None)

write_vars_to_cobotta(kind, start, end=None)[source]

end 省略で var のみ登録(一つだけ) manager –> cobotta本体へ反映(危険!)

cobotta2.server module