webots icon indicating copy to clipboard operation
webots copied to clipboard

There is an error between the actual value and the set value when setting the position of the robot with the supervisor in webots 2023b.

Open rookielittlep opened this issue 1 year ago • 1 comments
trafficstars

Describe the Bug In webots 2023b, programming in C ++, Use the supervisor's function to set the position of the robot, but the actual position is inconsistent with the desired position.

Steps to Reproduce

  1. Using the getFromDef function to get the robot node
  2. then using getField ("translation") to get the translation field
  3. setting the position with setSFVec3f, and getting the position of the robot with getPosition
  4. the results obtained are inconsistent. And the movement of the next frame is also inconsistent.

This is the relevant code Node* ROBOT = robot->getFromDef("ROBOT"); Field* ROBOTComPos = ROBOT ->getField("translation"); ROBOTComPos ->setSFVec3f(newpos); cout << "des pos:" << *newpos << " " << *(newpos + 1) << " " << *(newpos + 2) << endl; pos = ROBOT->getPosition(); cout <<"real pos" << *pos << " " << *(pos + 1) << " " << *(pos + 2) << endl;

Expected behavior Because a supervisor is used, the set position should be the same as the actual position, but the result is different.

Screenshots image

env Windows 11, webots2023b

rookielittlep avatar Jul 29 '24 16:07 rookielittlep

Set the acceleration of gravity to 0 and restart webots to solve this problem. I don't know the specific reason.

rookielittlep avatar Jul 30 '24 05:07 rookielittlep