-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
SoccerBall is moving after setting its position and resetting velocity #2899
Comments
Instead of setting the velocity to 0, you should reset the physics of the ball. |
I tried calling reset physics, but that had no effect on velocity the same problem occurs. |
Which Ball proto do you use? Some of them have an offset for the center of mass to provide some randomness in the motion, which makes that when you move them and want the ball to stay still you should also reset the rotation field of the ball, so that the offset of the center of mass will be vertical and won't generate an initial motion. Note: you may also remove this offset to the center of mass from the ball proto if not needed. Finally, you may also increase the Damping of the ball. |
The SoccerBall.proto has |
I checked and the SoccerBall.proto has no offset for the center of mass, so it shouldn't be a problem. |
Interesting. I'm using following code to move the ball: ball_translation_field = self.getFromDef("BALL").getField("translation")
ball_translation_field.setSFVec3f([x, y, z])
self.getFromDef("BALL").resetPhysics() And still does not work. :-/ |
I can reproduce the issue. The problem is that the A workaround that can be applied on the controller side is to reset the physics in the next simulation step, i.e. calling And I will fix this in the Webots code. |
Should be fixed in #2991. |
@stefaniapedrazzi I just tested this and seems like it did not resolve the issue :/ The ball is still moving after being moved by supervisor. |
@Adman: can you please upload a simplified project (a simple world with just one ball) and a supervisor process that shows the problem. If we can reproduce the problem, we will try to fix it. |
@omichel Sorry for late reply. Here's the simplified project just with the ball and supervisor, who moves the ball to a random position every 6 seconds. |
Thank you for this. I could reproduce the problem. Meanwhile, I found a little trick to minimize the reaction motion and almost fix the problem in your example. The trick is simply to reset twice the ball position and physics: import random
from controller import Supervisor
sup = Supervisor()
ball = sup.getFromDef("BALL")
time = 1
while sup.step(64) != -1:
time += 64 / 1000.0
if int(time % 6) == 0:
time += 1
# move the ball
x = random.uniform(-0.6, 0.6)
z = random.uniform(-0.5, 0.5)
ball_translation_field = ball.getField("translation")
translation = ball_translation_field.getSFVec3f()
print(translation)
for i in range(2):
ball_translation_field.setSFVec3f([x, translation[1], z])
ball.resetPhysics()
sup.step(64) |
I can reproduce this issue but not systematically. But sometimes it works perfectly well. Some observations so far:
|
@BenjaminDeleze We have similar problem with robots when they are being relocated while running at high speed - robocup-junior/rcj-soccersim#130 . Do you think it could be related to this issue? We tested the workaround by resetting the physics in two consecutive steps, which helped to reduce the problem. |
I will have a look |
I can reproduce the bug, but I am not sure it is related to this issue. I will continue to investigate |
@Adman I made some tests on my side and I don't think it is a bug of the reset but more a problem of timestep and collision. Anyway, I found a quick fix by changing the z-value of my robot such that it is already in contact with the floor when relocating it. |
We tried several different values robocup-junior/rcj-soccersim#130 (comment) , but the problem still persists. Are your robots running at high speed (i.e. 10) ? |
yes, I tested it with a speed of 10. |
We tested it and according to @RichoM it works better. |
Describe the Bug
When we manually set the position of the ball and subsequently reset its velocity, ball keeps moving very slowly. Seems like some force is not reset or paused in background while moving the object.
Steps to Reproduce
a)
self.getFromDef("BALL").getField("translation").setSFVec3f([x, y, z])
b)
self.getFromDef("BALL").setVelocity([0, 0, 0, 0, 0, 0])
Expected behavior
The ball should have zero velocity (not moving at all).
Video
soccer.mp4
System
Additional context
If I print the velocity using
getVelocity()
method after setting it to zero, the velocity is non-zero.Workaround
There is a workaround to tackle this problem: set the velocity to zero in two subsequent steps.
The text was updated successfully, but these errors were encountered: