dobot package

Dobot MG400 制御パッケージ。

Subpackages

Submodules

dobot.config module

Dobot の設定構造と YAML 読み込みを定義する。

class dobot.config.Config(yaml_path=None)[ソース]

ベースクラス: object

Dobot の設定構造。

実際の環境ごとの設定値は YAML から読み込む。 クラスとしての読み込みと、インスタンスごとの読み込みの両方に対応する。

CLIENT_LOGGER_NAME = 'dobot_client'
DOBOT_IP = '192.168.1.6'
INSTANCE_NAME = 'Ctrl'
LOGGER_LEVEL = 'INFO'
SERVER_IP = '127.0.0.1'
SERVER_LOGGER_NAME = 'dobot_server'
SERVER_PORT = 8000
TIMEOUT = 5
classmethod load_yaml(yaml_path)[ソース]

YAML を読み込み、Config クラスの設定値を更新する。

dobot.dobot_api module

class dobot.dobot_api.DobotApi(ip, port, *args)[ソース]

ベースクラス: object

close()[ソース]

Close the port

log(text)[ソース]
sendRecvMsg(string)[ソース]

send-recv Sync

send_data(string)[ソース]
wait_reply()[ソース]

Read the return value

class dobot.dobot_api.DobotApiDashboard(ip, port, *args)[ソース]

ベースクラス: DobotApi

Define class dobot_api_dashboard to establish a connection to Dobot

AccJ(speed)[ソース]

Set joint acceleration ratio (Only for MovJ, MovJIO, MovJR, JointMovJ commands) speed : Joint acceleration ratio (Value range:1~100)

AccL(speed)[ソース]

Set the coordinate system acceleration ratio (Only for MovL, MovLIO, MovLR, Jump, Arc, Circle commands) speed : Cartesian acceleration ratio (Value range:1~100)

Arch(index)[ソース]

Set the Jump gate parameter index (This index contains: start point lift height, maximum lift height, end point drop height) index : Parameter index (Value range:0~9)

BrakeControl(offset1, offset2)[ソース]
CP(ratio)[ソース]

Set smooth transition ratio ratio : Smooth transition ratio (Value range:1~100)

ClearError()[ソース]

Clear controller alarm information

Continue()[ソース]
ContinueScript()[ソース]

Continue running the script

DI(offset1)[ソース]
DO(index, status)[ソース]

