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.
rookielittlep opened this issue · 1 comments
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
- Using the getFromDef function to get the robot node
- then using getField ("translation") to get the translation field
- setting the position with setSFVec3f, and getting the position of the robot with getPosition
- 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.
env
Windows 11, webots2023b
Set the acceleration of gravity to 0 and restart webots to solve this problem. I don't know the specific reason.