MTK Control System with Current Not Working

Hello! I’m trying to implement this exact same example, but controlling with the current that passes through the resistance instead of the speed in speed_sensor.w.

    @equations begin
        #...
       #connect(current_sensor.i, :y, feedback.input2) #not working
        feedback.input2 ~ current_sensor.i
        connect(R1.n, current_sensor.p)        
        connect(current_sensor.n, L1.p)        
        #...
    end

@named model = DCMotor()

sys = structural_simplify(model)

At structural_simplify it gives ERROR: MethodError: no method matching -(::SymbolicUtils.BasicSymbolic{Real}, ::ODESystem) The function `-` exists, but no method is defined for this combination of argument types.
Since I’ve had similar issues with other implementations, I figured it could be a beginner’s problem.

It’s because feedback.input2 is a connector and not a variable. You would have to do

feedback.input2.u ~ current_sensor.i

instead.

Why does

connect(current_sensor.i, :y, feedback.input2)

not work?