Set digital signal output (Queue instruction) index : Digital output index (Value range:1~24) status : Status of digital signal output port(0:Low level,1:High level

DOExecute(offset1, offset2)[ソース]
DOGroup(*dynParams)[ソース]
DisableRobot()[ソース]

Disabled the robot

EmergencyStop()[ソース]
EnableRobot(*dynParams)[ソース]

Enable the robot

GetAngle()[ソース]
GetCoils(offset1, offset2, offset3)[ソース]
GetErrorID()[ソース]

Get robot error code

GetHoldRegs(id, addr, count, type=None)[ソース]

Read hold register id :Secondary device NUMBER (A maximum of five devices can be supported. The value ranges from 0 to 4

Set to 0 when accessing the internal slave of the controller)

addr :Hold the starting address of the register (Value range:3095~4095) count :Reads the specified number of types of data (Value range:1~16) type :The data type

If null, the 16-bit unsigned integer (2 bytes, occupying 1 register) is read by default "U16" : reads 16-bit unsigned integers (2 bytes, occupying 1 register) "U32" : reads 32-bit unsigned integers (4 bytes, occupying 2 registers) "F32" : reads 32-bit single-precision floating-point number (4 bytes, occupying 2 registers) "F64" : reads 64-bit double precision floating point number (8 bytes, occupying 4 registers)

GetInBits(offset1, offset2, offset3)[ソース]
GetInRegs(offset1, offset2, offset3, *dynParams)[ソース]
GetPose()[ソース]
InverseSolution(offset1, offset2, offset3, offset4, user, tool, *dynParams)[ソース]
LimZ(value)[ソース]

Set the maximum lifting height of door type parameters value : Maximum lifting height (Highly restricted:Do not exceed the limit position of the z-axis of the manipulator)

LoadSwitch(offset1)[ソース]
ModbusClose(offset1)[ソース]
ModbusCreate(ip, port, slave_id, isRTU)[ソース]
PauseScript()[ソース]

Pause the script

PayLoad(weight, inertia)[ソース]

Setting robot load weight : The load weight inertia: The load moment of inertia

PositiveSolution(offset1, offset2, offset3, offset4, user, tool)[ソース]
ResetRobot()[ソース]

Robot stop

RobotMode()[ソース]

View the robot status

RunScript(project_name)[ソース]

Run the script file project_name :Script file name

SetArmOrientation(offset1)[ソース]
SetCoils(offset1, offset2, offset3, offset4)[ソース]
SetCollisionLevel(offset1)[ソース]
SetHoldRegs(id, addr, count, table, type=None)[ソース]

Write hold register id :Secondary device NUMBER (A maximum of five devices can be supported. The value ranges from 0 to 4

Set to 0 when accessing the internal slave of the controller)

addr :Hold the starting address of the register (Value range:3095~4095) count :Writes the specified number of types of data (Value range:1~16) type :The data type

If null, the 16-bit unsigned integer (2 bytes, occupying 1 register) is read by default "U16" : reads 16-bit unsigned integers (2 bytes, occupying 1 register) "U32" : reads 32-bit unsigned integers (4 bytes, occupying 2 registers) "F32" : reads 32-bit single-precision floating-point number (4 bytes, occupying 2 registers) "F64" : reads 64-bit double precision floating point number (8 bytes, occupying 4 registers)

SetPayload(offset1, *dynParams)[ソース]
SpeedFactor(speed)[ソース]

Setting the Global rate speed:Rate value(Value range:1~100)

SpeedJ(speed)[ソース]

Set joint speed ratio (Only for MovJ, MovJIO, MovJR, JointMovJ commands) speed : Joint velocity ratio (Value range:1~100)

SpeedL(speed)[ソース]

Set the cartesian acceleration ratio (Only for MovL, MovLIO, MovLR, Jump, Arc, Circle commands) speed : Cartesian acceleration ratio (Value range:1~100)

StartDrag()[ソース]
StopDrag()[ソース]
StopScript()[ソース]

Stop scripts

Tool(index)[ソース]

Select the calibrated tool coordinate system index : Calibrated index of tool coordinates

ToolDI(offset1)[ソース]
ToolDO(offset1, offset2)[ソース]
ToolDOExecute(offset1, offset2)[ソース]
User(index)[ソース]

Select the calibrated user coordinate system index : Calibrated index of user coordinates

pause()[ソース]
wait(t)[ソース]
class dobot.dobot_api.DobotApiMove(ip, port, *args)[ソース]

ベースクラス: DobotApi

Define class dobot_api_move to establish a connection to Dobot

Arc(x1, y1, z1, r1, x2, y2, z2, r2, *dynParams)[ソース]

Circular motion instruction x1, y1, z1, r1 :Is the point value of intermediate point coordinates x2, y2, z2, r2 :Is the value of the end point coordinates Note: This instruction should be used together with other movement instructions

Circle(x1, y1, z1, r1, x2, y2, z2, r2, count, *dynParams)[ソース]

Full circle motion command count:Run laps x1, y1, z1, r1 :Is the point value of intermediate point coordinates x2, y2, z2, r2 :Is the value of the end point coordinates Note: This instruction should be used together with other movement instructions

JointMovJ(j1, j2, j3, j4, *dynParams)[ソース]

Joint motion interface (linear motion mode) j1~j6:Point position values on each joint

Jump(x, y, z, r, User=None, Tool=None, SpeedL=None, AccL=None, Start=None, End=None, ZLimit=None, auxJoint=None)[ソース]

调用示例:dobot.Jump(100, 200, 50, 45, User=1, Tool=2, SpeedL=50, AccL=50, Start=10, End=10, ZLimit=80) 门型运动指令 (Jump motion) x: X轴位置,单位:毫米 y: Y轴位置,单位:毫米 z: Z轴位置,单位:毫米 r: R轴位置,单位:毫米 User: 用户坐标系索引,取值范围:0~9,不填按照上一次设置的值 Tool: 工具坐标系索引,取值范围:0~9,不填按照上一次设置的值 SpeedL: 笛卡尔速度比例,取值范围:1~100,不填按照上一次设置的值 AccL: 笛卡尔加速度比例,取值范围:1~100,不填按照上一次设置的值 Start: 门型起始点抬升高度(单位:毫米),不填沿用 Arch() 设置 End: 门型结束点下降高度(单位:毫米),不填沿用 Arch() 设置 ZLimit: 门型最大抬升高度(单位:毫米),不填沿用 Arch() 设置 auxJoint: 滑轨辅助关节值

MovJ(x, y, z, r, *dynParams)[ソース]

Joint motion interface (point-to-point motion mode) x: A number in the Cartesian coordinate system x y: A number in the Cartesian coordinate system y z: A number in the Cartesian coordinate system z r: A number in the Cartesian coordinate system R

MovJExt(offset1, *dynParams)[ソース]
MovJIO(x, y, z, r, *dynParams)[ソース]

Set the digital output port state in parallel during point-to-point motion x: A number in the Cartesian coordinate system x y: A number in the Cartesian coordinate system y z: A number in the Cartesian coordinate system z r: A number in the Cartesian coordinate system r *dynParams :Parameter Settings(Mode、Distance、Index、Status)

Mode :Set Distance mode (0: Distance percentage; 1: distance from starting point or target point) Distance :Runs the specified distance(If Mode is 0, the value ranges from 0 to 100;When Mode is 1, if the value is positive,

it indicates the distance from the starting point. If the value of Distance is negative, it represents the Distance from the target point)

Index :Digital output index (Value range:1~24) Status :Digital output state(Value range:0/1)

MovL(x, y, z, r, *dynParams)[ソース]

Coordinate system motion interface (linear motion mode) x: A number in the Cartesian coordinate system x y: A number in the Cartesian coordinate system y z: A number in the Cartesian coordinate system z r: A number in the Cartesian coordinate system R

MovLIO(x, y, z, r, *dynParams)[ソース]

Set the digital output port state in parallel while moving in a straight line x: A number in the Cartesian coordinate system x y: A number in the Cartesian coordinate system y z: A number in the Cartesian coordinate system z r: A number in the Cartesian coordinate system r *dynParams :Parameter Settings(Mode、Distance、Index、Status)

Mode :Set Distance mode (0: Distance percentage; 1: distance from starting point or target point) Distance :Runs the specified distance(If Mode is 0, the value ranges from 0 to 100;When Mode is 1, if the value is positive,

it indicates the distance from the starting point. If the value of Distance is negative, it represents the Distance from the target point)

Index :Digital output index (Value range:1~24) Status :Digital output state(Value range:0/1)

MoveJog(axis_id=None, *dynParams)[ソース]

Joint motion axis_id: Joint motion axis, optional string value:

J1+ J2+ J3+ J4+ J5+ J6+ J1- J2- J3- J4- J5- J6- X+ Y+ Z+ Rx+ Ry+ Rz+ X- Y- Z- Rx- Ry- Rz-

*dynParams: Parameter Settings(coord_type, user_index, tool_index)

coord_type: 1: User coordinate 2: tool coordinate (default value is 1) user_index: user index is 0 ~ 9 (default value is 0) tool_index: tool index is 0 ~ 9 (default value is 0)

RelJointMovJ(offset1, offset2, offset3, offset4, *dynParams)[ソース]

The relative motion command is carried out along the joint coordinate system of each axis, and the end motion mode is joint motion Offset motion interface (point-to-point motion mode) j1~j6:Point position values on each joint *dynParams: parameter Settings(speed_j, acc_j, user)

speed_j: Set Cartesian speed scale, value range: 1 ~ 100 acc_j: Set acceleration scale value, value range: 1 ~ 100

RelMovJ(x, y, z, r, *dynParams)[ソース]

Offset motion interface (point-to-point motion mode) j1~j6:Point position values on each joint

RelMovJUser(offset_x, offset_y, offset_z, offset_r, user, *dynParams)[ソース]

The relative motion command is carried out along the user coordinate system, and the end motion mode is joint motion offset_x: X-axis direction offset offset_y: Y-axis direction offset offset_z: Z-axis direction offset offset_r: R-axis direction offset

user: Select the calibrated user coordinate system, value range: 0 ~ 9 *dynParams: parameter Settings(speed_j, acc_j, tool)

speed_j: Set joint speed scale, value range: 1 ~ 100 acc_j: Set acceleration scale value, value range: 1 ~ 100 tool: Set tool coordinate system index

RelMovL(offsetX, offsetY, offsetZ, offsetR, *dynParams)[ソース]

Offset motion interface (point-to-point motion mode) x: Offset in the Cartesian coordinate system x y: offset in the Cartesian coordinate system y z: Offset in the Cartesian coordinate system Z r: Offset in the Cartesian coordinate system R

RelMovLUser(offset_x, offset_y, offset_z, offset_r, user, *dynParams)[ソース]

The relative motion command is carried out along the user coordinate system, and the end motion mode is linear motion offset_x: X-axis direction offset offset_y: Y-axis direction offset offset_z: Z-axis direction offset offset_r: R-axis direction offset user: Select the calibrated user coordinate system, value range: 0 ~ 9 *dynParams: parameter Settings(speed_l, acc_l, tool)

speed_l: Set Cartesian speed scale, value range: 1 ~ 100 acc_l: Set acceleration scale value, value range: 1 ~ 100 tool: Set tool coordinate system index

Sync()[ソース]

The blocking program executes the queue instruction and returns after all the queue instructions are executed

SyncAll()[ソース]
dobot.dobot_api.alarmAlarmJsonFile()[ソース]

dobot.dobot_api_ext module

DOBOTベンダーAPIのプロジェクト向け拡張。

ベンダー提供 dobot_api.py は変更しない。 このモジュールでは、ベンダークラスを継承し、プロジェクト共通loggerへの 出力統一と、保持中TCPソケットの送信前死活確認だけを追加する。

class dobot.dobot_api_ext.DobotApiDashboardExt(ip, port, logger)[ソース]

ベースクラス: _DobotApiExtMixin, DobotApiDashboard

DobotApiDashboard のプロジェクト向け派生クラス。

GetInRegs(offset1, offset2, offset3, *dynParams)[ソース]
InverseSolution(offset1, offset2, offset3, offset4, user, tool, *dynParams)[ソース]
SetCoils(offset1, offset2, offset3, offset4)[ソース]
class dobot.dobot_api_ext.DobotApiExt(ip, port, logger)[ソース]

ベースクラス: _DobotApiExtMixin, DobotApi

DobotApi のプロジェクト向け派生クラス。

class dobot.dobot_api_ext.DobotApiMoveExt(ip, port, logger)[ソース]

ベースクラス: _DobotApiExtMixin, DobotApiMove

DobotApiMove のプロジェクト向け派生クラス。

Arc(x1, y1, z1, r1, x2, y2, z2, r2, *dynParams)[ソース]

Circular motion instruction x1, y1, z1, r1 :Is the point value of intermediate point coordinates x2, y2, z2, r2 :Is the value of the end point coordinates Note: This instruction should be used together with other movement instructions

Circle(x1, y1, z1, r1, x2, y2, z2, r2, count, *dynParams)[ソース]

Full circle motion command count:Run laps x1, y1, z1, r1 :Is the point value of intermediate point coordinates x2, y2, z2, r2 :Is the value of the end point coordinates Note: This instruction should be used together with other movement instructions

JointMovJ(j1, j2, j3, j4, *dynParams)[ソース]

Joint motion interface (linear motion mode) j1~j6:Point position values on each joint

Jump(x, y, z, r, User=None, Tool=None, SpeedL=None, AccL=None, Start=None, End=None, ZLimit=None, auxJoint=None)[ソース]

调用示例:dobot.Jump(100, 200, 50, 45, User=1, Tool=2, SpeedL=50, AccL=50, Start=10, End=10, ZLimit=80) 门型运动指令 (Jump motion) x: X轴位置,单位:毫米 y: Y轴位置,单位:毫米 z: Z轴位置,单位:毫米 r: R轴位置,单位:毫米 User: 用户坐标系索引,取值范围:0~9,不填按照上一次设置的值 Tool: 工具坐标系索引,取值范围:0~9,不填按照上一次设置的值 SpeedL: 笛卡尔速度比例,取值范围:1~100,不填按照上一次设置的值 AccL: 笛卡尔加速度比例,取值范围:1~100,不填按照上一次设置的值 Start: 门型起始点抬升高度(单位:毫米),不填沿用 Arch() 设置 End: 门型结束点下降高度(单位:毫米),不填沿用 Arch() 设置 ZLimit: 门型最大抬升高度(单位:毫米),不填沿用 Arch() 设置 auxJoint: 滑轨辅助关节值

MovJ(x, y, z, r, *dynParams)[ソース]

Joint motion interface (point-to-point motion mode) x: A number in the Cartesian coordinate system x y: A number in the Cartesian coordinate system y z: A number in the Cartesian coordinate system z r: A number in the Cartesian coordinate system R

MovJIO(x, y, z, r, *dynParams)[ソース]

Set the digital output port state in parallel during point-to-point motion x: A number in the Cartesian coordinate system x y: A number in the Cartesian coordinate system y z: A number in the Cartesian coordinate system z r: A number in the Cartesian coordinate system r *dynParams :Parameter Settings(Mode、Distance、Index、Status)

Mode :Set Distance mode (0: Distance percentage; 1: distance from starting point or target point) Distance :Runs the specified distance(If Mode is 0, the value ranges from 0 to 100;When Mode is 1, if the value is positive,

it indicates the distance from the starting point. If the value of Distance is negative, it represents the Distance from the target point)

Index :Digital output index (Value range:1~24) Status :Digital output state(Value range:0/1)

MovL(x, y, z, r, *dynParams)[ソース]

Coordinate system motion interface (linear motion mode) x: A number in the Cartesian coordinate system x y: A number in the Cartesian coordinate system y z: A number in the Cartesian coordinate system z r: A number in the Cartesian coordinate system R

dobot.dobot_ctrl module

DOBOT MG400 の共通制御 I/F。

このクラスは公開 I/F 層である。 MG400 固有の TCP/IP API、座標変換、コマンド変換、状態取得などの 実装は DobotTcp に置き、このクラスでは実装しない。

公開I/Fはロボット制御層として必要な操作をまとめ、 MG400固有の実装は DobotTcp に委譲する。

class dobot.dobot_ctrl.DobotCtrl(dobot_ip='192.168.1.6', instance_name='Ctrl', logger=None, log_level=None, auto_connect=True)[ソース]

ベースクラス: object

共通制御 I/F を DOBOT MG400 実装へ委譲する。

property accel
approach(lComp, vntPoseBase, vntPoseLen, bstrOpt=None)[ソース]
autocal(origin=False)[ソース]
property busy_status
change_tool(work_no)[ソース]
change_work(work_no)[ソース]
clear_log()[ソース]
clear_servo_log()[ソース]
connect()[ソース]
property coord_type
property current_angle
property current_position
property decel
delete()[ソース]
dev(base, offset)[ソース]
property direct_mode
disconnect()[ソース]
drive(target, *, relative=False, path_blend=None, speed=None, is_async=False)[ソース]
property error_code
property error_description
property extaccel
property extdecel
property extspeed
get_IO(id_num)[ソース]
get_accel()[ソース]
get_coord_type()[ソース]
get_current_angle()[ソース]
get_current_error_info()[ソース]
get_current_pose()[ソース]
get_current_position()[ソース]
get_current_tool()[ソース]
get_current_tool_no()[ソース]
get_current_work_no()[ソース]
get_decel()[ソース]
get_digital_input(id_num)[ソース]
get_direct_mode()[ソース]
get_error()[ソース]
get_error_code()[ソース]
get_error_count()[ソース]
get_error_description(error_code)[ソース]
get_error_info(index)[ソース]
get_extaccel()[ソース]
get_extdecel()[ソース]
get_extspeed()[ソース]
get_jspeed()[ソース]
get_log_count()[ソース]
get_log_record(index)[ソース]
get_motion_complete()[ソース]
get_motion_mode()[ソース]
get_motion_preparation()[ソース]
get_path_blend()[ソース]
get_speed()[ソース]
get_task_status()[ソース]
get_tool(tool_no)[ソース]
get_tool_define(tool_no)[ソース]
get_version(rel_toml_path)[ソース]
get_work(work_no=None)[ソース]
give_arm()[ソース]
halt()[ソース]
hand(pos=None, *, position=None, force=None, direction=True, relative=False, speed=None, is_async=False)[ソース]
hand_open(speed=None)[ソース]
hand_stop()[ソース]
init_hand()[ソース]
is_running()[ソース]
j2p(j_type_pos)[ソース]
jog(axis, direction, speed, step=None)[ソース]

関節JOGの共通I/F。

step=None では、jog_stop()を呼ぶまで指定方向へ連続JOGする。 step を指定した場合は、その絶対値だけ有限相対移動する。

パラメータ:
  • axis (int) -- 関節番号。

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

  • speed (float) -- 速度の大きさ。DOBOTでは速度倍率[%]として扱う。

  • step (Optional[float]) -- 有限JOG量。DOBOTでは関節角度[deg]。

jog_stop()[ソース]

jog()で開始した連続JOGを停止する。

property jspeed
property lock
motion_complete()[ソース]
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)[ソース]
open_hand(speed=None)[ソース]
p2j(p_type_pos)[ソース]
property path_blend
print_error(e)[ソース]
print_error_info(e)[ソース]
release_arm()[ソース]
reset_error()[ソース]
rotate(plane, angle, center, *, path_blend=None, speed=None, is_async=True)[ソース]
run_script()[ソース]
property servo_on
set_IO(id_num, value)[ソース]
set_accel(accel)[ソース]
set_coord_type(coord_type)[ソース]
set_decel(decel)[ソース]
set_extaccel(extaccel)[ソース]
set_extdecel(extdecel)[ソース]
set_extspeed(speed)[ソース]
set_jspeed(speed)[ソース]
set_motion_mode(mode)[ソース]
set_path_blend(path_blend)[ソース]
set_speed(speed)[ソース]
set_tool(tool_no, tool_define)[ソース]
set_tool_define(tool_no, tool_define)[ソース]
set_work(work_no, work_define, work_attribute=0)[ソース]
property speed
start_log()[ソース]
start_servo_log()[ソース]
state()[ソース]
stop()[ソース]
stop_log()[ソース]
stop_servo_log()[ソース]
take_arm()[ソース]
property task
property task_state
task_stop()[ソース]
turn_off_motor()[ソース]
turn_on_motor()[ソース]
wait_for_complete()[ソース]

