Skip to content

Commit

Permalink
Add update_previous_solution into the warm_start
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximilienNaveau committed Dec 9, 2024
1 parent b109535 commit 637222c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions agimus_controller/agimus_controller/mpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def run(self, initial_state: TrajectoryPoint, current_time_ns: int) -> OCPResult
)
timer3 = time.perf_counter_ns()
self._ocp.solve(x0, x_init, u_init)
self._warm_start.update_previous_solution(self._ocp.debug_data.result)
timer4 = time.perf_counter_ns()

# Extract the solution.
Expand Down
8 changes: 7 additions & 1 deletion agimus_controller/agimus_controller/warm_start_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,18 @@
class WarmStartBase(ABC):
def __init__(self) -> None:
super().__init__()
self._previous_solution: list[TrajectoryPoint] = list()

@abstractmethod
def generate(
self,
reference_trajectory: list[TrajectoryPoint],
previous_solution: list[TrajectoryPoint],
) -> tuple(np.ndarray, np.ndarray):
"""Returns x_init, u_init."""
...

def update_previous_solution(
self, previous_solution: list[TrajectoryPoint]
) -> None:
"""Stores internally the previous solution of the OCP"""
self._previous_solution = previous_solution

0 comments on commit 637222c

Please sign in to comment.