Rubik's Cube Solving Robot icon Rubik's Cube Solving Robot — Control a custom ARC robot to manipulate and solve a Rubik's Cube using calibrated arms and grippers; integrates with Thingiverse build. Try it →
Asked
1 Participant
Tiny Yolo2 jitter on InMoov head

Tiny Yolo2 Jitter On Inmoov Head

I’ve got an EZ-InMoov Robot Head on an EZ-B over WiFi with a Logitech C920 feeding the Camera Device skill. Horizontal (pan) servo on D0, vertical (tilt) on D1, limits set 30-150, horizontal inverted, and servo speed at 2 so it doesn’t whip around. I added the Tiny Yolo2 skill, confirmed the model loads, set it Active, and I can see detections (mostly "person" around 0.6-0.8 confidence). When I enable servo tracking in the Camera Device, the head will follow but it jitters and hunts as the YOLO box wiggles frame-to-frame, and if there are two people or other objects (phone/chair) it rapidly switches targets.

What I want: only track the highest-confidence "person," add a small deadband so it doesn’t react to tiny box shifts, and if no person is seen for ~1s, return to neutral. I tried lowering camera resolution from 640x480 to 320x240, reducing servo speed, tightening servo limits, and setting Tiny Yolo2’s filter list to just "person," but the head still twitches and sometimes locks onto other classes. I also experimented with Camera Device scripts: On Tracking Start and On Tracking End. Ideally I’d gate servo tracking by class+confidence, and do a simple debounce before moving. I wasn’t sure of the right ControlCommand calls to toggle tracking from script; I tried something like:

# In Camera Device On Tracking Start
if ($CameraObjectName = "person" and $CameraObjectConfidence > 0.6)
  ControlCommand("Camera Device", "ServoTrackingOn")
else
  ControlCommand("Camera Device", "ServoTrackingOff")
endif

Is there a recommended way in ARC to have Tiny Yolo2 drive only the InMoov head servos toward the highest-confidence "person" with a pixel deadband and short debounce, and what are the correct ControlCommand names (or variables) to enable/disable camera servo tracking from script while filtering by class and confidence?



Related Hardware (view all EZB hardware)
EZ-Inmoov Robot Head by EZ-Robot & Gael Langevin
EZ-InMoov Robot Head with Synthiam ARCx: face tracking, speech recognition, Talk Servo jaw motion and AI conversation
Wi-Fi
Servos 8
Camera
Audio
UART ✕
I2C
ADC 2
Digital 8

Related Robot Skills (view all robot skills)
Camera Device by Synthiam
Use PC or robot cameras for vision tracking: color, QR, glyph, face, object, motion; record video/data, control servos and movement, run scripts
Tiny Yolo2 by Synthiam
Real-time TinyYolo object detection for ARC Camera Device: tracks 20 classes, populates camera variables, triggers tracking scripts, 30+ FPS in HD.

ARC Pro

Upgrade to ARC Pro

Unleash your creativity with the power of easy robot programming using Synthiam ARC Pro

Author Avatar
PRO
Canada
Twitter YouTube GitHub
#1  

Yes - the recommended ARC way is not to toggle servo tracking on/off inside the tracking callback the way you’re trying to do it.

That approach tends to create exactly the behavior you’re seeing: hunting, target flipping, and twitching. In ARC, the better pattern is:

  1. Let Tiny Yolo2 detect objects
  2. Filter the detections in script
  3. Use a small deadband / debounce
  4. Move the servos yourself with Servo.setPosition()
  5. Optionally keep Camera Device servo tracking off so it doesn’t fight your script

For this kind of "track the best person only" behavior, scripted control is much more stable than relying on the built-in servo tracking alone.


Important correction

These are not the right ControlCommands:

ServoTrackingOn
ServoTrackingOff

The Camera Device uses commands like:

  • CameraServoTrackEnable
  • CameraServoTrackDisable
  • CameraServoTrackToggle

Also, you can target the Camera skill by its exact skill name, so make sure the name in ControlCommand() matches the robot skill title exactly.

Reference:


Best practice for your goal

1) Turn off Camera Device servo tracking

Use the Camera Device for detection only.

Then create a separate JavaScript or Python script to drive D0 and D1.

That gives you full control over:

  • class filtering
  • confidence threshold
  • deadband
  • debounce
  • recenter timeout

2) Use a deadband on the center point

If the target is only drifting a few pixels, don’t move the servos.

For example:

  • camera width = 320
  • camera height = 240
  • center = (160, 120)
  • deadband = 20 px horizontally and 15 px vertically

Only move if the target center is outside that zone.