dobot.dobot_error module

Dobot MG400のエラー取得・解析・表示を管理する。

DobotTcp からエラー関連処理を分離し、次の責務を集約する。

  • Dashboard GetErrorID() の構造解析

  • コントローラ/サーボアラームの識別

  • alarm JSONからの日本語説明・原因・対処取得

  • Feedback ErrorStatus と GetErrorID() による実行失敗判定

  • 非同期モーション受付直後のアラーム監視

TCP接続そのものは所有せず、Dashboard取得関数とFeedback状態取得関数を DobotTcp から受け取る。これにより通信ライフサイクルとエラー解釈を分離する。

class dobot.dobot_error.DobotErrorManager(*, dashboard_getter: Callable[[], Any], state_getter: Callable[[...], Any], scalar_status: Callable[[Any], int], logger: Any)[ソース]

ベースクラス: object

Dobotのアラーム取得・解釈・モーション失敗判定を担当する。

property error_description: str

現在発生中の全アラームを利用者向け文字列として返す。

static format_error_info(info: Dict[str, Any]) → str[ソース]

利用者向けにアラーム番号・内容・原因・対処を整形する。

get_current_error_info() → List[Dict[str, Any]][ソース]
get_error() → List[int][ソース]

現在発生中の全アラームIDを返す。

