Suppose you want to switch between a Planar (PX, PY, RZ) and 6-DOF (PX, PY, PZ, RX, RY, RZ) joint.
The only approach I know of is to add variable springs and dampers to each of the "tunable" joint primitives -- in this case, PZ, RX, and RY which you want to enable and disable.
When your condition is true, set the springs and dampers to a really high value, effectively constraining their motion with a little bit of compliance. When your condition is false, set these spring and damper values to zero, or a low number, effectively making them free to move.
These variable springs and dampers can be implemented using Physical Signal blocks (Fspring = K*x, Fdamper = D*v). So, for each joint primitive you measure the position and velocity, multiply them by variable gains as above, and feed them back to the joint as forces and torques.
Below is a screenshot showing an example for one joint primitive. I'd highly recommend using subsystems :)
NOTE: Based on sign convention, those constant values would have to be negative.
- Sebastian
Best Answer