Create a non-rotating frame

Now I am trying to solve a problem. I want to create a frame whose translation is the same as the frame of a certain bodynode, but there is no rotation. That is, there are linear acceleration and linear velocity, but there is no angular velocity and angular acceleration.
I don’t know how to create such a frame reasonably.

I think you could create a dummy body (low mass) with a TranslationalJoint to the world and attach it with a BallJointConstraint to the target body. I am not sure, whether there is a better solution.

Thanks for your advice, i worry about whether this approach can be stable

Can you elaborate on what you mean by “frame”? Does it need to be a BodyNode that gets physically simulated, or is it just meant to be an abstract reference frame that you can use for kinematic calculations?

If it’s the latter, then you could create your own SimpleFrame and on every time step just set the translation and the the velocity/acceleration based on the BodyNode properties that you’re trying to duplicate.

One word of caution: Make sure the parent frame of your SimpleFrame is the World frame and not the BodyNode, otherwise you’ll have a hard time keeping out the rotational velocity/acceleration.

Hi, grey, glad to see you again.
You got my point.
Can you give a short example code on how to correctly set the velocity and acceleration? I am afraid that i cannot implement correctly.

Actually all i want is to get a Frame which duplicates a BodyNode’s Frame, but not rotating. I am trying to get a non-rotating reference of Frame of a certain bodyNode, though actually the bodyNode may rotate…

This issue arises from my experiment that i want to simulate under a body’s non-inertial frame, but the euler forces and other angular-related force may cause instability on my own simulator. Thus i am trying to get a reference of frame which is non-rotating and that reference of frame should have the same linear velocity and acceleration as the true bodyNode.

In your word, the translation to be set should also be getWorldTransform().translation() and the velocity/acceleration to be set should be getLinearVelocity/Acceleration(Frame::World(),Frame::World())?

Yep, that’s how you should set the frame properties.

i want to simulate under a body’s non-inertial frame

I’m not quite sure what you mean by this or how you want to accomplish it. The simulation calculated within DART will always be performed within the inertial “world” frame. But if you have your own separate simulation that takes a reference frame as input, then this approach should work.

Thank you.
I understand that dart is simulating under a world inertial reference of frame.
Yes, i need a reference frame as input to my own separate simulation.

I just wonder this simple frame works equally as the original frame, that is, the bodyNode’s spatial velocity under the origin frame is correctly transformed to the spatial velocity under this non-rotating simple frame.

In short, are these two frames describes the same state of the bodyNode , under the implementation we discussed above.

do i have to set the simple frame’s mAmWorld as True? Because i wish to get a bodyNode’s spatialVelocity with respect to this simple frame, and through reading the source code of Frame.cpp, i find there are branches relating to the WorldFrame judgement.

The mAmWorld field is a special field whose value is false for every Frame except the world frame (which is retrieved using Frame::World(). No other Frame is allowed to set that field to true. This is done to short-circuit unnecessary calculations when asking for states relative to the static “world frame”.

So you mean that i have no need to set the mAmWorld?
Currently, to construct a frame that stick with certain bodyNode’s Translation, i set the translation, linearVelocity,LinearAcceleration.
But when i got a point’s velocity on that bodyNode w.r.t. the created simple Frame, it seems to still have a world linear velocity…

i mean it should show an relative angular speed, right?

Here’s my implementation

this->ref_Frame =std::make_shared< dart::dynamics::SimpleFrame>();
this->ref_Frame->setParentFrame(dart::dynamics::Frame::World());
dart::dynamics::Frame * frame  = this->linkPtr;
this->ref_Frame->setTranslation(frame->getWorldTransform().translation());
this->ref_Frame->setClassicDerivatives(
    frame->getLinearVelocity(),
    Eigen::Vector3d::Zero(),
    frame->getLinearAcceleration(),
    Eigen::Vector3d::Zero()
  );

And i got velocity using

linkPtr->getLinearVelocity(
linkPtr->getWorldTransform.inverse()*PointInWorld,
this->ref_Frame,
dart::dynamics::Frame::World());

You can find the relevant calculations being done here.

From what you’ve shown, and looking at the math in the block of code that I linked, I believe that the result you get from

linkPtr->getLinearVelocity(
  linkPtr->getWorldTransform.inverse()*PointInWorld,
  this->ref_Frame,
  dart::dynamics::Frame::World());

should indeed simply be angular_velocity x offset where offset is linkPtr->getWorldTransform().inverse()*PointInWorld. If offset is zero or angular_velocity is zero, then I would expect a {0, 0, 0} to be returned. I don’t know how the world linear velocity would be getting returned.

The only thing I can think of suggesting is to print out all of the values and compare it to calculations done by hand to see where a discrepancy might exist.

thank you, i found some problem, you are exactly correct