get_error_code() → int[ソース]

現在発生中の先頭アラームIDを返す。

get_error_count() → int[ソース]
get_error_description(error_code: int) → str[ソース]

指定IDの説明を返す。発生元不明時はControllerを優先する。

get_error_info(index: int) → Dict[str, Any] | None[ソース]
log_current_errors(command_name: str) → bool[ソース]

現在のエラー内容をログへ出す。エラーが存在すればTrue。

motion_error_active(command_name: str, *, query_error_id: bool = False) → bool[ソース]

FeedbackとGetErrorID()からモーション実行失敗を判定する。

print_error(error: Any) → bool[ソース]
print_error_info(error: Any) → bool[ソース]
wait_motion_start_or_error(command_name: str, *, timeout: float = 0.25, interval: float = 0.01) → bool[ソース]

非同期命令受付直後にアラームへ遷移した場合はFalseを返す。

dobot.dobot_tcp module

Dobot MG400 TCP/IP制御バックエンド。

Dashboard、Motion、Feedbackの3ソケットを管理し、MG400の基本制御、 状態取得、エラー取得、移動命令を一つのクラスにまとめる。

30004番ポートのリアルタイムステータスを別スレッドで受信し、最新フレームを スレッドセーフに保持する。移動の同期/非同期は共通I/Fの意味に合わせ、DOBOT公式APIのSYNCパラメータを使う。 非同期移動を明示的に待つ場合はDOBOT公式APIのSync()を使う。

