Playing mini-golf recently, I realized that my protractor can only help me so far since it can't calculate the speed of the swing needed. I decided a more sophisticated tool was needed and modeled a trick-shot in MapleSim.

To start, I laid out the obstacles, the ball and club, the ground, and some additional visualizations in the MapleSim environment.

When running the simulation, my first result wasn't even close to the hole (similar to when I play in real life!).

The model clearly needed to be optimized. I went to the Optimization app in MapleSim (this can be found under Add Apps or Templates on the left hand side).

Inside the app I clicked "Load System" then selected the parameters I wanted to optimize.

For this case, I'm optimizing 's' (the speed of the club) and 'theta' (the angle of the club). For the Objective Function I added a Relative Translation Sensor to the model and attached a probe to the Vector Norm of the output.

Inside the app, I switched to the Objective Function section. Selecting Probes, I added the new probe as the Objective Function by giving it a weight of 1.

Scrolling down to "Execute Parameter Optimization", I checked the "Use Global Optimization Toolbox" checkbox, and clicked Run Parameter Optimization.

Following a run time of 120 seconds, the app returns the graph of the objective function.

Below the plot, optimal values for the parameters are given. Plugging these back into the parameter block for the simulation we see that the ball does in fact go into the hole. Success!

Mini_golf_Global_Optimization.msim