Skip to content

Commit

Permalink
Added to_function methods in planners
Browse files Browse the repository at this point in the history
  • Loading branch information
S-Dafarra committed Apr 12, 2024
1 parent 97d921c commit 298ee7f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
11 changes: 9 additions & 2 deletions src/hippopt/turnkey_planners/humanoid_kinodynamic/planner.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,16 @@ def __init__(self, settings: Settings) -> None:
)
)

optimization_solver = hp.OptiSolver(
self.optimization_solver = hp.OptiSolver(
inner_solver=self.settings.opti_solver,
problem_type=self.settings.problem_type,
options_solver=self.settings.casadi_solver_options,
options_plugin=self.settings.casadi_opti_options,
callback_criterion=opti_callback,
)
ocp_solver = hp.MultipleShootingSolver(optimization_solver=optimization_solver)
ocp_solver = hp.MultipleShootingSolver(
optimization_solver=self.optimization_solver
)

self.ocp = hp.OptimalControlProblem.create(
input_structure=self.variables,
Expand Down Expand Up @@ -1063,6 +1065,11 @@ def solve(self) -> hp.Output[Variables]:
output.values = self._undo_mass_regularization(output.values)
return output

def to_function(
self, name: str = "opti_function", options: dict = None
) -> cs.Function:
return self.optimization_solver.to_function(name=name, options=options)

def get_adam_model(self) -> adam.model.Model:
if self.parametric_model:
guess = self.ocp.problem.get_initial_guess()
Expand Down
9 changes: 7 additions & 2 deletions src/hippopt/turnkey_planners/humanoid_pose_finder/planner.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,15 +253,15 @@ def __init__(self, settings: Settings):
settings=self.settings, kin_dyn_object=self.kin_dyn_object
)

optimization_solver = hp.OptiSolver(
self.optimization_solver = hp.OptiSolver(
inner_solver=self.settings.opti_solver,
problem_type=self.settings.problem_type,
options_solver=self.settings.casadi_solver_options,
options_plugin=self.settings.casadi_opti_options,
)

self.op = hp.OptimizationProblem.create(
input_structure=structure, optimization_solver=optimization_solver
input_structure=structure, optimization_solver=self.optimization_solver
)

variables = self.op.variables # type: Variables
Expand Down Expand Up @@ -650,6 +650,11 @@ def set_references(self, references: References) -> None:
def solve(self) -> hp.Output[Variables]:
return self.op.problem.solve()

def to_function(
self, name: str = "opti_function", options: dict = None
) -> cs.Function:
return self.optimization_solver.to_function(name=name, options=options)

def get_adam_model(self) -> adam.model.Model:
if self.parametric_model:
guess = self.get_initial_guess()
Expand Down

0 comments on commit 298ee7f

Please sign in to comment.