Working with the common control interface
Local status inspection
from dobot.dobot_ctrl import DobotCtrl
robot = DobotCtrl(dobot_ip="192.168.1.6", auto_connect=True)
try:
print(robot.state())
print(robot.get_current_position())
print(robot.get_current_angle())
finally:
robot.disconnect()
This example reads status without requesting motion. auto_connect=True connects during initialization. Refer to the generated API documentation and implementation for return-value details.
Motor control versus arm ownership
robot.take_arm()
robot.turn_on_motor()
# Execute operations only after the required safety checks.
robot.turn_off_motor()
robot.give_arm()
For MG400, take_arm() and give_arm() are currently no-ops because equivalent vendor ownership commands have not been established. Motor on/off maps to the MG400 enable/disable functions. This illustrates the interface, not a complete safe operating procedure.
Expose the same interface through FastAPI
python -m dobot.server_fastapi.server
server_fastapi/server.py instantiates FastApiServer(device_cls=DobotCtrl, router_cls=None, api_spec=None, object_name="dobot", ...). The ese774_frame automatic dispatcher exposes the controller without redefining the device interface in a second router.
from dobot.config import Config
from dobot.server_fastapi.client_sync import SyncDobotClient
client = SyncDobotClient(config=Config())
print(client.state())
print(client.get_current_position())
Default server address: 127.0.0.1:8000; default MG400 address: 192.168.1.6. Config.load_yaml() updates class settings, whereas Config(yaml_path=...) updates an instance. Verify how the server reads settings before choosing either mechanism.
For async use, see dobot.server_fastapi.client_async.AsyncDobotClient. Asynchronous HTTP execution does not imply waiting for physical motion completion. Review move() and wait_for_complete() behavior before commanding motion.