Skip to content

온라인 모드

Caution

Online 모듈은 RESEARCH 라이센스에서만 사용이 가능합니다.

이 챕터에서는 Online 모듈을 사용하여 현재 IndyEye 그래프의 데이터에 접근하는 방법을 다룹니다.

RESEARCH 라이센스의 IndyEye를 사용하는 경우, Online 모듈을 사용할 수 있습니다.

Online 모듈은 해당 모듈 직전까지 그래프를 실행시킨 뒤 실행 결과 값을 외부에서 받아올 수 있게하는 모듈이며, neuromeka 패키지의 IndyEye 클래스를 사용하여 Online 모듈의 데이터 (IndyEye의 그래프 내 데이터)를 바로 가져오는것이 가능합니다.

Online 모듈 예시

그래프에 추가되어있는 Online 모듈의 값 가져오기


Online 모듈

우선 IndyEye 앱을 사용하여 그래프에 Online 모듈을 추가 합니다.

이후 외부 python 파일에서 IndyEye 클래스의 eye.get(GraphFlow)를 사용하여 그래프 내 Online 모듈의 Index 값을 가져온 뒤, eye.get_pkl()과 해당 Index 값을 사용하여 그래프 실행결과 dictionary 를 받아올 수 있습니다.

from neuromeka import IndyDCP3
from neuromeka import IndyEye
from neuromeka.eye import *

robot_ip = "192.168.0.144"
eye_ip = "192.168.0.114"

indy = IndyDCP3(robot_ip)
eye = IndyEye(eye_ip)

#Connect robot
if eye.get(RobotStatus)['data']['stateCode'] != 0:
    resp = eye.post(RobotDisconnect, name="IndyDCP3", ip=robot_ip)
    time.sleep(0.5)
resp = eye.post(RobotConnect, name="IndyDCP3", ip=robot_ip)
con_state = eye.get(RobotStatus)['data']

if con_state['stateCode'] == 1: #Robot connected
    online_module_key = ""

    #Find Online module's index value
    graph_flow = eye.get(GraphFlow)['data']['graph']

    for key in graph_flow.keys():
        if graph_flow[key]["name"] == "Online":
            online_module_key = key
            break

    #Get result dictionary from the Online module
    if len(online_module_key) > 0:
        graph_result = eye.get_pkl(f"/detect/module/online/{online_module_key}/pickle", return_values="all")
        print(graph_result)
    else:
        print("Online module not found")
else:
    print("Robot not connected")

# Result
dict_keys(['effector_coord_base', 'plane_coord_cam', 'cam_coord_base', 'workspace_dims', 'camera_matrix', 'resolution', 'minz_dict', 'id_end', 'retrieve', 'image'])
{'effector_coord_base': array([[ 1.0000000e+00,  1.2246469e-16,  1.2246469e-16,  6.1511879e-10],
       [-1.2246469e-16,  1.0000000e+00, -1.2246469e-16, -1.8650000e-01],
       [-1.2246469e-16,  1.2246469e-16,  1.0000000e+00,  1.3279999e+00],
       [ 0.0000000e+00,  0.0000000e+00,  0.0000000e+00,  1.0000000e+00]],
      dtype=float32), 'plane_coord_cam': array([[-0.0253914 ,  0.9982995 ,  0.05247305,  0.07476724],
       [ 0.40781167,  0.05826779, -0.9112049 ,  0.07082713],
       [-0.9127129 , -0.00173767, -0.40859762,  1.1162121 ],
       [ 0.        ,  0.        ,  0.        ,  1.        ]],
      dtype=float32), 'cam_coord_base': array([[-0.02539146, -0.4078117 ,  0.912713  ,  0.9917956 ],
       [ 0.9982995 , -0.0582677 ,  0.00173765, -0.07682745],
       [ 0.05247313,  0.91120505,  0.40859777,  0.5166966 ],
       [ 0.        ,  0.        ,  0.        ,  1.        ]],
      dtype=float32), 'workspace_dims': array([0.24, 0.16, 0.1 ]),
      'camera_matrix': array([[910.21795654,   0.        , 640.10125732],
       [  0.        , 909.50714111, 386.84814453],
       [  0.        ,   0.        ,   1.        ]]), 'resolution': (1280, 720), 'minz_dict': {}, 'id_end': 108503726946600032536757885788871217695, 'retrieve': False,
       'image': array([[[0, 0, 0],
        [0, 0, 0],
        [0, 0, 0],
        ...,
        [0, 0, 0],
        [0, 0, 0],
        [0, 0, 0]],
...
        ...,
        [0, 0, 0],
        [0, 0, 0],
        [0, 0, 0]]], dtype=uint8)}

Online 모듈 결과값 키

Online 모듈을 통해 가져온 dictionary가 포함할 수 있는 주요 값들은 아래와 같습니다. Online 모듈 앞의 다른 모듈들의 종류에 따라 다른 값들을 포함하게 됩니다.

  • effector_coord_base : 로봇 엔드 이펙터 위치 (Task pos)
  • plane_coord_cam :
  • cam_coord_base :
  • workspace_dims : Workspace의 dimension
  • camera_matrix : 카메라 Intrinsic properties (array(3x3 float))
    • array([[910.21795654, 0, 640.10125732], [0, 909.50714111, 386.84814453], [0, 0, 1]])
  • resolution : 해상도 (tuple(int, int), (width, height))
    • (1280, 720)
  • minz_dict :
  • id_end : Online 모듈 바로 직전의 모듈의 ID값 (int)
  • retrieve :
  • image : 현재 이미지 (uint8, BGR image)
  • mask : 현재 인식된 대상의 마스크 이미지 (uint8, BGR image)
  • name : 현재 인식된 대상의 이름 (string)
  • grip_pose_base : 인식된 물체의 이름 (Task pos)
  • text: OCR 또는 ScanCode 모듈의 결과 텍스트값 (string)
  • code_type: 현재 인식된 코드 종류 (string, e.g. 'CODE128')
  • task_pose_base : 로봇 엔드 이펙터 위치 (Task pos)
  • tool_idx : 현재 선택된 툴 인덱스, Gripper 모듈 내에서 설정된 TOOL 기준 (int)
  • vector_approach : 인식된 물체의 이름 (string)