# Hinge Joint

## Watch the video tutorial on controlling a motor using a neural network!

 Figure 1. Hinge Joint Type.

This joint type can be used in the biomechanical editor to create a musculo-skeletal model. A Hinge leaves a pair of bodies free to rotate about a single axis (the hinge axis) but otherwise completely fixed with respect to each other. The axis has fixed positions and orientations in each of the rigid body and the hinge constraint forces those axes to coincide at all times. In doing so, it removes five degrees of freedom, and is therefore more computationally costly than, for example, a ball and socket joint.

A Hinge joint could be used, for example, to attach a gate (or door) to a gatepost, finger joints, drawbridge or seesaw to its fulcrum, or to attach rotating parts such as a wheel to a chassis, a propeller shaft to a ship or a turntable to a deck.

The geometry of this biomechanical joint is such that during the simulation, a line l0 fixed in body b0 will be coincident to a line l1 fixed in body b1, and the origin of l1 is fixed relative to the origin of l0. This allows relative rotation of both bodies about the common axis defined by l0 or l1. For convenience, the origin of l0 and l1 is chosen to coincide and this point is called the joint position. This means that in world coordinates, the direction vector of line l0 and line l1 will be almost identical and so will be the world coordinates of the origin of line l0 and line l1.

The hinge joint also has a built in motor that can be used to rotate the connected parts around the joint. The motor can operate in three modes. The first, default mode, is like a normal DC motor. The input to the motor determines its speed. This is velocity control. The second mode is as a standard servo motor. In this case the input determines the rotational position. The motor will move to the new position at its maximum speed. This is position control. The third mode is where you can control both the position and velocity for the motor. This is velocity and position control mode. In this mode you can have two different neurons connected to your motor. One of them can have a target data type of desired position, and the other can have a target data type of desired velocity. This allows you to control the position and velocity targets of the motor independently using neural output in your network. You can control the motor using a motor velocity stimulus, motor position stimulus, or directly using neural control. A typical example in neural control would relate the membrane voltage of a neuron to the position or velocity of the motor, depending on which type of motor you are using. This conversion is performed using an adapter.

## General Properties

 Figure 2. The properties of the hinge joint.

To see a description of the properties common to all bodies follow this link

## Hinge Properties

These properties are specific to hinge only.

Constraint

Damping
Damping is a spring damping term applied to joints that have exceeded their limit. As with a spring, if both the stiffness and damping are set to zero, the limit is essentially deactivated.
Default value: 0 Kg/m
Acceptable range: Anything greater than or equal to 0.

Enable Limits
If this is true then the constraint is turned on, if it is false then there are no constraints on the movement of the hinge joint within its axis of movement.
Default value: True
Acceptable range: True/False

Maximum
The maximum amount a body can rotate around the axis of rotation. This is the upper bound of the constraint limit.
Default value: 90 degrees
Acceptable range: 0 - 360

Minimum
The minimum amount a body can rotate around the axis of rotation. This is the lower bound of the constraint limit.
Default value: -90 degrees
Acceptable range: 0 - (-360)

Restitution
The coefficient of restitution is the ratio of rebound velocity to impact velocity when the joint reaches the low or high stop. This is used if the limit stiffness is greater than zero. Restitution must be in the range zero to one inclusive.
Default value: 0 V/V
Acceptable range: 0-1.

Stiffness
When the angle between two bodies reaches the cone limit a stiffness value determines how the restoring force is applied. If this value is set high, there is perfect restitution when the limit is reached. Otherwise, there will be a degree of springiness between the two bodies at the limit.
Default value: 5 MN/m
Acceptable range: Anything greater than or equal to 0.

Part Properties

Enable Motor
Determines whether the motor is on or not. If the motor is on then it will not allow movements until either a neural input or a stimulus tells it to move by setting its velocity. See how to add a motor velocity stimulus here, and how to move a motor using a neural network here.
Default value: False
Acceptable range: True/False

Max Motor Torque
The maximum torque that this motor can apply to obtain a desired velocity of movement
Default value: 100 Nm
Acceptable range:

Max Velocity
The maximum positive or negative velocity that the motor can use to move this part
Default value: 100 rad/s
Acceptable range:

Servo Gain
The magnitude of the feedback gain for the servo motor. This is only used if the motor type is Servo. It determines how quickly the motor attempts to reach the desired location using a simple feedback gain mechanism.
Default value: 100
Acceptable range:

Motor Type
Sets the type of motor to use for this joint. Options are velocity control, position control, and velocity and position control
Default value: Velocity control