Cyber Brick servo always returns to neutral position

Hi everyone,

I’m using the Cyber Brick remote controller with standard 180° servos, and I’ve noticed that whenever I turn the servo to a new angle, it always snaps back to its neutral (initial) position. This happens regardless of where I move it, it just won’t hold the last position. Here’s the model I’ve printed: Servo Mini Arm V2 - CyberBrick by LucaDilo MakerWorld: Download Free 3D Models

From what I understand, the current firmware logic sends a “stop” command that resets the servo to its neutral angle instead of holding the last commanded position.

I analyzed the Python source code (with AI assistance) and tried monkey-patching the stop method in ServosControllerExecMapper to hold the last angle instead:

# Simple Servo Fix - Alternative approach
from control import ServosControllerExecMapper

servo_mapper = ServosControllerExecMapper()
original_stop = servo_mapper.singleton.stop

def hold_position_stop(servo_idx):
    """Hold position instead of stopping"""
    internal_idx = servo_idx - 1
    if 0 <= internal_idx < len(servo_mapper.singleton.servos_map):
        current_angle = servo_mapper.singleton.servos_info_map[internal_idx]["c_ang"]
        duty = int(current_angle * 102 / 180 + 25)
        servo_mapper.singleton.servos_map[internal_idx].duty(duty)
        servo_mapper.singleton.servos_info_map[internal_idx]["step_en"] = False
        print(f"Servo {servo_idx} holding at {current_angle}°")

servo_mapper.singleton.stop = hold_position_stop
servo_mapper.singleton.original_stop = original_stop

print("Servo position hold fix applied!")

Unfortunately, this didn’t solve the problem, possibly because I’m hooking into the wrong place in the execution flow.

My main blockers now are:

  1. I’m not sure exactly where to trigger this code. I tried triggering it on the left stick’s X‑axis movement, but it didn’t work.

  2. I’m also not sure how to “upload the modified code to the onboard file system of the Controller Core” and then debug it.

Has anyone here tried modifying servo behavior in Cyber Brick?

  • Is there a known way to make it hold its last commanded position instead of returning to neutral?
  • What’s the best way to deploy and debug modified Python code on the Controller Core?

Thanks in advance!

The position control is done in the servo itself. CyberBrick kit offers two types of servos - angle mode driven and velocity mode driven.

The angle mode servos control the position according to the servo pulse width input to them and return thus with neutral 1.5 ms long pulse to the center.

The velocity mode servos do not move, when neutral input is given to them and turn to one or the other side if a deflection to the neutral input is provided, speed proportional to the deflection amount.

1 Like