MATLAB: How to impose limits on the Joint blocks in SimMechanics

actuatordamperinverted pendulumjointlimitsimmechanicsSimscape Multibodyspring

I would like to create a joint in SimMechanics where the angle between two bodies is bounded between two values regardless of the external force/torque.
For example, in the two-joint inverted pendulum demo (mech_dpen.mdl), how can I constrain the angle of Revolute joint 1 so that the angle is restricted to -10 and + 10 degrees?
I attempted to limit joint movement using joint spring and damper but I already control this joint using joint torque. I am solving in Forward Dynamics mode.

Best Answer

The ability to create a joint which has limits imposed on top of the applied torque is not available in SimMechanics. The issue is related to the fact that it is not possible to connect more than one joint actuator to a joint primitive.
To work around this issue, sum all of the torques or forces that will act on a primitive and then inject the total signal into the joint with one joint actuator. You will have to use a technique similar to what is used in the demo "mech_bouncing_ball" to enforce the limits, by creating a spring or some other limiting force that activates when the angle is outside of the limits. The external control torque signal and the spring signal will be added and then fed into the one joint actuator. You will need to create your own spring damper using Simulink blocks instead of using the supplied Joint Spring Damper.