Page 1 of 1

balljoint

Posted: Mon Jul 22, 2019 9:55 am
by danmenpui
I want to use a balljoint, but I can not find an example. Could someone give me an example of how you should write the code for a balljoint?
Thank you

Re: balljoint

Posted: Mon Jul 22, 2019 10:21 am
by jimmy
Matlab, Python, C++?

Re: balljoint

Posted: Mon Jul 22, 2019 10:28 am
by jimmy
Below is some Matlab code for making a pinjoint between a thigh and a pelvis. You can adjust to make it a Balljoint. Use the BallJoint API documentation to help.

Code: Select all

%% Create a Left Thigh
leftThigh = Body();
leftThigh.setName('LeftThigh');
leftThigh.setMass(1);
leftThigh.setInertia(Inertia(2,2,0.02,0,0,0));

 % Create a Pin joint
locationInParent    = Vec3(0,0,-0.2);
orientationInParent = Vec3(0,0,0);
locationInChild     = Vec3(0,0.25,0);
orientationInChild  = Vec3(0,0,0);
LThighToPelvis = PinJoint('LThighToPelvis', pelvis, locationInParent, ...
    orientationInParent, leftThigh, locationInChild, orientationInChild);

 % Update the coordinates of the new joint
LHip_rz = LThighToPelvis.updCoordinate();
LHip_rz.setRange([deg2rad(-100), deg2rad(100)]);
LHip_rz.setName('LHip_rz');
LHip_rz.setDefaultValue(0.312511671);
LHip_rz.setDefaultSpeedValue(-0.245407488);

 % Add geometry to display in the GUI
ThighLength = 0.5;
leftThigh.attachGeometry(Ellipsoid(ThighLength/20, ThighLength/2, ThighLength/20));

% Add the joint to the Model.
model.addJoint(LThighToPelvis);