Create a revolute, prismatic, and fixed joint constraints for a simple rigid body tree.

**Revolute Joint Constraint**

To demonstrate a revolute joint constraint, create a four-bar linkage by connecting the end of the last link, `link3`

, and the first link, `link0`

.

Create a generalized inverse kinematics solver with a revolute joint constraint and a joint bounds constraint.

To ensure repeatable IK solutions, disable random restarts.

Fix the first joint by setting `theta`

as both the minimum and maximum bound.

Create a revolute joint constraint with successor and predecessor bodies set to the last link `link3`

and the first link `link0,`

respectively. Specify predecessor and successor transforms that create intermediate frames `1`

meter away, in the *X*-axis, from their respective body. Once defined, these intermediate frames move such that their frame origins coincide when their *Z*-axes align.

Provide `[theta 0 0]`

as an initial guess to the solver, along with the constraints.

Visualize the robot to see the robot acting as a four-bar linkage. If the first joint rotates, the solver tries to keep the intermediate frames of the revolute joint constraint coincident, acting as a joint and resulting in four-bar motion.

ans =
Axes (Primary) with properties:
XLim: [-2.5000 2.5000]
YLim: [-2.5000 2.5000]
XScale: 'linear'
YScale: 'linear'
GridLineStyle: '-'
Position: [0.1300 0.1100 0.7750 0.8150]
Units: 'normalized'
Use GET to show all properties

**Prismatic Joint Constraint**

Use a prismatic joint constraint to create a slider-crank. Create a new solver with a prismatic joint constraint and a joint bounds constraint.

Create the prismatic joint constraint with `link3`

and `link0`

as the successor and predecessor bodies, respectively, and set the predecessor transform such that the predecessor intermediate frame is `1`

meter away on the *X*-axis and rotated `pi/2`

in the *Y*-axis from the predecessor body frame.

Provide `[theta 0 0]`

as an initial guess to the solver along with the constraints.

Visualize the robot to see the robot acting as a slider-crank. If the first joint rotates, the solver tries to keep the intermediate frames of the prismatic joint constraint coincident, acting as a joint and resulting in slider-crank motion.

ans =
Axes (Primary) with properties:
XLim: [-2.5000 2.5000]
YLim: [-2.5000 2.5000]
XScale: 'linear'
YScale: 'linear'
GridLineStyle: '-'
Position: [0.1300 0.1100 0.7750 0.8150]
Units: 'normalized'
Use GET to show all properties

**Fixed Joint Constraint**

To demonstrate a fixed joint constraint, create a triangle with the links that is preserved when the first joint moves. Create a new solver with a fixed joint constraint.

Create the fixed joint constraint with `link3`

and `link0`

as the successor and predecessor bodies, respectively, and set the successor transform such that the predecessor intermediate frame is `1`

meter away on the *X*-axis from the predecessor body frame.

Set the weight of the orientation constraint of the fixed joint constraint to `0`

.

Visualize the robot to see how the fixed constraint joint acts on the robot frame. If the first joint rotates, the solver tries to keep the intermediate frames of the fixed joint constraint coincident, acting as a fixed joint.

ans =
Axes (Primary) with properties:
XLim: [-2.5000 2.5000]
YLim: [-2.5000 2.5000]
XScale: 'linear'
YScale: 'linear'
GridLineStyle: '-'
Position: [0.1300 0.1100 0.7750 0.8150]
Units: 'normalized'
Use GET to show all properties