| SimMechanics™ | ![]() |
Specify distance between two Body CS origins as function of time
Constraints & Drivers

The Distance Driver block drives the distance between the origins of two Body coordinate system (CS) as a function of time that you specify. This function must always remain nonnegative during the simulation.
Let r1, r2 be the vector positions of the origins of CS1 on one Body and CS2 on the other Body, respectively. These vectors can be measured in any CS. The Distance Driver specifies the scalar distance d = |r1 - r2| between these points as a function of time:
![]()
You connect the Distance Driver to a Driver Actuator block.
The Simulink® input signal into the Driver Actuator specifies the time-dependent driving function f(t) and its first two derivatives, as well as their units. If you do not actuate Distance Driver, this block acts as a time-independent constraint that freezes the distance between the two Body CSs at its initial value d(t=0) during the simulation.
Caution The block computes the initial distance d(t=0) between the coordinate systems when the machine is in its home configuration, the original configuration of the machine's bodies before the simulation imposes initial conditions and implements joint assembly. See Kinematics and the Machine's State of Motion in the Representing Motion chapter and How SimMechanics™ Software Works in the Running Mechanical Models chapter. |
Drivers restrict relative degrees of freedom (DoFs) between a pair of bodies as specified functions of time. Locally in a machine, they replace a Joint as the expression of the DoFs. Globally, Driver blocks must occur topologically in closed loops. Like Bodies connected to a Joint, the two Bodies connected to a Drivers are ordered as base and follower, fixing the direction of relative motion.
You can also connect a Constraint & Driver Sensor to any Driver and measure the reaction forces/torques between the driven bodies.

The dialog has one active area, Connection parameters.
The base (B)-follower (F) Body sequence determines the sense of positive motion. Positive translation is the follower moving in the direction of the translation axis.
When you connect the base (B) connector port on the Distance Driver block to a Body CS Port on a Body, this parameter is automatically reset to the name of this Body CS. See the following figure, Distance Driver Base and Follower Body Connector Ports.
When you connect the follower (F) connector port on the Distance Driver block to a Body CS Port on a Body, this parameter is automatically reset to the name of this Body CS. See the following figure, Distance Driver Base and Follower Body Connector Ports.
Using this spinner menu, you can set the number of extra connector ports needed for connecting Driver Actuator and Constraint & Driver Sensor blocks to this Driver. The default is 0.
To activate the Driver, connect a Driver Actuator.
Distance Driver Base and Follower Body Connector Ports

Constraint & Driver Sensor, Driver Actuator, Linear Driver, Weld
See Constraining and Driving Degrees of Freedom for more on restricting DoFs with Drivers.
See Verifying Machine Topology and How SimMechanics™ Software Works for more on using drivers in closed loops.
![]() | Disassembled Spherical | Driver Actuator | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |