physx-js-webidl icon indicating copy to clipboard operation
physx-js-webidl copied to clipboard

some help about articulation

Open lo-th opened this issue 3 years ago • 6 comments

Hi i need some help for articulation i know how to init / add bone but i have problem to get joint

init is

this.chain = this.useReducer ? root.world.createArticulationReducedCoordinate() : root.world.createArticulation()
// bone is 
var bone = this.chain.createLink( parent || null, transform );

joint should be joint = this.bones[ o.bone ].getInboundJoint()

on reducer i should have a PxArticulationJointReducedCoordinate but i have a PxArticulationJointBase i try joint = PhysX.TypeHelpers.prototype.articulationBaseJointToJoint( joint ) but i get a PxArticulationJoint

lo-th avatar Jan 31 '22 17:01 lo-th

in doc i have PxArticulationJoint* joint = static_cast<PxArticulationJoint*>(link->getInboundJoint()); for non reduced and PxArticulationJointReducedCoordinate* joint = static_cast<PxArticulationJointReducedCoordinate*>(link->getInboundJoint()); for reduced

lo-th avatar Feb 01 '22 08:02 lo-th

Ah I guess the cast function for reduced joint is missing in TypeHelpers. Should be easy to add (I'm not sure when I will have time to do that though).

I never tried the reduced coordinate articulations, the normal ones already were good enough (according to the doc the reduced coordinate version is more accurate and slower).

fabmax avatar Feb 01 '22 20:02 fabmax

yes i try to add typeHelpers but not work joint stay fixed reduced is more interesting because have many more option and work like standard joint

lo-th avatar Feb 01 '22 21:02 lo-th

basic articulation is for chaine or rope but reduced is for robot arm, leg, kinematic ... reduced have drive on joint and can be spherical, prismatic, revolute...

i try

TypeHelpers.prototype['articulationBaseJointToJointReduced'] = TypeHelpers.prototype.articulationBaseJointToJointReduced = /** @suppress {undefinedVars, duplicate} @this{Object} */function(baseJoint) {
  var self = this.ptr;
  if (baseJoint && typeof baseJoint === 'object') baseJoint = baseJoint.ptr;
  return wrapPointer(_emscripten_bind_TypeHelpers_articulationBaseJointToJoint_1(self, baseJoint), PxArticulationJointReducedCoordinate);
};;

now i have access of joint propriety but joint stay fixed :(

lo-th avatar Feb 02 '22 08:02 lo-th

wow that work !! i just make error in definition ( missing () at end ) joint.setJointType( PhysX[ '_emscripten_enum_PxArticulationJointTypeEnum_e'+ o.type.toUpperCase() ]() )

so just need add new TypeHelpers proto

lo-th avatar Feb 02 '22 15:02 lo-th

Alright, I added the TypeHelper function. Updated lib is available in dist directory. I haven't published it on npmjs yet in case more changes come up.

fabmax avatar Feb 02 '22 17:02 fabmax