org.odejava
Class Joint

java.lang.Object
  extended by org.odejava.Joint
Direct Known Subclasses:
JointAMotor, JointBall, JointFixed, JointHinge, JointHinge2, JointSlider, JointUniversal

public abstract class Joint
extends Object

In real life a joint is something like a hinge, that is used to connect two objects. In ODE a joint is very similar: It is a relationship that is enforced between two bodies so that they can only have certain positions and orientations relative to each other.

Created 20.12.2003 (dd.mm.yyyy)

Author:
Jani Laakso E-mail: jani.laakso@itmill.com see http://odejava.dev.java.net

Field Summary
protected  Body body1
          The first body that this joint is attached to.
protected  Body body2
          The second body that this joint is attached to.
protected static String BOUNCE_RANGE_MSG
          Error message when the bounce range is negative
protected  boolean deleted
          Flag indicating that this joint has been requested to be deleted.
protected  JointFeedback feedback
          Dataholder for acquiring feedback information when the user has enabled feedback tracking.
protected  JointGroup group
          If the user provided a joint group to create the joint with, this will reference the group it is a part of.
protected  org.odejava.ode.SWIGTYPE_p_dJointGroupID jointGroupId
          The ID of the group that this joint belongs to.
protected  org.odejava.ode.SWIGTYPE_p_dJointID jointId
          The ODE ID of this joint object.
protected  String name
          An arbitrary, user-defined name string for the joint.
 
Constructor Summary
Joint(String name, JointGroup jointGroup)
          Create a new joint with a given name label and an optional group that it is a member of.
 
Method Summary
 void attach(Body body1, Body body2)
          Attach this joint to the two bodies.
 void delete()
          Request deletion of this joint.
 void enableFeedbackTracking()
          Create a JointFeedback object and associate it with this joint.
 void enableFeedbackTracking(boolean state)
          Modify the current joint feedback tracking state.
 Body getBody1()
          Returns the first body this joint is connected to.
 Body getBody2()
          Returns the second body this joint is connected to.
 JointFeedback getFeedback()
          Return detailed information about this joint from the last simulation step.
 JointGroup getGroup()
          Returns the JointGroup that this joint was attached to when created.
 String getName()
          Get the currently set name of this joint.
 float getParam(int parameter)
          Get an unchecked parameter value directly from this joint.
 boolean isFeedbackTrackingEnabled()
          Check to see if feedback tracking is currently enabled.
 void setAxis1(float x, float y, float z)
           
 void setAxis2(float x, float y, float z)
           
 void setName(String name)
          Set a new custom name for this joint.
 void setParam(int parameter, float value)
          Set a generic, unchecked, parameter directly for this joint.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BOUNCE_RANGE_MSG

protected static final String BOUNCE_RANGE_MSG
Error message when the bounce range is negative

See Also:
Constant Field Values

jointGroupId

protected org.odejava.ode.SWIGTYPE_p_dJointGroupID jointGroupId
The ID of the group that this joint belongs to. Assigned during the constructor and will either point to the group's ID or to the default zero value if no group is provided.


jointId

protected org.odejava.ode.SWIGTYPE_p_dJointID jointId
The ODE ID of this joint object. Set during the constructor of the concrete classes.


name

protected String name
An arbitrary, user-defined name string for the joint. Not used by ODE.


group

protected JointGroup group
If the user provided a joint group to create the joint with, this will reference the group it is a part of. If the joint is part of the global environment, and not part of a group, this will be null.


body1

protected Body body1
The first body that this joint is attached to. Null if not attached.


body2

protected Body body2
The second body that this joint is attached to. Null if not attached.


feedback

protected JointFeedback feedback
Dataholder for acquiring feedback information when the user has enabled feedback tracking. If no tracking is currently taking place, this will be null.


deleted

protected boolean deleted
Flag indicating that this joint has been requested to be deleted. After this is set to true, none of the methods should allow further calls to ODE as the values are invalid, and may well cause a crash of the library or other strange error.

Constructor Detail

Joint

public Joint(String name,
             JointGroup jointGroup)
Create a new joint with a given name label and an optional group that it is a member of. Both parameters are optional. If no joint group is supplied then the default joint ID of 0 is used.

Parameters:
name - A label string to associate with this joint
jointGroup - An optional group to associate this joint with
Method Detail

attach

public void attach(Body body1,
                   Body body2)
Attach this joint to the two bodies. If both body references are null, the joint is detached from both and put into limbo until re-attached to one or more bodies. If this joint is already attached to bodies, it is first detached from the old bodies and then attached to new bodies. Either body reference may be null, in which case the joint is attached to the global environment.

Parameters:
body1 - The first body reference to attach to
body2 - The second body reference to attach to

delete

public void delete()
Request deletion of this joint. If the joint is attached to a group, it is not immediately deleted. Instead, it is marked as deleted and must wait until the owning group is deleted or emptied. Any further calls to this joint instance after this has been called will be met with an error.


getName

public String getName()
Get the currently set name of this joint. If no name is set, this will return null.

Returns:
The name string or null if none set

setName

public void setName(String name)
Set a new custom name for this joint. A value of null will clear the currently set name. This is a local convenience function as ODE does not track names for joints.

Parameters:
name - The new name string to set.

enableFeedbackTracking

public void enableFeedbackTracking()
Create a JointFeedback object and associate it with this joint. This means that ODE will now store specific information about this joint in this structure after every world step, so you can find out more information on what forces and torques are acting upon it.


enableFeedbackTracking

public void enableFeedbackTracking(boolean state)
Modify the current joint feedback tracking state. This can be used to enable or disable feedback tracking as needed.

Parameters:
state - true to enable feedback tracking, false to disable

isFeedbackTrackingEnabled

public boolean isFeedbackTrackingEnabled()
Check to see if feedback tracking is currently enabled.

Returns:
true if feeback tracking is running

getFeedback

public JointFeedback getFeedback()
Return detailed information about this joint from the last simulation step. Must first enableFeedbackTracking() to start getting information.

Returns:
The joint feedback instance, or null if tracking is not enabled.

getGroup

public JointGroup getGroup()
Returns the JointGroup that this joint was attached to when created. If no group was assigned, this returns null.

Returns:
The group reference or null

getBody1

public Body getBody1()
Returns the first body this joint is connected to. If no body is assigned, this returns null.

Returns:
The current first body instance, or null

getBody2

public Body getBody2()
Returns the second body this joint is connected to. If no body is assigned, this returns null.

Returns:
The current second body instance, or null

setParam

public void setParam(int parameter,
                     float value)
Set a generic, unchecked, parameter directly for this joint. The parameter types that are permissable for the joint are defined by the individual joint classes and the definitions can be found in OdeConstants. The default implementation in this class does not support any parameters, and is implemented as an empty method that silently ignores the request.

Parameters:
parameter - A parameter constant from OdeConstants
value - The new value to associate with the parameter

getParam

public float getParam(int parameter)
Get an unchecked parameter value directly from this joint. The parameter types that are permissable for the joint are defined by the individual joint classes and the definitions can be found in OdeConstants. The default implementation in this class does not support any parameters, and shall always return zero.

Parameters:
parameter - A constant describing the parameter to fetch
Returns:
The value of that parameter

setAxis1

public void setAxis1(float x,
                     float y,
                     float z)

setAxis2

public void setAxis2(float x,
                     float y,
                     float z)