class dobot.dobot_tcp.DobotTcp(dobot_ip: str = '192.168.1.6', instance_name: str = 'Ctrl', logger: Any | None = None, log_level: str | None = None, auto_connect: bool = True)[ソース]

ベースクラス: object

Dobot MG400のTCP/IP通信を管理する。

Dashboard API、Motion API、Feedback APIへの接続を保持し、 ロボットの制御と状態取得を提供する。

パラメータ:
  • dobot_ip (str) -- MG400のIPアドレス。

  • instance_name (str) -- インスタンス識別名。

  • logger (Optional[Any]) -- 呼び出し側から渡されるロガー。 Noneの場合の処理は既存実装に従う。

  • log_level (Optional[str]) -- loggerがNoneの場合に使用するログレベル。

  • auto_connect (bool) -- Trueの場合、初期化時に接続する。

DASHBOARD_PORT = 29999
FEEDBACK_MAGIC = 81985529216486895
FEEDBACK_PORT = 30004
FEEDBACK_SIZE = 1440
MOVE_PORT = 30003
property accel
approach(lComp, vntPoseBase, vntPoseLen, bstrOpt=None)[ソース]

基準P座標へオフセットを加えて移動する。

autocal(origin: bool = False) → bool[ソース]

自動キャリブレーションを実行する。MG400で対応処理を確認できないため未対応。

