Returns +1 if the bricks separate under this force, and -1 otherwise.
(force)
| 64 | bound_attachment_frame = physics.bind(attachment_frame) |
| 65 | |
| 66 | def func(force): |
| 67 | """Returns +1 if the bricks separate under this force, and -1 otherwise.""" |
| 68 | with physics.model.disable('gravity'): |
| 69 | # Reset the simulation. |
| 70 | physics.reset() |
| 71 | # Get the initial height. |
| 72 | initial_height = bound_attachment_frame.xpos[2] |
| 73 | # Apply an upward force to the attachment frame. |
| 74 | bound_attachment_frame.xfrc_applied[2] = force |
| 75 | # Advance the simulation until either the height threshold or time limit |
| 76 | # is reached. |
| 77 | while physics.time() < time_limit: |
| 78 | physics.step() |
| 79 | distance_lifted = bound_attachment_frame.xpos[2] - initial_height |
| 80 | if distance_lifted > height_threshold: |
| 81 | return 1.0 |
| 82 | return -1.0 |
| 83 | |
| 84 | # Ensure that the min and max forces bracket the true separation force. |
| 85 | while func(min_force) > 0: |
searching dependent graphs…