HALCON provides numerous methods to determine the 3D pose of a part. Telling a robot where the part is located in 3D space by no means guarantees it can be picked successfully, however, to determine whether a part can be picked successfully, we must also make sure nothing is in the way as the robot approaches the part. Furthermore, we must make sure the part can be gripped, which can be particularly challenging within a bin.
HALCON provides an operator that calculates the distance between 3D object models for each point or surface element. By that means we can determine if two 3D objects, such as the gripper and another part, come too close to one another.
The following example shows how to apply the operator, distance_object_model_3d, to determine if parts violate a user-defined ‘safe-zone’. To run the program, you can copy+paste the example into HDevelop.
dev_close_window()
dev_open_window(0, 0, 512, 512, ‘black’, WindowHandle)
set_display_font(WindowHandle, 24, ‘mono’, ‘true’, ‘false’)
read_object_model_3d (‘pipe_joint’, ‘m’, [], [], PipeJointOM3DID, Status)
sample_object_model_3d(PipeJointOM3DID, ‘fast’, 0.002, [], [], SampledObjectModel3D)
pose_to_hom_mat3d([1e-2,1e-2,1e-2,45,45,45,0], HomMat3D)
affine_trans_object_model_3d(SampledObjectModel3D, HomMat3D, ObjectModel3DAffineTrans)
distance_object_model_3d(ObjectModel3DAffineTrans, SampledObjectModel3D, [], 0, [], [])
SafeDistance := 0.01
select_points_object_model_3d(ObjectModel3DAffineTrans, ‘&distance’, 0, SafeDistance,
ObjectModel3DThresholded)
get_object_model_3d_params(ObjectModel3DThresholded, ‘num_points’, NumPoints)
if (NumPoints > 0)
visualize_object_model_3d(WindowHandle, [ObjectModel3DThresholded,
SampledObjectModel3D,ObjectModel3DAffineTrans], [], [], ‘colored’, 12,
‘COLLISION !!’, [], [], PoseOut)
else
visualize_object_model_3d(WindowHandle, [SampledObjectModel3D,ObjectModel3DAffineTrans]
, [], [], [‘color_0′,’color_1’], [‘green’,’blue’], ‘SAFE!’, [], [], PoseOut)
endif
You can apply this concept to other applications as well, such as performing critical measurements in 3D.