property busy_status

MG400が現在動作中かを真偽値で返す。

Feedbackの RunningStatus と JogStatus を参照し、 キュー動作中またはJOG中であればTrueを返す。

change_tool(work_no: int) → bool[ソース]
change_work(work_no: int) → bool[ソース]
check_error() → bool[ソース]

現在エラーがなければTrueを返す。

clear_log()[ソース]
clear_servo_log()[ソース]
connect() → bool[ソース]

MG400の3つのTCP/IPポートへ接続する。

Dashboard、Motion、Feedbackの順にソケットを生成し、接続成功後に Feedback受信スレッドを開始する。

戻り値:

すべての接続と受信スレッド開始に成功した場合はTrue。

接続処理で例外が発生した場合はFalse。

戻り値の型:

bool

property coord_type
property current_angle
property current_position
property decel
delete() → bool[ソース]
dev(base, offset)[ソース]

MG400で実現可能な範囲のDev(P姿勢変位)を計算する。

MG400はP=[x,y,z,rx,ry,rz]のうちrx/ryを実現できない。 したがってbase/offset双方のrx/ryが0の場合だけ、 x,y,z,rzの変位を合成する。

rx/ryを黙って捨てることはしない。

property direct_mode
disconnect() → bool[ソース]

MG400とのTCP/IP接続を閉じる。

Feedback受信スレッドへ停止を通知した後、Feedback、Motion、 Dashboardの各ソケットを閉じる。

戻り値:

切断処理を実行した場合はTrue。

戻り値の型:

bool

drive(target, *, relative=False, path_blend=None, speed=None, is_async=False)[ソース]

軸番号と値によるDrive共通I/F。

property error_code
property error_description
property extaccel
property extdecel
property extspeed
get_IO(id_num: int)[ソース]

共通 IO* の出力readbackを返す。

set_IO() がDOを書き込むため、同じI/Fの get_IO() もDO状態を 読む。入力は get_digital_input() で明示的に取得する。

get_accel()[ソース]
get_coord_type() → str[ソース]
get_current_angle()[ソース]

現在関節値を6成分として同期取得して返す。

MG400のDashboard API GetAngle() を直接使用する。MG400は4軸 なのでJ5/J6は0.0として公開する。

get_current_error_info()[ソース]
get_current_pose()[ソース]

get_current_position() の互換別名。

get_current_position()[ソース]

現在TCP位置を6成分座標として同期取得して返す。

MG400のDashboard API GetPose() を直接使用する。4軸MG400の [x, y, z, r] は公開I/Fで [x, y, z, 0.0, 0.0, rz] として返す。

get_current_tool()[ソース]
get_current_tool_no()[ソース]

現在のツール座標系番号を取得する。

戻り値:

フィードバックで取得したツール座標系番号。

未受信時は最後に設定した番号。

戻り値の型:

int

get_current_work_no()[ソース]

現在のユーザー座標系番号を取得する。

戻り値:

フィードバックで取得したユーザー座標系番号。

未受信時は最後に設定した番号。

戻り値の型:

int

get_decel()[ソース]
get_digital_input(index)[ソース]

DOBOT固有: 指定DIの状態を取得する。

ベンダーDashboard APIの DI(index) を使用する。 共通Ctrl I/Fには公開しない。

get_direct_mode()[ソース]

ダイレクトモード状態を取得する。MG400では未対応。

get_error()[ソース]

現在発生しているDobotエラーIDを取得する。

get_error_code()[ソース]

現在の先頭エラーコードを取得する。

get_error_count()[ソース]
get_error_description(error_code: int) → str[ソース]
get_error_info(index: int)[ソース]
get_extaccel()[ソース]
get_extdecel()[ソース]
get_extspeed()[ソース]

MG400 Feedbackのglobal velocity ratio[%]を返す。

get_jspeed()[ソース]
get_log_count()[ソース]
get_log_record(index)[ソース]
get_motion_complete()[ソース]

現在ロボットがモーション実行中でないかを返す。

モーション実行状態の判定には、DOBOTのリアルタイムステータス RunningStatus を使う。

get_motion_mode()[ソース]
get_motion_preparation()[ソース]

モーション準備状態を取得する。MG400では未対応。

get_path_blend()[ソース]
get_robot_mode()[ソース]

DOBOT固有: Dashboard RobotMode() のモード番号を返す。

get_speed()[ソース]

最後に共通I/Fから設定した内部移動速度[%]を返す。

MG400 TCP/IPには SpeedL のreadback APIがないため、 DobotTcpが最後に設定した値を保持して返す。実速度計測値ではない。

get_task_status()[ソース]

現在のタスク状態値を取得する。MG400では未対応。

get_tool(tool_no: int)[ソース]

get_tool_define()の互換別名。

get_tool_define(tool_no: int)[ソース]

指定Tool座標系定義を6成分座標で返す。

MG400には任意番号を直接readするGetToolDef相当がないため、現在Toolを 保存して一時選択し、Feedback tool を取得後に元へ戻す。

get_version(rel_toml_path=None)[ソース]

コントローラのバージョン情報を取得する。MG400では未対応。

get_work(work_no=None)[ソース]

ユーザー座標系定義を取得する。

