loco-3d / crocoddyl

Crocoddyl is an optimal control library for robot control under contact sequence. Its solver is based on various efficient Differential Dynamic Programming (DDP)-like algorithms
BSD 3-Clause "New" or "Revised" License
854 stars 174 forks source link

Add Bounds to the Inequality Feasibility Calculation #1307

Closed aristotpap closed 1 month ago

aristotpap commented 2 months ago

This pull request introduces a refinement to the calculation of the inequality feasibility by adding the inequality bounds to the calculation. The update ensures that when a constraint is within its specified bounds, its feasibility is considered 0. Only if the constraint exceeds the bounds, its feasibility is greater than zero.

cmastalli commented 2 months ago

@aristotpap -- Also, do not forget to update our changelog.

aristotpap commented 2 months ago

Hi @cmastalli,

Thank you for the suggestions. I can definitely create a private member for g_adj, however we need to consider whether we want or not dynamic allocation during the calculations. A situation like this may arise if certain action models have different numbers of constraints. In these situations we have two alternatives as I see it:

  1. Dynamically resize the vector like below:

    g_adj_.resize(models[t]->ng).setZero()
  2. Find the maximum constraint dimension during the construction of the Shooting Problem and use part of the pre-allocated vector for the feasibility calculations, as below:

    g_adj_.resize(max_ng).setZero() # During the Construction of the Shooting Problem
    ...
    ...
    g_adj_.head(models[t]->ng) # Use during the calculations with models[t] -> ng <= max_ng

Let me know what you prefer according to Crocoddyl's requirements.

cmastalli commented 2 months ago

I don't like the idea of using a "max dimension". It seems to me that the best implementation is when we create a list of g_adj_ items and resize them when needed.

We have defined a resizeData function that is called every time the shooting problem is changed. Our MPC highly depends on it. For more details see: https://github.com/loco-3d/crocoddyl/blob/devel/src/core/solver-base.cpp#L68-L79.

Note that resizeData is a virtual function that can be specialized for any solver.

aristotpap commented 1 month ago

Hello @cmastalli,

I have implemented the requested changes and updated the CHANGELOG.md in the most recent commit. Let me know if there is anything else that requires my attention.