Weighting, activation/deactivating contacts =========================================== Weighting contact ----------------- By default, forces and moments generated by the solver have no cost (they are however internally weighted by the problem solver to make the problem feasible). If you want to mitigate the forces produced by a specific contact, you can use the :func:`weight_forces ` attribute. For unilateral contacts, you can use :func:`weight_tangentials ` attribute to discourage high tangential forces. .. admonition:: Example: unweighted tangential forces .. video:: https://github.com/Rhoban/placo-examples/raw/master/dynamics/videos/quadruped.mp4 :autoplay: :muted: :loop: In this example, the tangential forces are not weighted. :example:`dynamics/quadruped.py` .. admonition:: Example: weighting tangential forces .. video:: https://github.com/Rhoban/placo-examples/raw/master/dynamics/videos/quadruped_weight_tangentials.mp4 :autoplay: :muted: :loop: By passing ``--weight_tangentials`` to the quadruped example, the tangential forces are weighted with a cost of :math:`10^{-4}`. This results in contact forces that are more normal to the contact surface. :example:`dynamics/quadruped.py` For planar and fixed contacts, you can use the :func:`weight_moments ` attribute to discourage high moments. .. admonition:: Sigmaban humanoid .. video:: https://github.com/Rhoban/placo-examples/raw/master/dynamics/videos/sigmaban.mp4 :autoplay: :muted: :loop: In this example, the moments are weighted using :func:`weight_moments ` to encourage the center of pressure to be at the center of the foot. :example:`dynamics/sigmaban.py` Activating/desactivating or removing contacts --------------------------------------------- Contacts can change during the simulation. You can activate or deactivate a contact by setting the :func:`active ` attribute: .. code-block:: python # At initialization right_contact = solver.add_planar_contact(rightFoot_task) ... # During execution, contact can be activated or deactivated right_contact.active = False .. admonition:: Sigmaban humanoid .. video:: https://github.com/Rhoban/placo-examples/raw/master/dynamics/videos/sigmaban.mp4 :autoplay: :muted: :loop: In the Sigmaban example again, the right foot contact is activated and deactivated during the motion :example:`dynamics/sigmaban.py` You can also remove a contact by using :func:`remove_contact `: .. code-block:: python # Remove the right foot contact solver.remove_contact(right_contact)