MG400のUser座標系定義を、30004番ポートのリアルタイムステータス user から取得する。

work_no がNoneの場合は現在選択中のUser座標系をそのまま返す。 番号を指定した場合、MG400の現在のPython APIには任意番号の User座標系定義だけを直接取得する命令がないため、一時的に User(work_no)で選択して user を取得し、その後で元のUserへ戻す。

パラメータ:

work_no (int or None) -- 取得するWork/User座標系番号。 Noneの場合は現在選択中の座標系。

戻り値:

[x, y, z, rx, ry, rz] の6成分座標系定義。

リアルタイムステータスを取得できない場合はNone。

戻り値の型:

list

give_arm() → bool[ソース]

アーム制御権解放I/Fを処理する。

MG400のTCP/IP APIには独立した制御権解放操作がないため、 ロボットへコマンドは送信せず成功として扱う。 DisableRobot()とは役割が異なるため、ここでは呼び出さない。

halt() → bool[ソース]

即時停止を行う。

現在利用しているMG400 APIでは、このI/Fに必要な停止動作と同義であることを 確認できるコマンドがないため未対応とする。ResetRobot()は代用しない。

例外:

NotImplementedError -- 対応するMG400実装がない。

hand(pos=None, *, position=None, force=None, direction=True, relative=False, speed=None, is_async=False)[ソース]
hand_open(speed=None)[ソース]

ハンドを開放する。MG400標準APIでは未対応。

hand_stop() → bool[ソース]
init_hand()[ソース]

ハンドを初期化する。MG400標準APIでは未対応。

is_connected()[ソース]

3本のDOBOT TCP接続が存在するかを返す。

is_running()[ソース]
j2p(j_type_pos)[ソース]

J6をMG400順運動学へ渡し、P6で返す。

jog(axis, direction, speed, step=None)[ソース]

共通JOG I/FをMG400へ変換する。

パラメータ:
  • axis (int) -- 関節番号。MG400では1..4。

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

  • speed (float) -- DOBOTの速度倍率[%]。1..100。

  • step (Optional[float]) -- Noneなら連続JOG。値を指定した場合は その絶対値[deg]だけ指定関節を相対移動する。

戻り値:

コマンド受付または有限ステップ移動に成功した場合True。

戻り値の型:

bool

メモ

連続JOGにはDOBOT公式TCP/IP APIの MoveJog を使用する。 MoveJog("J1+") 等で開始し、MoveJog() で停止する。 MoveJogには個別速度引数がないため、speedはグローバル速度倍率 SpeedFactor に写像する。

jog_stop()[ソース]

連続JOGを停止する。

DOBOT公式TCP/IP APIでは引数なしの MoveJog() がJOG停止命令。

property jspeed
property lock

ロック状態を取得する。MG400では対応状態を確認できないため未対応。

motion_complete()[ソース]

get_motion_complete() の別名。

property motion_mode
motor_off() → bool[ソース]

駆動を無効にする。MG400ではDisableRobot()に対応する。

motor_on() → bool[ソース]

駆動を有効にする。MG400ではEnableRobot()に対応する。

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

公開move I/FをMG400の移動コマンドへ変換する。

公開座標:

P = [x, y, z, rx, ry, rz] J = [j1, j2, j3, j4, j5, j6]

MG400内部:

P = [x, y, z, r] (r <- rz) J = [j1, j2, j3, j4]

同期契約:
is_async=True:

TCP/IPのMovJ/MovL/JointMovJを送信し、受付応答後に戻る。

is_async=False:

TCP/IPのMovJ/MovL/JointMovJを送信した後、Sync()を送信して 投入済みモーションの実行完了まで待ってから戻る。

DobotStudio ProスクリプトのMovJ/MovLにあるSYNCオプションは、 TCP/IP 30003ポートのMovJ/MovLオプションではないため送信しない。

open_hand(speed=None)[ソース]

ハンドを開く。MG400標準APIでは未対応。

p2j(p_type_pos)[ソース]

P6をMG400逆運動学へ渡し、J6で返す。

property path_blend
print_error(e) → bool[ソース]
print_error_info(e) → bool[ソース]
reconnect()[ソース]

既存接続を切断して3ポートへ再接続する。

release_arm() → bool[ソース]

give_arm()の別名。

reset_error() → bool[ソース]

現在発生しているアラームをクリアする。

rotate(plane, angle, center, *, path_blend=None, speed=None, is_async=True)[ソース]
run_project(project_name)[ソース]

DOBOT 固有: 指定プロジェクトを RunScript で実行する。

run_script()[ソース]

共通 I/F のスクリプト実行。

公開I/Fの run_script() は引数なしだが、MG400の RunScript(projectName) はプロジェクト名を必要とするため、 このメソッドでは別の意味を割り当てず未対応とする。

property servo_on

MG400の駆動Enable状態を返す。

Feedbackの EnableStatus を使用し、EnableRobot() / DisableRobot() による現在のEnable状態を取得する。 RobotMode や busy_status とは別の状態である。

set_IO(id_num: int, value: float) → bool[ソース]
set_accel(accel: float) → bool[ソース]
set_coord_type(coord_type: str) → bool[ソース]
set_decel(decel)[ソース]

独立した減速度設定。

現在使用しているMG400 APIには独立した減速度指定を確認できないため、 Accへ読み替えず未対応とする。

set_extaccel(accel)[ソース]
set_extdecel(decel)[ソース]
set_extspeed(speed)[ソース]

