Operational workflow: from local control to HTTP clients
This page is grounded in the supplied DobotCtrl, DobotTcp, server_fastapi, Config, and ese774_frame sources. Run motion commands only after validating the physical safety procedure.
1. Before connecting
Confirm the MG400 IP address (
192.168.1.6is the configured default).Check connectivity to Dashboard (29999), Motion (30003), and Feedback (30004).
Verify servo state, work envelope, and emergency-stop procedure.
Start with read-only state queries.
2. Local control
from dobot.dobot_ctrl import DobotCtrl
robot = DobotCtrl(dobot_ip="192.168.1.6", auto_connect=False)
try:
if not robot.connect():
raise RuntimeError("MG400 connection failed")
print(robot.get_current_pose())
print(robot.get_current_angle())
finally:
robot.disconnect()
With auto_connect=False, explicitly call connect(). DobotCtrl delegates operations to DobotTcp.
3. FastAPI server
The server entry point is src/dobot/server_fastapi/server.py:
python -m dobot.server_fastapi.server
It uses FastApiServer(device_cls=DobotCtrl, router_cls=None, api_spec=None, object_name="dobot", ...): automatic dispatch through ese774_frame, without a mandatory device-specific router or Pydantic request model.
Defaults: Config.SERVER_IP="127.0.0.1", SERVER_PORT=8000, DOBOT_IP="192.168.1.6". Access from other hosts requires an appropriate bind address and network configuration.
Note: src/dobot/server.py exports public clients; it is not the server launch module.
4. Synchronous client
from dobot.server_fastapi import SyncDobotClient
client = SyncDobotClient(server_ip="127.0.0.1", server_port=8000)
print(client.get_current_pose())
print(client.get_current_angle())
A synchronous HTTP client waits for the HTTP call, not necessarily for robot motion. Motion completion is separately controlled by move(..., is_async=...).
5. Asynchronous client
AsyncDobotClient subclasses ese774_frame.clients.async_device_client.AsyncDeviceClient. Follow its actual method and cleanup contract; no unverified event-loop example is introduced here.
6. Motion completion semantics
DobotTcp.move() accepts target, motion_mode, coord_type, path_blend, offset, pose, speed, accel, decel, and is_async. With is_async=True, it returns after command acceptance. With is_async=False, it sends Sync() to wait for queued motion completion. A supplied pose is not implemented and returns False in the current backend.
7. Configuration
Config.load_yaml(path) changes class attributes; Config(yaml_path=path) changes instance attributes. Choose the appropriate form for how the server receives its configuration.