Classification
Warning
The AI Accelerator requires ROS 2 Humble, so PolyScope X 10.12.1 is the latest compatible release. PolyScope X 10.13 and later use ROS 2 Jazzy and are not currently supported.
Load a classification model, set an image ROI, and run inference. Requires ark_init() (see General).
Typical call order: ark_init() → ark_load_classification_model → ark_set_classification_params → ark_infer_classification.
ark_load_classification_model(model)
ark_load_classification_model(model)
Loads a classification model on the AI Accelerator.
Arguments
model(string): Model filename or path relative to/workspaces/isaac_ros-dev/data/models/(that prefix is prepended automatically)
Returns
ArkError— typicallyArkError(False)(the preamble does not inspect the service response for errors)
Errors / failure modes
Requires
ark_init()(uses/load_modelclient)Missing or invalid model may still return
ArkError(False); verify by checking inference results
ROS
Service:
ARK_ROS2Namespace + "/load_model"Type:
ur_ark_ros_common_msgs/srv/LoadModelLoad request includes
min_confidence=1.0and default ROIstruct(x=240.0, y=140.0, width=160.0, height=120.0)(override inference ROI withark_set_classification_params)
Call order
After ark_init(), before setting ROI / inferring.
Example
ark_init()
ark_load_classification_model("classification_active/model.onnx")
ark_set_classification_params(roi=struct(x=240.0, y=140.0, width=160.0, height=120.0))
ark_set_classification_params(roi=struct(x=240.0, y=140.0, width=160.0, height=120.0))
Stores the region of interest used by the next ark_infer_classification call (global ark_classification_roi).
Arguments
roi(struct, defaultstruct(x=240.0, y=140.0, width=160.0, height=120.0)): Crop rectangle in image coordinates (x,y,width,height)
Returns
void
Errors / failure modes
ROI must match what the model / training pipeline expects; a mismatched ROI is a common cause of wrong classes (see the classification example docs)
ROS
None directly (local URScript global only). Applied on the next
/infer_classificationcall.
Call order
After load; before or between inference calls when the ROI changes.
Example
ark_set_classification_params(struct(x=200.0, y=120.0, width=200.0, height=160.0))
ark_infer_classification()
ark_infer_classification()
Runs classification on the current image using the stored ROI.
Arguments
None
Returns
struct(error=ArkError(...), class_name=<string>, confidence=<float>)On success:
class_nameandconfidenceare the first label/confidence from the resultOn failure:
class_name="",confidence=0.0,error.error=True
Errors / failure modes
error.error=Trueif the service reportssuccess=False, or if labels/confidences lists are emptyService call timeout: 5.0 seconds
Requires
ark_init()and a priorark_set_classification_params(or the global ROI remains unset until set)
ROS
Service:
ARK_ROS2Namespace + "/infer_classification"Type:
ur_ark_ros_common_msgs/srv/InferClassificationRequest:
roi_query=ark_classification_roi
Call order
ark_init() → load model → set ROI → infer.
Example
ark_init()
ark_set_overlay("classification")
ark_load_classification_model("classification_active/model.onnx")
ark_set_classification_params(struct(x=240.0, y=140.0, width=160.0, height=120.0))
res = ark_infer_classification()
if res.error.error == False:
textmsg(res.class_name + " " + to_str(res.confidence))
end