Skip to content

Conversation

Copy link

Copilot AI commented Jul 1, 2025

This PR implements a flexible DIYRobot factory class that allows engineers with custom robotic platforms to integrate into the armctl ecosystem using a pick-and-choose communication system.

Key Features

Factory Pattern Implementation

The DIYRobot class follows the factory pattern specified in the issue:

from armctl import DIYRobot
from armctl.templates import SocketController

# Create blank factory class
Robot = DIYRobot()

# Configure with any communication method using __call__
Robot(SocketController, "192.168.1.100", 8080)

# Access only basic communication methods
Robot.connect()
response = Robot.send_command("CUSTOM_COMMAND")
Robot.disconnect()

Minimal Interface

The DIYRobot provides only the essential communication methods without any template commands:

  • connect() - Connect to the robot
  • disconnect() - Disconnect from the robot
  • send_command() - Send custom commands for any protocol

This allows engineers complete flexibility to implement their own custom robotic protocols without assumptions about movement commands or robot capabilities.

Flexible Communication Support

Works with any Communication subclass in the armctl ecosystem:

  • SocketController for TCP/IP communication
  • SerialController for serial communication
  • PLCController for PLC communication
  • Any custom communication class

Error Handling & Validation

  • Validates that communication classes inherit from Communication
  • Ensures robot is configured before attempting operations
  • Provides clear error messages for common mistakes

Context Manager Support

robot = DIYRobot()
robot(SocketController, "10.0.0.1", 8080)

with robot:
    response = robot.send_command("STATUS")

Implementation Details

  • File: armctl/diy_robot.py - Contains the complete DIYRobot implementation
  • Integration: Updated armctl/__init__.py to export DIYRobot
  • Documentation: Added usage examples to README.md
  • Zero Breaking Changes: Fully backwards compatible with existing code

Usage Examples

Basic Custom Robot

from armctl import DIYRobot
from armctl.templates import SocketController

robot = DIYRobot()
robot(SocketController, "192.168.1.100", 8080)
robot.connect()
robot.send_command("INIT_SYSTEM")
robot.send_command("MOVE_TO:X100,Y200,Z50")
robot.disconnect()

Multiple Custom Robots

# Manage multiple custom platforms
arm_robot = DIYRobot()
arm_robot(SocketController, "10.0.0.1", 8080)

gripper_robot = DIYRobot() 
gripper_robot(SerialController, "/dev/ttyUSB0", 115200)

This implementation enables robot enthusiasts and engineers to integrate their custom robotic platforms into the armctl library ecosystem without requiring specific robot model support, exactly as requested in the issue.

Fixes #7.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI changed the title [WIP] DIY Robot Factory Class Implement DIY Robot Factory Class for Custom Robotic Platforms Jul 1, 2025
Copilot AI requested a review from MGross21 July 1, 2025 21:23
Copilot finished work on behalf of MGross21 July 1, 2025 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DIY Robot Factory Class

2 participants