[ODE] swinging hinge joint
Wesley Smith
wesley.hoke at gmail.com
Sat Apr 22 18:52:37 MST 2006
Hi,
I'm trying to get a grasp on ODE and to that end, I'm trying to make
very very simple tests for myself. Right now, I'm trying to create a
hinge joint between a plane and a sphere and have the sphere swing. I
have the plane as a Geom with no Body 'cause I don't want it to move.
It's located at (0, 4, 0) with it's normal pointing down. The sphere
I create at (0, 2.5, 0) initially and place the joint anchor at (0,
3.5, 0) with an axis (1, 0, 0). Here's the code:
m_ground = dCreatePlane(m_worldSpace, 0, -1, 0, -4);
//set positions for creating joints
dBodySetPosition(m_grains[0].bodyID(), 0.f, 2.5f, 0.f);
//make hinge joint between sphere and world
dJointID jid = dJointCreateHinge(m_grainWorld, 0);
dJointSetHingeAnchor(jid, 0.f, 3.5f, 0.f);
dJointSetHingeAxis(jid, 1.f, 0.f, 0.f);
dJointAttach(jid, m_grains[0].bodyID(), 0);
dBodySetLinearVel(m_grains[0].bodyID(), 2.f, 0.f, 0.f);
dJointAddHingeTorque(jid, 3.f);
//move sphere to start simulation
dBodySetPosition(m_grains[0].bodyID(), 1.f, 3.f, 0.2f);
I also try to give the sphere/joint a "push" with the torque and
velocity (m_grains[0] is my sphere). What I'm seeing during
simulation is that the sphere ends up moving to (0, 0, 0) and staying
there. If I try and apply a velocity to it, it immediately snaps back
into place with no swing. Obviously, I'm not doing something right.
I suspect this line is not correct:
dJointAttach(jid, m_grains[0].bodyID(), 0);
How can I attach the joint to a sphere and an immovable plane to get
this pendulum-like swinging effect?
thanks,
wes
More information about the ODE
mailing list