Online mode
Caution
Online
modules are only available with the RESEARCH license.
This chapter covers how to use the Online module to access data in the current IndyEye graph.
If you use IndyEye with the RESEARCH license, you can use the Online
module.
This Online
module is a module that allows you to receive the results of the graph execution up to the added Online
module.
You can directly get the data of the Online
module (data in the graph of IndyEye) by using the IndyEye
class of the neuromeka
package.
Online Module Example
Get the value of the Online module added to the graph
First, add the Online module to the graph using the IndyEye app.
After that, in an external python file, use eye.get(GraphFlow)
of the IndyEye
class to get the Index value of the Online module in the graph,
and then use eye.get_pkl()
and the corresponding Index value to get the graph execution result 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 module result key
The following list shows the general key values that can be included in the Online module's result dictionary. The result of the Online module can contain different values depending on the types of other modules before the Online module.
effector_coord_base
: Robot end effector position (Task position)plane_coord_cam
:cam_coord_base
:workspace_dims
: Dimension of workspacecamera_matrix
: Camera Intrinsic properties (array(3x3 float)
)array([[910.21795654, 0, 640.10125732], [0, 909.50714111, 386.84814453], [0, 0, 1]])
resolution
: resolution (tuple(int, int)
, (width, height))(1280, 720)
minz_dict
:id_end
: ID value of the module immediately preceding the Online module (int
)retrieve
:image
: Current image (uint8
, BGR image)mask
: Mask image of the currently recognized object (uint8
, BGR image)name
: Name of the currently recognized object (string
)text
: Result text of the OCR or ScanCode module (string
)code_type
: Currently detected code type, from ScanCode module (string
, e.g. 'CODE128')grip_pose_base
: Name of recognized object (Task position)task_pose_base
: Robot end effector position (Task position)tool_idx
: Currently selected tool index, TOOL standard (int
) set within the Gripper modulevector_approach
: Name of recognized object (string
)