|
27 | 27 | "metadata": {}, |
28 | 28 | "outputs": [], |
29 | 29 | "source": [ |
30 | | - "# Workaround for: https://github.com/JuliaRobotics/RigidBodyDynamics.jl/issues/500\n", |
31 | | - "using LinearAlgebra; BLAS.set_num_threads(1)" |
| 30 | + "using LinearAlgebra\n", |
| 31 | + "# Try to load something faster than OpenBLAS\n", |
| 32 | + "try using AppleAccelerate catch e; end\n", |
| 33 | + "try using MKL catch e; end\n", |
| 34 | + "BLAS.get_config()" |
32 | 35 | ] |
33 | 36 | }, |
34 | 37 | { |
|
37 | 40 | "metadata": {}, |
38 | 41 | "outputs": [], |
39 | 42 | "source": [ |
40 | | - "using KNITRO\n", |
| 43 | + "# using KNITRO\n", |
41 | 44 | "using MeshCat\n", |
42 | 45 | "using RigidBodyDynamics" |
43 | 46 | ] |
44 | 47 | }, |
| 48 | + { |
| 49 | + "cell_type": "code", |
| 50 | + "execution_count": null, |
| 51 | + "metadata": {}, |
| 52 | + "outputs": [], |
| 53 | + "source": [ |
| 54 | + "# Load the pre-compiled binaries of Coin HSL routines\n", |
| 55 | + "HSL_jll_path = expanduser(\"~/HSL_jll.jl-2023.5.26\")\n", |
| 56 | + "Pkg.develop(path=HSL_jll_path)\n", |
| 57 | + "import HSL_jll" |
| 58 | + ] |
| 59 | + }, |
45 | 60 | { |
46 | 61 | "cell_type": "code", |
47 | 62 | "execution_count": null, |
|
71 | 86 | "metadata": {}, |
72 | 87 | "outputs": [], |
73 | 88 | "source": [ |
74 | | - "robot = TORA.create_robot_kuka_iiwa_14(vis)\n", |
75 | | - "problem = TORA.Problem(robot, 301, 1/150)\n", |
| 89 | + "robot = TORA.create_robot_franka(\"panda_arm\", vis)\n", |
| 90 | + "# robot = TORA.create_robot_kinova_gen2(\"j2s6s200\", vis)\n", |
| 91 | + "# robot = TORA.create_robot_kinova_gen3(\"gen3_robotiq_2f_140\", vis)\n", |
| 92 | + "# robot = TORA.create_robot_kuka(\"iiwa14\", vis)\n", |
| 93 | + "# robot = TORA.create_robot_ur(\"ur10e\", vis)\n", |
| 94 | + "\n", |
| 95 | + "problem = TORA.Problem(robot, 2001, 1/1000)\n", |
76 | 96 | "\n", |
77 | 97 | "# Constrain initial and final joint velocities to zero\n", |
78 | 98 | "TORA.fix_joint_velocities!(problem, robot, 1, zeros(robot.n_v))\n", |
|
90 | 110 | "\n", |
91 | 111 | " for k = 1:2:problem.num_knots\n", |
92 | 112 | " θ = CubicTimeScaling(problem.num_knots - 1, k - 1) * 2π\n", |
93 | | - " pos = [0.5, 0.2 * cos(θ), 0.8 + 0.2 * sin(θ)]\n", |
| 113 | + " # pos = [0.5, 0.2 * cos(θ), 0.8 + 0.2 * sin(θ)] # UR10e\n", |
| 114 | + " pos = [0.4, 0.2 * cos(θ), 0.7 + 0.2 * sin(θ)] # Franka Emika\n", |
94 | 115 | " # pos = [0.5, 0.3 * sin(θ) + 0.1 * sin(8 * θ), 0.8 + 0.3 * cos(θ) + 0.1 * cos(8 * θ)]\n", |
95 | 116 | " TORA.constrain_ee_position!(problem, k, pos)\n", |
96 | 117 | " end\n", |
|
105 | 126 | "metadata": {}, |
106 | 127 | "outputs": [], |
107 | 128 | "source": [ |
108 | | - "initial_q = [0, 0, 0, -π/2, 0, 0, 0]\n", |
| 129 | + "initial_q = zeros(robot.n_q)\n", |
| 130 | + "# initial_q = [0, 0, 0, -π/2, 0, 0, 0]\n", |
| 131 | + "initial_q = [0, -π/4, 0, -3π/4, 0, π/2, 0] # Franka Emika\n", |
| 132 | + "# initial_q = [0, -120, 120, -180, -90, 0] .|> deg2rad # UR10e\n", |
| 133 | + "# initial_q = x[1:7]\n", |
109 | 134 | "\n", |
110 | 135 | "zero!(robot.state)\n", |
111 | 136 | "set_configuration!(robot.state, initial_q)\n", |
|
130 | 155 | "use_inv_dyn = true\n", |
131 | 156 | "minimise_τ = false\n", |
132 | 157 | "\n", |
| 158 | + "user_options = Dict(\n", |
| 159 | + " # === Termination === # https://coin-or.github.io/Ipopt/OPTIONS.html#OPT_Termination\n", |
| 160 | + " # \"tol\" => 10e-2, # default: 10e-8\n", |
| 161 | + " # \"max_cpu_time\" => 4.0, # default: 10e20\n", |
| 162 | + " # \"constr_viol_tol\" => 0.1, # default: 0.0001\n", |
| 163 | + " # \"acceptable_tol\" => 0.1, # default: 10e-6\n", |
| 164 | + " # \"acceptable_constr_viol_tol\" => 0.1, # default: 0.01\n", |
| 165 | + "\n", |
| 166 | + " # === Output === # https://coin-or.github.io/Ipopt/OPTIONS.html#OPT_Output\n", |
| 167 | + " # \"print_level\" => 0, # [0, 12], default: 5\n", |
| 168 | + " \n", |
| 169 | + " # === NLP Scaling === # https://coin-or.github.io/Ipopt/OPTIONS.html#OPT_NLP_Scaling\n", |
| 170 | + " # \"nlp_scaling_method\" => \"none\", # none, user-scaling, gradient-based (default), equilibration-based\n", |
| 171 | + "\n", |
| 172 | + " # === Warm Start === # https://coin-or.github.io/Ipopt/OPTIONS.html#OPT_Warm_Start\n", |
| 173 | + " # \"warm_start_init_point\" => \"yes\",\n", |
| 174 | + " # \"warm_start_same_structure\" => \"yes\",\n", |
| 175 | + " # \"warm_start_entire_iterate\" => \"yes\",\n", |
| 176 | + "\n", |
| 177 | + " # === Barrier Parameter Update === # https://coin-or.github.io/Ipopt/OPTIONS.html#OPT_Barrier_Parameter_Update\n", |
| 178 | + " \"mu_strategy\" => \"adaptive\", # monotone (default), adaptive\n", |
| 179 | + " # \"mu_oracle\" => \"loqo\", # probing, loqo, quality-function (default)\n", |
| 180 | + "\n", |
| 181 | + " # === Linear Solver === # https://coin-or.github.io/Ipopt/OPTIONS.html#OPT_Linear_Solver\n", |
| 182 | + " \"linear_solver\" => \"ma57\", # ma27 (default), ma57, ma77, ma86, ma97, (...)\n", |
| 183 | + " # \"ma57_pre_alloc\" => 1.10, # [1, Inf), 1.05 (default)\n", |
| 184 | + "\n", |
| 185 | + " # === Step Calculation === # https://coin-or.github.io/Ipopt/OPTIONS.html#OPT_Step_Calculation\n", |
| 186 | + " # \"mehrotra_algorithm\" => \"yes\", # yes, no (default)\n", |
| 187 | + " \"fast_step_computation\" => \"yes\", # yes, no (default)\n", |
| 188 | + "\n", |
| 189 | + " # === Hessian Approximation === # https://coin-or.github.io/Ipopt/OPTIONS.html#OPT_Hessian_Approximation\n", |
| 190 | + " \"hessian_approximation\" => \"limited-memory\", # exact (default), limited-memory\n", |
| 191 | + " # \"hessian_approximation_space\" => \"all-variables\", # nonlinear-variables (default), all-variables\n", |
| 192 | + "\n", |
| 193 | + " # === Derivative Checker === # https://coin-or.github.io/Ipopt/OPTIONS.html#OPT_Derivative_Checker\n", |
| 194 | + " # \"derivative_test\" => \"first-order\", # none, first-order, second-order, only-second-order\n", |
| 195 | + ")\n", |
| 196 | + "\n", |
133 | 197 | "# Choose which solver you want to use:\n", |
134 | 198 | "solve = TORA.solve_with_ipopt # Uses Ipopt (https://github.com/coin-or/Ipopt)\n", |
135 | 199 | "# solve = TORA.solve_with_knitro # Uses KNITRO (https://www.artelys.com/solvers/knitro/)\n", |
|
138 | 202 | "cpu_time, x, solver_log = solve(problem, robot,\n", |
139 | 203 | " initial_guess=initial_guess,\n", |
140 | 204 | " use_inv_dyn=use_inv_dyn,\n", |
141 | | - " minimise_τ=minimise_τ)" |
| 205 | + " minimise_τ=minimise_τ,\n", |
| 206 | + " user_options=user_options)" |
142 | 207 | ] |
143 | 208 | }, |
144 | 209 | { |
|
162 | 227 | { |
163 | 228 | "cell_type": "code", |
164 | 229 | "execution_count": null, |
165 | | - "metadata": {}, |
| 230 | + "metadata": { |
| 231 | + "tags": [] |
| 232 | + }, |
166 | 233 | "outputs": [], |
167 | 234 | "source": [ |
168 | 235 | "TORA.plot_log(solver_log)" |
|
171 | 238 | ], |
172 | 239 | "metadata": { |
173 | 240 | "kernelspec": { |
174 | | - "display_name": "Julia 1.7.2", |
| 241 | + "display_name": "Julia 1.10.2", |
175 | 242 | "language": "julia", |
176 | | - "name": "julia-1.7" |
| 243 | + "name": "julia-1.10" |
177 | 244 | }, |
178 | 245 | "language_info": { |
179 | 246 | "file_extension": ".jl", |
180 | 247 | "mimetype": "application/julia", |
181 | 248 | "name": "julia", |
182 | | - "version": "1.7.2" |
| 249 | + "version": "1.10.2" |
183 | 250 | } |
184 | 251 | }, |
185 | 252 | "nbformat": 4, |
|
0 commit comments