Capture a series of Kangaroo simulations

Here I use @DanielPiker’s rigid body collisions example as a reference. I have a list of box sizes and I want to run a Kangaroo simulation for each size and capture the viewport when the solver has converged according to my prescribed threshold.

I am having trouble implementing how I step through my data set. I want to use Rhino.RhinoApp.Idle with a callback function that captures the viewport and resets the solver. However, it seems like every iteration in Kangaroo triggers the same event as well, so the solver is reset before it has a chance to run to completion. Is there a way to create a new event that detects if Rhino has been idle for a set amount of time (around 10s perhaps) instead?

I am using a simple time-based trigger in the meantime: (47.3 KB)

Hi @hkit.yong
To avoid using the normal Kangaroo updating of iterations, you can call the Kangaroo solver from a script like this: (33.3 KB)

(this is similar to the example I posted here )

This way Kangaroo will perform a set number of iterations, or until a certain energy threshold, only outputting the final result, all within a single Grasshopper solve iteration (and if the input has multiple data branches, each branch will be a separate instance of the physics solver).
Just be careful of setting the maxIterations too high, or you could get stuck waiting a long time. Some types of simulation might look like they stop moving quickly when using the regular solver component, but continue to move a tiny amount for a while so they could still take many iterations to fully converge if the energy threshold convergence setting is low. Multiply this by all the data paths and it could easily add up to many minutes.

1 Like

This worked like a charm, thanks! This lead me into looking up Kangaroo scripting as well which looks pretty cool. I’ll look into more examples!

1 Like

@DanielPiker, the multisolve solution is really amazing (should be a standard solver IMO)

There is sth curious, however:

The C# component seems to handle iterations differently… It seems that it undergoes many more subiterations per iteration. To achieve the same result and computation time, I had to set the Zombie Solver to 400 iterations and the Custom Solver to 32.

I could not find any “sub-iterations”, or similar, in the code…

Could you explain the difference?

Thanks a lot,