raisimTech / raisimLib

Visit www.raisim.com
http://www.raisim.com
Other
341 stars 91 forks source link

value of getNonlinearities when called multiple times #475

Closed loewt closed 1 year ago

loewt commented 1 year ago

Hi, when I call getNonlinearities() the return value changes with each call, even there is no call to integrateWorld() in between. This has been an issue since v1.1.7, so when using e.g. v1.1.5 the value remains the same as expected.

Here is a minimal example that creates the issue on system (linux), the system is the Franka Emika Panda robot:

int main(int argc, char **argv) { raisim::World::setActivationKey("key....");

raisim::World world;
world.addGround(0, "gnd");

raisim::ArticulatedSystem *system = world.addArticulatedSystem("urdf...");

Eigen::VectorXd position = Eigen::VectorXd::Zero(9);
Eigen::VectorXd velocity = Eigen::VectorXd::Zero(9);

position << -0.0, -0.075, 0.0, -2.0, 0.0, 1.95, -0.75, 0.0, 0.0;

system->setGeneralizedCoordinate(position);
system->setGeneralizedVelocity(velocity);

for (unsigned i = 0; i < 50; ++i)
{
    std::cout << system->getNonlinearities(world.getGravity()) << std::endl;
}

}

The output of this is: 0 -27.6242 -0.0708329 22.7964 0.626924 2.3484 6.51542e-05 0.00367606 -0.00367606 0 -55.2484 -0.141666 45.5928 1.25385 4.6968 0.000130308 0.00735212 -0.00735212 0 -82.8726 -0.212499 68.3892 1.88077 7.04521 0.000195463 0.0110282 -0.0110282 0 -110.497 -0.283332 91.1856 2.5077 9.39361 0.000260617 0.0147042 -0.0147042 0 -138.121 -0.354165 113.982 3.13462 11.742 0.000325771 0.0183803 -0.0183803 0 -165.745 -0.424998 136.778 3.76154 14.0904 0.000390925 0.0220564 -0.0220564 0 -193.369 -0.495831 159.575 4.38847 16.4388 0.000456079 0.0257324 -0.0257324 0 -220.993 -0.566663 182.371 5.01539 18.7872 0.000521234 0.0294085 -0.0294085 0 -248.618 -0.637496 205.168 5.64232 21.1356 0.000586388 0.0330846 -0.0330846 0 -276.242 -0.708329 227.964 6.26924 23.484 0.000651542 0.0367606 -0.0367606 0 -303.866 -0.779162 250.76 6.89616 25.8324 0.000716696 0.0404367 -0.0404367 0 -331.49 -0.849995 273.557 7.52309 28.1808 0.00078185 0.0441127 -0.0441127 0 -359.114 -0.920828 296.353 8.15001 30.5292 0.000847005 0.0477888 -0.0477888 0 -386.739 -0.991661 319.15 8.77694 32.8776 0.000912159 0.0514649 -0.0514649 0 -414.363 -1.06249 341.946 9.40386 35.226 0.000977313 0.0551409 -0.0551409 0 -441.987 -1.13333 364.742 10.0308 37.5744 0.00104247 0.058817 -0.058817 0 -469.611 -1.20416 387.539 10.6577 39.9228 0.00110762 0.0624931 -0.0624931 0 -497.235 -1.27499 410.335 11.2846 42.2712 0.00117278 0.0661691 -0.0661691 0 -524.86 -1.34583 433.132 11.9116 44.6196 0.00123793 0.0698452 -0.0698452 0 -552.484 -1.41666 455.928 12.5385 46.968 0.00130308 0.0735212 -0.0735212 0 -580.108 -1.48749 478.724 13.1654 49.3164 0.00136824 0.0771973 -0.0771973 0 -607.732 -1.55832 501.521 13.7923 51.6648 0.00143339 0.0808734 -0.0808734 0 -635.356 -1.62916 524.317 14.4193 54.0132 0.00149855 0.0845494 -0.0845494 0 -662.98 -1.69999 547.113 15.0462 56.3616 0.0015637 0.0882255 -0.0882255 0 -690.605 -1.77082 569.91 15.6731 58.71 0.00162886 0.0919016 -0.0919016 0 -718.229 -1.84166 592.706 16.3 61.0585 0.00169401 0.0955776 -0.0955776 0 -745.853 -1.91249 615.503 16.9269 63.4069 0.00175916 0.0992537 -0.0992537 0 -773.477 -1.98332 638.299 17.5539 65.7553 0.00182432 0.10293 -0.10293 0 -801.101 -2.05416 661.095 18.1808 68.1037 0.00188947 0.106606 -0.106606 0 -828.726 -2.12499 683.892 18.8077 70.4521 0.00195463 0.110282 -0.110282 0 -856.35 -2.19582 706.688 19.4346 72.8005 0.00201978 0.113958 -0.113958 0 -883.974 -2.26665 729.485 20.0616 75.1489 0.00208493 0.117634 -0.117634 0 -911.598 -2.33749 752.281 20.6885 77.4973 0.00215009 0.12131 -0.12131 0 -939.222 -2.40832 775.077 21.3154 79.8457 0.00221524 0.124986 -0.124986 0 -966.847 -2.47915 797.874 21.9423 82.1941 0.0022804 0.128662 -0.128662 0 -994.471 -2.54999 820.67 22.5693 84.5425 0.00234555 0.132338 -0.132338 0 -1022.09 -2.62082 843.467 23.1962 86.8909 0.00241071 0.136014 -0.136014 0 -1049.72 -2.69165 866.263 23.8231 89.2393 0.00247586 0.13969 -0.13969 0 -1077.34 -2.76248 889.059 24.45 91.5877 0.00254101 0.143366 -0.143366 0 -1104.97 -2.83332 911.856 25.077 93.9361 0.00260617 0.147042 -0.147042 0 -1132.59 -2.90415 934.652 25.7039 96.2845 0.00267132 0.150719 -0.150719 0 -1160.22 -2.97498 957.449 26.3308 98.6329 0.00273648 0.154395 -0.154395 0 -1187.84 -3.04582 980.245 26.9577 100.981 0.00280163 0.158071 -0.158071 0 -1215.46 -3.11665 1003.04 27.5847 103.33 0.00286678 0.161747 -0.161747 0 -1243.09 -3.18748 1025.84 28.2116 105.678 0.00293194 0.165423 -0.165423 0 -1270.71 -3.25832 1048.63 28.8385 108.026 0.00299709 0.169099 -0.169099 0 -1298.34 -3.32915 1071.43 29.4654 110.375 0.00306225 0.172775 -0.172775 0 -1325.96 -3.39998 1094.23 30.0924 112.723 0.0031274 0.176451 -0.176451 0 -1353.59 -3.47081 1117.02 30.7193 115.072 0.00319256 0.180127 -0.180127 0 -1381.21 -3.54165 1139.82 31.3462 117.42 0.00325771 0.183803 -0.183803

jhwangbo commented 1 year ago

do you have the latest version? this error has been fixed recently

loewt commented 1 year ago

yes, I have the latest version, I freshly cloned the repository to make sure this is the commit hash that I am using: 294441bb4495135803c90b5b60ac91b0649b40c7

jhwangbo commented 1 year ago

Do you use Linux? I pushed a fix for the linux version. The issue was on fixed-based robots. Other OS's fixes will follow

loewt commented 1 year ago

yes I use Linux, this works, thank you!