Just gonna dump this draft out there since I’ve moved on (I’ll edit this if I come back to it). You can embed collisions in mixed integer programming. I did it below using a strong acceleration force that turns on when you enter the floor. What this corresponds to is a piecewise linear potential barrier.

Such a formulation might be interesting for the trajectory optimization of shooting a hoop, playing Pachinko, Beer Pong, or Pinball.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
using JuMP using Cbc using Plots N = 50 T = 5 dt = T/N m = Model(solver=CbcSolver()) @variable(m, x[1:N]) # , Bin @variable(m, v[1:N]) # , Bin @variable(m, f[1:N-1]) @variable(m, a[1:N-1], Bin) # , Bin @constraint(m, x[1] == 1) @constraint(m, v[1] == 0) M = 10 for t in 1:N-1 @constraint(m, x[t+1] == x[t] + dt*v[t]) @constraint(m, v[t+1] == v[t] + dt*(10*(1-a[t])-1)) #@constraint(m, v[t+1] == v[t] + dt*(10*f[t]-1)) @constraint(m, M * a[t] >= x[t+1]) #if on the next step projects into the earth @constraint(m, M * (1-a[t]) >= -x[t+1]) #@constraint(m, f[t] <= M*(1-a[t])) # we allow a bouncing force end k = 10 # @constraint(m, f .>= 0) # @constraint(m, f .>= - k * x[2:N]) # @constraint(m, x[:] .>= 0) E = 1 #sum(f) # 1 #sum(x) #sum(f) # + 10*sum(x) # sum(a) @objective(m, Min, E) solve(m) println(x) println(getvalue(x)) plotly() plot(getvalue(x)) #plot(getvalue(a)) gui() |

More things to consider:

Is this method trash? Yes. You can actually embed the mirror law of collisions directly without needing to using a funky barrier potential.

You can extend this to ball trapped in polygon, or a ball that is restricted from entering obstacle polygons. Check out the IRIS project – break up region into convex regions

https://github.com/rdeits/ConditionalJuMP.jl Gives good support for embedding conditional variables.

https://github.com/joehuchette/PiecewiseLinearOpt.jl On a related note, gives a good way of defining piecewise linear functions using Mixed Integer programming.

Pajarito is another interesting Julia project. A mixed integer convex programming solver.

Russ Tedrake papers – http://groups.csail.mit.edu/locomotion/pubs.shtml

Break up obstacle objects into delauney triangulated things.

www.mit.edu/~jvielma/presentations/MINLPREPSOLJUL_NORTHE18.pdf