class PickAndPlaceLogic(fb.FunctionBlock):
"""Логика захвата детали с видением"""
def on_part_detected_event(self, detection_result):
# Видение обнаружило деталь с координатами
part_coords = detection_result.coordinates
part_orientation = detection_result.rotation
# Отправляем команду роботу через OPC UA
self.robot_client.move_to_and_grasp(
position=part_coords,
orientation=part_orientation,
force=5 # ньютоны
)
# Публикуем событие для следующего блока
self.output("part_grasped")
class QualityInspectionLogic(fb.FunctionBlock):
"""Контроль качества после обработки"""
def on_processing_complete(self, result_image):
# ML-модель проверяет качество
quality_score = self.quality_model.predict(result_image)
if quality_score > self.threshold:
self.output("part_ok")
else:
self.output("part_defect")
self.publish_metrics({
"defect_type": self.classifier.classify(result_image),
"timestamp": time.time()
})
┌─────────────────┐
│ UR коbot │ PolyScope программирование
│ PolyScope 5 │ (по 30 мин на переналадку)
└─────────────────┘
↑↓
┌─────────────────┐
│ Siemens S7 │ TIA Portal программирование
│ S7-1200 │ (по 20 мин)
└─────────────────┘
↑↓
┌─────────────────┐
│ Видение (Linux) │ Python код переделать
│ Basler camera │ (по 20 мин + тестирование)
└─────────────────┘
↑↓
OPC UA binding
(20 мин отладки)
ИТОГО ПЕРЕНАЛАДКА: ~90 мин ┌─────────────────────────────────┐
│ O-PAS │
│ (единый проект 61499) │
│ │
│ • Robot блок (OPC UA) │
│ • Vision блок (Python + ML) │
│ • Logic блок (IEC 61499) │
│ • Quality блок (ML inference) │
└─────────────────────────────────┘
↓ YAML конфиг ↓
Product_A.yaml → новые параметры
Product_B.yaml → новые параметры
ИТОГО ПЕРЕНАЛАДКА: ~3–5 мин ┌──────────────────────────────────────────────────────┐
│ OpenFB Runtime (Orchestration) │
│ Python + IEC 61499 (работает на Linux/Raspberry Pi) │
│ │
│ ┌────────────────┐ ┌──────────────┐ ┌──────────┐ │
│ │ Robot │ │ Vision Block │ │ Quality │ │
│ │ Management │ │ (TensorFlow) │ │ Block │ │
│ │ Block │ │ │ │ (ML) │ │
│ │ (OPC UA) │ │ (GPU узел) │ │ │ │
│ └────────────────┘ └──────────────┘ └──────────┘ │
│ │ │ │ │
│ EVENTS+DATA MQTT PUB OPC UA │
└──────────────────────────────────────────────────────┘
│ │ │
↓ ↓ ↓
┌─────────┐ ┌──────────┐ ┌────────────┐
│UR Cobot │ │Raspberry │ │ Database/ │
│ │ │ Pi 5 GPU │ │ Analytics │
│Polyscope│ │ │ │ │
└─────────┘ └──────────┘ └────────────┘ class VisionDetectionBlock(fb.FunctionBlock):
def __init__(self, config):
self.model = load_model(config['model_path'])
self.threshold = config['quality_threshold']
self.mqtt_client = mqtt.Client()
def process_image(self, image_bytes):
image = cv2.imdecode(image_bytes, cv2.IMREAD_COLOR)
detections = self.model.predict(image)
for detection in detections:
if detection.confidence > self.threshold:
self.mqtt_publish("detection_found", {
'position': detection.bbox,
'confidence': detection.confidence
}) vision:
model_path: models/pcba_detector_v2.onnx
quality_threshold: 0.95
robot:
speed: 0.8
force: 5.0 vision:
model_path: models/pcba_detector_v3.onnx
quality_threshold: 0.98
robot:
speed: 0.5 # медленнее для сложных деталей
force: 3.0 # мягче захват Siemens S7-1200 ←→ OpenFB Runtime ←→ Новая кобот-линия
(старые конвейеры) (через OPC UA) (Product A/B переналадки)