Posted By: yorisimo
physX 6D joint examples and questions - 01/26/12 19:43
I've spent some time trying to figure out how to make motorized joints with limits using physX. I thought some people might find this example code useful. Use home and end keys to change the joint type (from 1-3 degrees of freedom with different combinations of swing1, swing2, and twist motions). Then use page up, page down, cursor left, cursor right, cursor up, or cursor down to drive the motors. Only the keys controlling the active degrees of freedom will work (e.g. for the fixed joint, no matter what you push the joint won't move). The code is completely self contained (no external model or levels, so just copy into an empty .c file and it should run with A8.30)
I've found some discrepancies with the manual, and some things that weren't very clear to me from the manual:
1. in "pXcon_set6djoint", JointMotion[3-5] defines the swing1, swing2, and twist motion of the joint in that order (not pan,tilt, and roll)
2. also in "pXcon_set6djoint", an axis may be NX_D6JOINT_MOTION_FREE or NX_D6JOINT_MOTION_LIMITED in order to be driven by a motor
3. in "pXcon_setmotor", the vecParam specifies the twist, swing2, and swing1 motor values in that order
4. in "Constaints/PH_6DJOINT", parameter 4, x represents swing1 limit in either direction, y represents swing 2 limit in either direction
5. also in "Constaints/PH_6DJOINT", parameter 5, x represents lower twist limit, and y represents upper twist limit.
for a definition of the swing1, swing2, and twist you have to see the PhysXDocumentation ( http://server.conitec.net/down/physXdoc.zip)
Questions:
1. Is there a way to query what the current angles are? pXcon_getposition does not return the swing1, swing2, and twist angles. These must somehow be available within the engine in order to verify whether or not the joint is between its limits, but they do not seem to be exposed in GS.
2. Is there a way to motorize a simple hinge joint instead of using the more complicated 6d joint in GS. According to PhysX documentation this seems very simple but it does not appear to be exposed in GS and didn't work when I tried it.
3. Why can't the 6D Joint be motorized with a positional motor? (That is, attempt to drive to a certain angle, rather than angular velocity) I tried setting the appropriate JointDrive element to NX_D6JOINT_DRIVE_POSITION in pXcon_set6djoint, and setting mode=2 in pXcon_setmotor but it didn't work.
I hope that the PhysX plug-in for GS will be developed further and that more of the features available in PhysX will become available, and that the use of these features will be more clearly explained in the manual.
Thanks!
Click to reveal..
I've found some discrepancies with the manual, and some things that weren't very clear to me from the manual:
1. in "pXcon_set6djoint", JointMotion[3-5] defines the swing1, swing2, and twist motion of the joint in that order (not pan,tilt, and roll)
2. also in "pXcon_set6djoint", an axis may be NX_D6JOINT_MOTION_FREE or NX_D6JOINT_MOTION_LIMITED in order to be driven by a motor
3. in "pXcon_setmotor", the vecParam specifies the twist, swing2, and swing1 motor values in that order
4. in "Constaints/PH_6DJOINT", parameter 4, x represents swing1 limit in either direction, y represents swing 2 limit in either direction
5. also in "Constaints/PH_6DJOINT", parameter 5, x represents lower twist limit, and y represents upper twist limit.
for a definition of the swing1, swing2, and twist you have to see the PhysXDocumentation ( http://server.conitec.net/down/physXdoc.zip)
Questions:
1. Is there a way to query what the current angles are? pXcon_getposition does not return the swing1, swing2, and twist angles. These must somehow be available within the engine in order to verify whether or not the joint is between its limits, but they do not seem to be exposed in GS.
2. Is there a way to motorize a simple hinge joint instead of using the more complicated 6d joint in GS. According to PhysX documentation this seems very simple but it does not appear to be exposed in GS and didn't work when I tried it.
3. Why can't the 6D Joint be motorized with a positional motor? (That is, attempt to drive to a certain angle, rather than angular velocity) I tried setting the appropriate JointDrive element to NX_D6JOINT_DRIVE_POSITION in pXcon_set6djoint, and setting mode=2 in pXcon_setmotor but it didn't work.
I hope that the PhysX plug-in for GS will be developed further and that more of the features available in PhysX will become available, and that the use of these features will be more clearly explained in the manual.
Thanks!