MG400のグローバル速度倍率を設定する。

Dashboard APIの SpeedFactor を使用する。

set_jspeed(speed: int) → bool[ソース]
set_motion_mode(mode) → bool[ソース]
set_path_blend(path_blend)[ソース]

パス遷移条件を設定する。

現在の path_blend の値をDOBOTのCP値へ安全に変換する規則を 定義していないため、Noneだけを「指定なし」として受理する。

set_speed(speed)[ソース]

MG400の直線移動速度率を設定する。

Dashboard APIの SpeedL を使用する。 グローバル速度倍率は SpeedFactor を使用する別I/Fで管理する。

set_tool(tool_no, tool_define) → bool[ソース]

set_tool_define()の互換別名。

set_tool_define(tool_no, tool_define) → bool[ソース]

MG400 SetTool(index,{x,y,z,r}) でTool座標系を定義する。

set_work(work_no, work_define, work_attribute=0) → bool[ソース]

ユーザー座標系を定義する。

MG400のUser座標系を SetUser(index,{x,y,z,r}) で定義する。

work_define は [x, y, z, rx, ry, rz] として受け取り、MG400の4軸座標系 [x, y, z, r] へ変換する。MG400のrにはrzを対応させる。 rx/ryが0でない座標系はMG400では表現できないため拒否する。

work_attribute は公開I/Fとの互換性のため受け取るが、 MG400の座標系定義には使用しない。

注意:

MG400マニュアル上、SetUserによる変更は現在の プロジェクト実行中のみ有効で、プロジェクト停止後は 変更前の値へ戻る。

パラメータ:
  • work_no (int) -- Work/User座標系番号。0..9。

  • work_define (list or tuple) -- [x,y,z,rx,ry,rz]。

  • work_attribute -- 互換引数。現在は未使用。

戻り値:

SetUserが成功した場合True。

戻り値の型:

bool

property speed
start_log()[ソース]
start_servo_log()[ソース]
state()[ソース]

現在の実行状態を返す。

MG400 Feedbackの RunningStatus を返す。

busy_status はJOGも含む「ロボットが動作中」の判定であり、 state() とは意図的に分ける。DOBOT固有のRobotMode番号が必要な場合は get_robot_mode() を使用する。

stop()[ソース]

ロボットの停止処理を行う。

このI/Fが要求する停止シーケンスをMG400で同じ意味のまま保証できないため 未対応とする。halt() の単純な別名にはしない。

stop_log()[ソース]
stop_script()[ソース]

DOBOT固有: 実行中のスクリプトを停止する。

ベンダーDashboard APIの StopScript() をそのまま使用する。 共通Ctrl I/Fには公開しない。

stop_servo_log()[ソース]
take_arm() → bool[ソース]

アーム制御権取得I/Fを処理する。

MG400のTCP/IP APIには独立した制御権取得操作がないため、 ロボットへコマンドは送信せず成功として扱う。 EnableRobot()とは役割が異なるため、ここでは呼び出さない。

property task

実行タスクを取得する。MG400では対応するタスクハンドルがないため未対応。

property task_state

タスク状態を取得する。MG400では対応する状態ハンドルがないため未対応。

task_stop() → bool[ソース]

タスク実行を停止する。

MG400の StopScript() とこのI/Fのタスク停止が同義であることを 確認できないため未対応とする。MG400固有のスクリプト停止は stop_script() として分離する。

turn_off_motor() → bool[ソース]

旧I/F互換。motor_off()へ委譲する。

turn_on_motor() → bool[ソース]

旧I/F互換。motor_on()へ委譲する。

wait_for_complete(timeout=None, interval=0.02) → bool[ソース]

キューに入っているモーションがすべて完了するまで待つ。

MG400のSync()を使用する。Sync()は、先行してキューへ登録された モーションの実行がすべて完了してから応答する。

timeout と interval は共通I/Fのシグネチャを維持するため受け取るが、 MG400のSync()自体には対応する引数がないため使用しない。

戻り値:

Sync()が正常終了した場合True。

戻り値の型:

bool

dobot.robot_var_manager module

COBOTTA互換I/Fで使用するロボット非依存変数ストア。

P/J/I/F/IO変数の値管理とJSON保存だけを担当する。 実ロボット制御やTCP通信は行わない。

class dobot.robot_var_manager.RobotVarManager(robot_instance=None, filename=None, logger=None, autosave=True, autoload=True)[ソース]

ベースクラス: object

P/J/I/F/IO変数を管理する。

get_all_var()[ソース]
get_var(kind_or_name, id_num=None, default=False)[ソース]
has_var(kind_or_name, id_num=None)[ソース]
load(filename=None)[ソース]
classmethod make_name(kind_or_name, id_num=None)[ソース]
save(filename=None)[ソース]
set_var(kind_or_name, id_or_value, value=None, save=None)[ソース]
classmethod split_name(kind_or_name, id_num=None)[ソース]

("P", 10) と "P10" を ("P", 10) に正規化する。

dobot.server module

Dobot FastAPI 関連の公開入口。

class dobot.server.AsyncDobotClient(*args: Any, **kwargs: Any)[ソース]

ベースクラス: AsyncDeviceClient

Dobot FastAPI サーバーへ接続する非同期クライアント。

class dobot.server.SyncDobotClient(*args: Any, **kwargs: Any)[ソース]

ベースクラス: SyncDeviceClient

Dobot FastAPI サーバーへ接続する同期クライアント。