Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Symmetry unittest #1193

Closed
JiazhengSun opened this issue Nov 10, 2018 · 3 comments
Closed

Symmetry unittest #1193

JiazhengSun opened this issue Nov 10, 2018 · 3 comments

Comments

@JiazhengSun
Copy link

JiazhengSun commented Nov 10, 2018

This is the unittest I did to check symmetry.

class SymTest : public testing::Test
{
  public:
    void AngularVelAdd();
  protected:
};

void SymTest::AngularVelAdd()
{
  WorldPtr world = World::create();
  EXPECT_TRUE(world != nullptr);
  world->setGravity(Vector3d(0.0, -10.0, 0.0));
  world->setTimeStep(0.001);

  SkeletonPtr sphereSkel = createSphere(0.05, Vector3d(0.0, 1.0, 0.0));
  BodyNode* sphere = sphereSkel->getBodyNode(0);
  Joint* sphereJoint = sphere->getParentJoint();
  sphereJoint->setVelocity(0, 10.0);  // ang_x -> Affect lz and ly
  sphereJoint->setVelocity(1, 10.0);  // ang_y -> No effect
  sphereJoint->setVelocity(2, 10.0);  // ang_z -> Affect lx and ly
  world->addSkeleton(sphereSkel);

  Eigen::Vector3d LinearVelBefore = sphere->getLinearVelocity(); //Get linear velocity 

  cout<<"Linear Velocity before running is "<< LinearVelBefore.transpose()<<endl;

  int maxSteps = 500;
  for (int i = 0; i < maxSteps; i++)
  {
    //cout<<"linear Z is: "<<sphere->getLinearVelocity()[2]<<endl;
    world->step();
  }

  Vector3d LinearVelAfter = sphere->getLinearVelocity(); // Get linear velocity
  cout<<"Linear Velocity after running is "<<LinearVelAfter.transpose()<<endl;
  double lx = LinearVelAfter[0];
  //double ly = LinearVelAfter[1];
  double lz = LinearVelAfter[2];

  EXPECT_EQ(lx, 0.0);
  //EXPECT_EQ(ly, 0.0);
  EXPECT_EQ(lz, 0.0);
}

TEST_F(SymTest, AngularVelAdd)
{
  AngularVelAdd();
}
@jslee02
Copy link
Member

jslee02 commented Nov 10, 2018

Thank you for sharing the test code. Let me investigate this.

@azeey
Copy link
Contributor

azeey commented Mar 7, 2020

I believe PR #1437 fixes this. I've added a regression test based on @JiazhengSun's code.

azeey added a commit to gazebo-forks/dart that referenced this issue Apr 2, 2020
azeey added a commit to gazebo-forks/dart that referenced this issue Apr 3, 2020
* Fix issue dartsim#1433

The main fix is in the expression used to integrate velocities. The
secondary fix is to update spatial accelerations after
integrating velocities and to update both spatial velocities and
accelerations after integrating positions.

* Add regression test for issue dartsim#1193

* Remove main in test, fix style
@jslee02
Copy link
Member

jslee02 commented Dec 19, 2021

Finally resolved by #1437

@jslee02 jslee02 closed this as completed Dec 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants