Driving a kinematic joint
INTERACT allows you to easily control some physicalized objects with the following buttons, located in the joint component of the objects. In this page you will learn how to use them according your expectations.
Depend on the Joint Type
This 4 buttons will appear for a hinge, a prismatic or a helical joint.
However you can also add a monitor to a mapped joint.
Apply a Force or Torque
Click on Add Joint Effort to add the component XdeJointEffort allowing you to apply a force or a torque to the joint.
- The effort's unit is in Newton meter when it drives an Hinge Joint or in Newton if it drives a Prismatic Joint.
If joint is not moving
If your joint is not moving while an effort is set, double-check the friction value on the joint component. If the friction inside the joint is larger than the effort, you don't have enough force to move it.
Control the Position and/or Velocity with Gain
Click on Add PD Coupling to add the component XdeUnitJointPDController allowing you to control an object's position and/or velocity in the joint space depending on the gain added (and the friction defined on the object).
- Units are degrees and degrees/s when it controls an Hinge Joint or in m and m/s if it controls a Prismatic Joint.
- You can set desired position and/or velocity depending on which controlling mode you have selected.
- Proportional and derived gain are applied to the position and velocity difference.
If joint is not moving
If your joint is not moving while a controller is active, the controller response time may be too slow. Double-check the proportional and derived gain values.
If joint is moving too much
If you want the joint to stop quicker, you can add some friction in the joint component or reduce the gain values.
Define a velocity
Click on Add Dry Friction Control to define the velocity you want to assign to the object. The effort applied to the object will adapt according to the friction. The more friction your object has, the greater the force applied and the faster it will reach the requested speed.
Get Position and/or Velocity
To retrieve a joint position in a custom script, you can use a XdeUnitJointMonitor. To add it, in your joint component (ex: Xde Prismatic Joint), at the bottom click on Add monitor.
This component retrieves joint position and velocity in the joint space. Unit is degrees for hinge joint and meters for prismatic joint.
public XdeEngine.Core.Monitoring.XdeUnitJointMonitor xdeUnitJointMonitor;
void Update()
{
float alertThreshold = 50f;
if (xdeUnitJointMonitor.currentPosition > alertThreshold)
Debug.LogWarning("Limit exceeded");
}