Skip to content

Commit

Permalink
Systems with an enormous number of legs now walks fine.
Browse files Browse the repository at this point in the history
  • Loading branch information
HugoFara committed Jun 25, 2021
1 parent 34aad8c commit 471a57f
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions leggedsnake/physicsengine.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,14 @@
def set_space_constraints(space):
"""Set the solver if they are many constraints."""
constraints = space.constraints
len_c = len(space.constraints)
# Number of iteration can be adapted
# space.iterations = min(10, int(np.exp(len(c)/12)))
# space.collision_slop = .5
# space.collision_bias = (1 - .1 * np.exp(-len(c) / 50)) ** 60
# Ugly way to prevent linkages to bounce on the ground
# space.damping = .9
space.iterations = int(10 * np.exp(len_c / 60))
for constraint in constraints:
if not isinstance(constraint, pm.SimpleMotor) and False:
constraint.max_force = params["physics"]["max_force"] * (np.exp(
- len(constraints) / 25) / 2 + .5)
# constraint.error_bias = (1 - .1 * np.exp(-len(c) / 50)) ** 60
- len_c / 25) / 2 + .5)
constraint.error_bias = (1 - .1 * np.exp(-len_c / 60)) ** 60


class World:
Expand Down

0 comments on commit 471a57f

Please sign in to comment.