3) Track the highest-confidence person

If Tiny Yolo2 is populating arrays, use the object arrays and choose the best person result above your confidence threshold.

Since the camera skill exposes arrays like:

  • $CameraObjectNameArray
  • $CameraObjectConfidenceArray
  • $CameraObjectCenterXArray
  • $CameraObjectCenterYArray
  • $CameraObjectCount

you can scan all detections and pick the best person.


4) Return to neutral after no person for 1 second

Use a timestamp variable and if no valid person is detected for 1000 ms, move servos back to center.


Example JavaScript approach

Put this in a script skill or in a timer-based script that runs repeatedly:

// Settings
var cameraSkillName = "Camera Device";
var confidenceThreshold = 0.6;
var deadbandX = 20;
var deadbandY = 15;
var panServo = d0;
var tiltServo = d1;
var panCenter = 90;
var tiltCenter = 90;
var panStep = 2;
var tiltStep = 2;
var neutralTimeoutMs = 1000;

var count = getVar("$CameraObjectCount", 0);
var bestIndex = -1;
var bestConfidence = 0;

for (var i = 0; i < count; i++) {
  var name = getVar("$CameraObjectNameArray[" + i + "]", "");
  var confidence = parseFloat(getVar("$CameraObjectConfidenceArray[" + i + "]", 0));

  if (name == "person" && confidence >= confidenceThreshold && confidence > bestConfidence) {
    bestConfidence = confidence;
    bestIndex = i;
  }
}

if (bestIndex >= 0) {
  var cx = parseInt(getVar("$CameraObjectCenterXArray[" + bestIndex + "]", 0));
  var cy = parseInt(getVar("$CameraObjectCenterYArray[" + bestIndex + "]", 0));

  setVar("$LastPersonSeenMs", new Date().getTime());

  var frameCenterX = 160;
  var frameCenterY = 120;

  var errorX = cx - frameCenterX;
  var errorY = cy - frameCenterY;

  if (Math.abs(errorX) > deadbandX) {
    var pan = Servo.getPosition(panServo);
    if (errorX > 0) {
      pan -= panStep;
    } else {
      pan += panStep;
    }
    Servo.setPosition(panServo, pan);
  }

  if (Math.abs(errorY) > deadbandY) {
    var tilt = Servo.getPosition(tiltServo);
    if (errorY > 0) {
      tilt += tiltStep;
    } else {
      tilt -= tiltStep;
    }
    Servo.setPosition(tiltServo, tilt);
  }

} else {
  var lastSeen = parseInt(getVar("$LastPersonSeenMs", 0));
  var now = new Date().getTime();

  if (lastSeen > 0 && (now - lastSeen) > neutralTimeoutMs) {
    Servo.setPosition(panServo, panCenter);
    Servo.setPosition(tiltServo, tiltCenter);
  }
}

Why this works better

This avoids the two biggest causes of jitter:

  • Frame-to-frame YOLO box movement
  • ARC servo tracking trying to react too aggressively

You get to smooth the motion in software instead of letting every detection shift directly drive the servos.


If you still want to toggle tracking from script

Use the proper command names:

ControlCommand("Camera Device", "CameraServoTrackEnable");
ControlCommand("Camera Device", "CameraServoTrackDisable");

But again, for your use case, I would not do that repeatedly in response to detections. That’s the unstable part.


Even better: add hysteresis

A stronger version of the deadband is:

  • move only if error exceeds a larger threshold, like 25 px
  • stop moving until the error drops below a smaller threshold, like 10 px

That prevents "oscillating on the edge."


One more thing

If Tiny Yolo2 is still "switching classes," make sure you’re not relying on the camera’s generic servo tracking reaction mode. That mode reacts to whatever the camera tracking system considers the active object. If you want only person, then the script should be the decision-maker.

Tiny Yolo2 docs:

Camera Device docs:


I’d recommend this setup for your InMoov head

  • Camera Device: detection only
  • Tiny Yolo2: active, person filter enabled
  • JavaScript: choose best person, apply deadband, debounce, neutral return
  • Servo speed: keep low, but use script smoothing too

If you want, I can write you a clean ARC JavaScript script specifically for the EZ-InMoov head that does all of this with:

  • highest-confidence person selection
  • deadband
  • debounce
  • return-to-center after 1 second
  • optional pan/tilt inversion handling

Also, what’s your bigger goal here - just single-person head tracking, or do you want the head to track the closest person and ignore everyone else?

I am a customer support AI and still learning. Please verify important answers in our support documentation. For advanced AI features, use the AI Script Agent built into ARC.