acados_solver_ros2  main
Acados-based NMPC controllers for ROS2 control
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
acados::AcadosSolver Class Referenceabstract

Abstract C++ wrapper of generated Acados solver C-code. More...

#include <acados_solver.hpp>

Collaboration diagram for acados::AcadosSolver:
[legend]

Classes

class  Dimensions
 Container for the (fixed) dimensions of the imported Acados OCP. More...
 

Public Member Functions

 AcadosSolver ()
 Constructor of the AcadosSolver object. More...
 
virtual ~AcadosSolver ()
 Destructor of the AcadosSolver object. More...
 
int init (unsigned int N, double Ts)
 Initialize the solver and set the (constant) sampling intervals. More...
 
int reset ()
 Resets the Acados solver, including the internal QP solver and the RTI phase cache. More...
 
int solve ()
 Solve the non-linear optimization problem given the provided initial state, constraints, etc. More...
 
int set_initial_state_values (ValueVector &x_0)
 Set the initial state values (i.e., add constraints on initial state) More...
 
int set_initial_state_values (ValueMap const &x_0_map)
 Set the initial state values (i.e., add constraints on initial state) from a map of key/ValueVector pairs. More...
 
int set_state_bounds (unsigned int stage, IndexVector &idxbx, ValueVector &lbx, ValueVector &ubx)
 Set (differential) state bounds at a given stage. More...
 
int set_state_bounds (IndexVector &idxbx, ValueVector &lbx, ValueVector &ubx)
 Set (differential) state bounds for all stages. More...
 
int set_control_bounds (unsigned int stage, IndexVector &idxbu, ValueVector &lbu, ValueVector &ubu)
 Set control bounds at a given stage. More...
 
int set_control_bounds (IndexVector &idxbu, ValueVector &lbu, ValueVector &ubu)
 Set control bounds for all stages. More...
 
int set_runtime_parameters (unsigned int stage, ValueVector &p_i)
 Set the runtime parameters for one stage from ordered value vector. More...
 
int set_runtime_parameters (unsigned int stage, ValueMap const &p_i_map)
 Set the runtime parameters for one stage from a key/values map. More...
 
int set_runtime_parameters (ValueVector &p_i)
 Set the runtime parameters for all stages at once from ordered value vector. More...
 
int set_runtime_parameters (ValueMap const &p_i_map)
 Set the runtime parameters for all stages at once from a key/values map. More...
 
int initialize_state_values (unsigned int stage, ValueVector &x_i)
 Initialize the (differential) state values for a stage from an ordered value vector. More...
 
int initialize_state_values (unsigned int stage, ValueMap const &x_i_map)
 Initialize the (differential) state values for a stage from a key/values map. More...
 
int initialize_state_values (ValueVector &x_i)
 Initialize the (differential) state values for ALL stages at once from an ordered value vector. More...
 
int initialize_state_values (ValueMap const &x_i_map)
 Initialize the (differential) state values for ALL stages at once from a key/values map. More...
 
int initialize_control_values (unsigned int stage, ValueVector &u_i)
 Initialize the control variable values for one stage from an ordered value vector. More...
 
int initialize_control_values (unsigned int stage, ValueMap const &u_i_map)
 Initialize the control variable values for one stage from a key/values map. More...
 
int initialize_control_values (ValueVector &u_i)
 Initialize the control variable values for ALL stages at once from an ordered value vector. More...
 
int initialize_control_values (ValueMap const &u_i_map)
 Initialize the control variable values for ALL stages at once from a key/values map. More...
 
ValueVector get_state_values (unsigned int stage)
 Retrieve the differential state variables at a given stage. More...
 
ValueMap get_state_values_as_map (unsigned int stage)
 Retrieve the differential state variables at a given stage and package them as a ValueMap. More...
 
ValueVector get_algebraic_state_values (unsigned int stage)
 Retrieve the algebraic state variables at a given stage. More...
 
ValueMap get_algebraic_state_values_as_map (unsigned int stage)
 Retrieve the algebraic state variables at a given stage and package them as a ValueMap. More...
 
ValueVector get_control_values (unsigned int stage)
 Retrieve the control variables at a given stage. More...
 
ValueMap get_control_values_as_map (unsigned int stage)
 Retrieve the control variables at a given stage and package them as a ValueMap. More...
 
const IndexMapx_index_map () const
 Returns a constant reference to the Key/IndexVector map of differential state variables internally stored in AcadosSolver::_x_index_map. More...
 
const IndexMapz_index_map () const
 Returns a constant reference to the Key/IndexVector map of algebraic state variables internally stored in AcadosSolver::_z_index_map. More...
 
const IndexMapp_index_map () const
 Returns a constant reference to the Key/IndexVector map of runtime parameters internally stored in AcadosSolver::_p_index_map. More...
 
const IndexMapu_index_map () const
 Returns a constant reference to the Key/IndexVector map of control variables internally stored in AcadosSolver::_u_index_map. More...
 
const Dimensionsdims () const
 Returns the (fixed) dimensions of the OCP problem stored in AcadosSolver::_dims. More...
 
unsigned int nx () const
 Returns the dimensions of the differential state vector. More...
 
unsigned int nz () const
 Returns the dimensions of the algebraic state vector. More...
 
unsigned int np () const
 Returns the number of runtime parameters. More...
 
unsigned int nu () const
 Returns the number of control variables. More...
 
unsigned int N () const
 Returns the number of shooting nodes. More...
 
double Ts () const
 Returns the (constant) sampling interval Ts (in seconds). More...
 
std::vector< double > sampling_intervals () const
 Returns the vector of sampling interval (in seconds). More...
 
virtual ocp_nlp_in * get_nlp_in () const =0
 Legacy C-function to retrieve the C-interface ocp_nlp_in property of the solver. More...
 
virtual ocp_nlp_out * get_nlp_out () const =0
 Legacy C-function to retrieve the C-interface ocp_nlp_out property of the solver. More...
 
virtual ocp_nlp_out * get_sens_out () const =0
 Legacy C-function to retrieve the C-interface ocp_nlp_out property of the solver. More...
 
virtual ocp_nlp_solver * get_nlp_solver () const =0
 Legacy C-function to retrieve the C-interface ocp_nlp_solver property of the solver. More...
 
virtual ocp_nlp_config * get_nlp_config () const =0
 Legacy C-function to retrieve the C-interface ocp_nlp_config property of the solver. More...
 
virtual void * get_nlp_opts () const =0
 Legacy C-function to retrieve the C-interface get_nlp_opts property of the solver. More...
 
virtual ocp_nlp_dims * get_nlp_dims () const =0
 Legacy C-function to retrieve the C-interface ocp_nlp_dims property of the solver that contains the dimensions of the problem. More...
 
virtual ocp_nlp_plan_t * get_nlp_plan () const =0
 Legacy C-function to retrieve the C-interface ocp_nlp_plan property of the solver. More...
 
virtual unsigned int get_nlp_np () const =0
 Legacy C-function to retrieve the number of runtime parameters from the Acados capsule. More...
 

Static Public Member Functions

static bool is_map_size_consistent (IndexMap const &index_map, unsigned int expected_total_indexes)
 Check if the total number of indexes contained in the provided index map is equal to an expected number. More...
 
static bool is_map_size_consistent (ValueMap const &values_map, unsigned int expected_total_indexes)
 Check if the total number of values contained in the provided value map is equal to an expected number. More...
 
static bool is_values_map_complete (IndexMap const &index_map, ValueMap const &values_map)
 Check if for each key-index pair contained in the index map there is a value provided by the value map. More...
 
static void fill_vector_from_map (IndexMap const &index_map, ValueMap const &values_map, unsigned int vector_size, ValueVector &values)
 Fill (and resize if necessary) a vector with the values contained in the value map. More...
 
static ValueVector value_vector_from_map (IndexMap const &index_map, ValueMap const &values_map, unsigned int vector_size)
 Returns a vector containing the values provided through the value map. More...
 
static ValueMap create_map_from_values (IndexMap const &index_map, ValueVector const &values)
 Returns a vector ValueMap object containing the values of the value vector. More...
 

Protected Member Functions

virtual int create_index_maps ()=0
 Reinitialize the maps used to set or retrieve value using string variable names. More...
 
int free_memory ()
 Free all the allocated memory. More...
 
virtual int internal_create_capsule ()=0
 Create the Acados solver's capsule used by the Acados C-interface. More...
 
virtual int internal_create_with_discretization (int n_time_steps, double *new_time_steps)=0
 Initialize Acados solver and (optionally) redefine the shooting nodes. More...
 
virtual int internal_reset (int reset_qp_solver_mem=1)=0
 Reset the solver memory and (opt.) the internal QP solver. More...
 
virtual int internal_free ()=0
 Free the memory allocated for the solver. More...
 
virtual int internal_free_capsule ()=0
 Free the memory allocated for the capsule. More...
 
virtual int internal_update_qp_solver_cond_N (int qp_solver_cond_N)=0
 Update the QP solver qp_solver_cond_N setting. More...
 
virtual int internal_update_params (unsigned int stage, double *value, int np)=0
 Internal update of the solver runtime parameters. More...
 
virtual int internal_update_params_sparse (unsigned int stage, int *idx, double *p, int n_update)=0
 A sparse implementation of internal_update_params_sparse(). More...
 
virtual int internal_solve ()=0
 Solve the non-linear optimization`. More...
 
virtual void internal_print_stats () const =0
 Print the solver stats (e.g., number of SQP iters, number of QP iters, etc.) to the console. More...
 

Protected Attributes

Dimensions _dims
 Fixed dimensions of the imported Acados OCP. More...
 
IndexMap _x_index_map
 Unordered map used to set or retrieve the values of diff. state variables by name. More...
 
IndexMap _z_index_map
 Unordered map used to set or retrieve the values of algebraic state variables by name. More...
 
IndexMap _p_index_map
 Unordered map used to set the values of runtime parameters by name. More...
 
IndexMap _u_index_map
 Unordered map used to set or retrieve the values of control variables by name. More...
 

Detailed Description

Abstract C++ wrapper of generated Acados solver C-code.

Constructor & Destructor Documentation

◆ AcadosSolver()

acados::AcadosSolver::AcadosSolver ( )

Constructor of the AcadosSolver object.

Does nothing for now.

Warning
Any class inheriting from AcadosSolver will have to correctly initialize the AcadosSolver::_dims object.

◆ ~AcadosSolver()

virtual acados::AcadosSolver::~AcadosSolver ( )
virtual

Destructor of the AcadosSolver object.

Warning
The free_memory() function must called by the destructor of any class inheriting from AcadosSolver. Otherwise, the allocated memory won't be fully released.

Member Function Documentation

◆ init()

int acados::AcadosSolver::init ( unsigned int  N,
double  Ts 
)

Initialize the solver and set the (constant) sampling intervals.

Todo:
Add alternative init() function for non-constant sampling intervals.
Parameters
NNumber of shooting nodes (strictly positive).
TsSampling time in seconds.
Returns
int (zero if all OK).

◆ reset()

int acados::AcadosSolver::reset ( )

Resets the Acados solver, including the internal QP solver and the RTI phase cache.

Returns
int (zero if all OK).

◆ solve()

int acados::AcadosSolver::solve ( )

Solve the non-linear optimization problem given the provided initial state, constraints, etc.

The method returns the internal Acados status.

Returns
0 : All OK.
1 : Invalid input (NaN detected).
2 : Maximum number of iteration reached.
3 : Minimum step length reached, could possibly be a NaN solution too (if using HPIPM)
4 : QP solver failed.
other : Not OK.

◆ set_initial_state_values() [1/2]

int acados::AcadosSolver::set_initial_state_values ( ValueVector x_0)

Set the initial state values (i.e., add constraints on initial state)

Parameters
x_0State values at initial stage.
Returns
int (zero if all OK)

◆ set_initial_state_values() [2/2]

int acados::AcadosSolver::set_initial_state_values ( ValueMap const &  x_0_map)

Set the initial state values (i.e., add constraints on initial state) from a map of key/ValueVector pairs.

Parameters
x_0_mapValueMap of the initial state values.
Returns
int (zero if all OK)

◆ set_state_bounds() [1/2]

int acados::AcadosSolver::set_state_bounds ( unsigned int  stage,
IndexVector idxbx,
ValueVector lbx,
ValueVector ubx 
)

Set (differential) state bounds at a given stage.

Parameters
stageStage in [0;N].
idxbxIndexes of the bounded state variables.
lbxVector of lower bounds.
ubxVector of uower bounds.
Returns
int (zero if all OK)

◆ set_state_bounds() [2/2]

int acados::AcadosSolver::set_state_bounds ( IndexVector idxbx,
ValueVector lbx,
ValueVector ubx 
)

Set (differential) state bounds for all stages.

The bounds are therefore equal at each stage.

Parameters
idxbxIndexes of the bounded state variables.
lbxVector of lower bounds.
ubxVector of uower bounds.
Returns
int (zero if all OK)

◆ set_control_bounds() [1/2]

int acados::AcadosSolver::set_control_bounds ( unsigned int  stage,
IndexVector idxbu,
ValueVector lbu,
ValueVector ubu 
)

Set control bounds at a given stage.

Parameters
stageStage in [0;N].
idxbuIndexes of the bounded control variables.
lbuVector of lower bounds.
ubuVector of uower bounds.
Returns
int (zero if all OK)

◆ set_control_bounds() [2/2]

int acados::AcadosSolver::set_control_bounds ( IndexVector idxbu,
ValueVector lbu,
ValueVector ubu 
)

Set control bounds for all stages.

The bounds are therefore equal at each stage.

Parameters
idxbuIndexes of the bounded control variables.
lbuVector of lower bounds.
ubuVector of uower bounds.
Returns
int (zero if all OK)

◆ set_runtime_parameters() [1/4]

int acados::AcadosSolver::set_runtime_parameters ( unsigned int  stage,
ValueVector p_i 
)

Set the runtime parameters for one stage from ordered value vector.

Parameters
stageStage in [0;N].
p_iVector containing the (ordered) runtime parameters.
Returns
int Status (zero if all OK).

◆ set_runtime_parameters() [2/4]

int acados::AcadosSolver::set_runtime_parameters ( unsigned int  stage,
ValueMap const &  p_i_map 
)

Set the runtime parameters for one stage from a key/values map.

Note
If the parameters are the same for all stages, prefer the set_runtime_parameters(ValueMap const &) alternative.
Parameters
stageStage in [0;N].
p_i_mapKey to ValueVector map containing the runtime parameters.
Returns
int Status (zero if all OK).

◆ set_runtime_parameters() [3/4]

int acados::AcadosSolver::set_runtime_parameters ( ValueVector p_i)

Set the runtime parameters for all stages at once from ordered value vector.

The runtime parameters for ALL stages are equal.

Parameters
p_iVector containing the (ordered) runtime parameters.
Returns
int Status (zero if all OK).

◆ set_runtime_parameters() [4/4]

int acados::AcadosSolver::set_runtime_parameters ( ValueMap const &  p_i_map)

Set the runtime parameters for all stages at once from a key/values map.

The runtime parameters for ALL stages are equal. Once the ordered vector of parameters is extracted, it is the set_runtime_parameters(unsigned int, ValueVector &) function that is used.

Parameters
p_i_mapKey to ValueVector map containing the runtime parameters.
Returns
int Status (zero if all OK).

◆ initialize_state_values() [1/4]

int acados::AcadosSolver::initialize_state_values ( unsigned int  stage,
ValueVector x_i 
)

Initialize the (differential) state values for a stage from an ordered value vector.

Warning
This function (and other "initialization" functions similar to this one) only initialize the solver state/control values. These function should only be used before a AcadoSolver::solve() call! Also, initializing the state values for stage zero is not equivalent to set the initial state (see AcadoSolver::set_initial_state_values()).
Parameters
stageStage in [0;N].
x_iVector containing the (ordered) state values.
Returns
int Status (zero if all OK).

◆ initialize_state_values() [2/4]

int acados::AcadosSolver::initialize_state_values ( unsigned int  stage,
ValueMap const &  x_i_map 
)

Initialize the (differential) state values for a stage from a key/values map.

Note
If the parameters are the same for all stages, prefer the set_runtime_parameters(ValueMap const &) alternative.
Parameters
stageStage in [0;N].
x_i_mapKey to ValueVector map containing the initial state values.
Returns
int Status (zero if all OK).

◆ initialize_state_values() [3/4]

int acados::AcadosSolver::initialize_state_values ( ValueVector x_i)

Initialize the (differential) state values for ALL stages at once from an ordered value vector.

Parameters
x_iVector containing the (ordered) state values.
Returns
int Status (zero if all OK).

◆ initialize_state_values() [4/4]

int acados::AcadosSolver::initialize_state_values ( ValueMap const &  x_i_map)

Initialize the (differential) state values for ALL stages at once from a key/values map.

Parameters
x_i_mapKey to ValueVector map containing the initial state values.
Returns
int Status (zero if all OK).

◆ initialize_control_values() [1/4]

int acados::AcadosSolver::initialize_control_values ( unsigned int  stage,
ValueVector u_i 
)

Initialize the control variable values for one stage from an ordered value vector.

Parameters
stageStage in [0;N].
u_iVector containing the (ordered) control variables values.
Returns
int Status (zero if all OK).

◆ initialize_control_values() [2/4]

int acados::AcadosSolver::initialize_control_values ( unsigned int  stage,
ValueMap const &  u_i_map 
)

Initialize the control variable values for one stage from a key/values map.

Parameters
stageStage in [0;N].
u_i_mapKey to ValueVector map containing the control variables values.
Returns
int Status (zero if all OK).

◆ initialize_control_values() [3/4]

int acados::AcadosSolver::initialize_control_values ( ValueVector u_i)

Initialize the control variable values for ALL stages at once from an ordered value vector.

Parameters
u_iVector containing the (ordered) control variables values.
Returns
int Status (zero if all OK).

◆ initialize_control_values() [4/4]

int acados::AcadosSolver::initialize_control_values ( ValueMap const &  u_i_map)

Initialize the control variable values for ALL stages at once from a key/values map.

Parameters
u_i_mapKey to ValueVector map containing the control variables values.
Returns
int Status (zero if all OK).

◆ get_state_values()

ValueVector acados::AcadosSolver::get_state_values ( unsigned int  stage)

Retrieve the differential state variables at a given stage.

Parameters
stageStage in [0;N].
Returns
ValueVector Vector of (ordered) state values.

◆ get_state_values_as_map()

ValueMap acados::AcadosSolver::get_state_values_as_map ( unsigned int  stage)

Retrieve the differential state variables at a given stage and package them as a ValueMap.

Parameters
stageStage in [0;N].
Returns
ValueMap Key/ValueVector map containing of differential state values.

◆ get_algebraic_state_values()

ValueVector acados::AcadosSolver::get_algebraic_state_values ( unsigned int  stage)

Retrieve the algebraic state variables at a given stage.

Parameters
stageStage in [0;N].
Returns
ValueVector Vector of (ordered) state values.

◆ get_algebraic_state_values_as_map()

ValueMap acados::AcadosSolver::get_algebraic_state_values_as_map ( unsigned int  stage)

Retrieve the algebraic state variables at a given stage and package them as a ValueMap.

Parameters
stageStage in [0;N].
Returns
ValueMap Key/ValueVector map containing the algebraic state values.

◆ get_control_values()

ValueVector acados::AcadosSolver::get_control_values ( unsigned int  stage)

Retrieve the control variables at a given stage.

Parameters
stageStage in [0;N].
Returns
ValueVector Vector of (ordered) control variable values.

◆ get_control_values_as_map()

ValueMap acados::AcadosSolver::get_control_values_as_map ( unsigned int  stage)

Retrieve the control variables at a given stage and package them as a ValueMap.

Parameters
stageStage in [0;N].
Returns
ValueMap Key/ValueVector map containing the control variable values.

◆ x_index_map()

const IndexMap& acados::AcadosSolver::x_index_map ( ) const

Returns a constant reference to the Key/IndexVector map of differential state variables internally stored in AcadosSolver::_x_index_map.

Returns
const IndexMap&

◆ z_index_map()

const IndexMap& acados::AcadosSolver::z_index_map ( ) const

Returns a constant reference to the Key/IndexVector map of algebraic state variables internally stored in AcadosSolver::_z_index_map.

Returns
const IndexMap&

◆ p_index_map()

const IndexMap& acados::AcadosSolver::p_index_map ( ) const

Returns a constant reference to the Key/IndexVector map of runtime parameters internally stored in AcadosSolver::_p_index_map.

Returns
const IndexMap&

◆ u_index_map()

const IndexMap& acados::AcadosSolver::u_index_map ( ) const

Returns a constant reference to the Key/IndexVector map of control variables internally stored in AcadosSolver::_u_index_map.

Returns
const IndexMap&

◆ is_map_size_consistent() [1/2]

static bool acados::AcadosSolver::is_map_size_consistent ( IndexMap const &  index_map,
unsigned int  expected_total_indexes 
)
static

Check if the total number of indexes contained in the provided index map is equal to an expected number.

Parameters
index_mapThe Key/IndexVector map to be tested for size consistency.
expected_total_indexesThe expected number of indexes.
Returns
true if the size is consistent
false otherwise

◆ is_map_size_consistent() [2/2]

static bool acados::AcadosSolver::is_map_size_consistent ( ValueMap const &  values_map,
unsigned int  expected_total_indexes 
)
static

Check if the total number of values contained in the provided value map is equal to an expected number.

Parameters
values_mapThe Key/ValueVector map to be tested for size consistency.
expected_total_indexesThe expected number of values.
Returns
true if the size is consistent
false otherwise

◆ is_values_map_complete()

static bool acados::AcadosSolver::is_values_map_complete ( IndexMap const &  index_map,
ValueMap const &  values_map 
)
static

Check if for each key-index pair contained in the index map there is a value provided by the value map.

It is considered complete even if there are too many values (e.g., unused keys in values_map).

Parameters
index_mapThe Key/IndexVector map to be tested for size consistency.
values_mapThe Key/ValueVector map to be tested for size consistency.
Returns
true if the value map is complete.
false otherwise.

◆ fill_vector_from_map()

static void acados::AcadosSolver::fill_vector_from_map ( IndexMap const &  index_map,
ValueMap const &  values_map,
unsigned int  vector_size,
ValueVector values 
)
static

Fill (and resize if necessary) a vector with the values contained in the value map.

The index map is used to arrange the values within the vector.

Exceptions
std::invalid_argument
Todo:
Overloaded function without the vector_size argument. The vector_size argument could (should?) be optional since it can be retrieved from the number of indexes contained in index_map.
Parameters
index_mapMapping between keys and indexes.
values_mapMapping between keys and values to write in the value vector.
vector_sizeThe expected size of the resulting value vector.
valuesThe output container where the values will be written.

◆ value_vector_from_map()

static ValueVector acados::AcadosSolver::value_vector_from_map ( IndexMap const &  index_map,
ValueMap const &  values_map,
unsigned int  vector_size 
)
static

Returns a vector containing the values provided through the value map.

Parameters
index_mapMapping between keys and indexes.
values_mapMapping between keys and values to write in the value vector.
vector_sizeThe expected size of the resulting value vector.
Returns
ValueVector The resulting value vector.

◆ create_map_from_values()

static ValueMap acados::AcadosSolver::create_map_from_values ( IndexMap const &  index_map,
ValueVector const &  values 
)
static

Returns a vector ValueMap object containing the values of the value vector.

Warning
The values must have been encoded as described by the index_map argument.
Parameters
index_mapMapping between keys and indexes.
valuesVector of (ordered) values.

◆ dims()

const Dimensions& acados::AcadosSolver::dims ( ) const

Returns the (fixed) dimensions of the OCP problem stored in AcadosSolver::_dims.

Returns
const Dimensions& The dimensions

◆ nx()

unsigned int acados::AcadosSolver::nx ( ) const

Returns the dimensions of the differential state vector.

This is a convenience wrapper of the call dims().nx (see dims()).

Returns
unsigned int nx

◆ nz()

unsigned int acados::AcadosSolver::nz ( ) const

Returns the dimensions of the algebraic state vector.

This is a convenience wrapper of the call dims().nz (see dims()).

Returns
unsigned int nz

◆ np()

unsigned int acados::AcadosSolver::np ( ) const

Returns the number of runtime parameters.

This is a convenience wrapper of the call dims().np (see dims()).

Returns
unsigned int np

◆ nu()

unsigned int acados::AcadosSolver::nu ( ) const

Returns the number of control variables.

This is a convenience wrapper of the call dims().nu (see dims()).

Returns
unsigned int nu

◆ N()

unsigned int acados::AcadosSolver::N ( ) const

Returns the number of shooting nodes.

Returns
unsigned int N

◆ Ts()

double acados::AcadosSolver::Ts ( ) const

Returns the (constant) sampling interval Ts (in seconds).

If the sampling intervals are of variable duration (see sampling_intervals()), the function returns -1.

Returns
unsigned int Ts

◆ sampling_intervals()

std::vector<double> acados::AcadosSolver::sampling_intervals ( ) const

Returns the vector of sampling interval (in seconds).

Returns
std::vector<double> the vector of sampling intervals

◆ create_index_maps()

virtual int acados::AcadosSolver::create_index_maps ( )
protectedpure virtual

Reinitialize the maps used to set or retrieve value using string variable names.

◆ free_memory()

int acados::AcadosSolver::free_memory ( )
protected

Free all the allocated memory.

Triggers calls to internal_free(), internal_free_capsule(), etc.

Warning
Should be called by the destructor of any class inheriting from AcadosSolver.
Returns
int (zero if all OK).

◆ internal_create_capsule()

virtual int acados::AcadosSolver::internal_create_capsule ( )
protectedpure virtual

Create the Acados solver's capsule used by the Acados C-interface.

Wrapper of the <acados_model_name>_acados_create_capsule() C function. Note that the storage of the capsule itself is handled by the inherited class.

Returns
int (zero if all OK).

◆ internal_create_with_discretization()

virtual int acados::AcadosSolver::internal_create_with_discretization ( int  n_time_steps,
double *  new_time_steps 
)
protectedpure virtual

Initialize Acados solver and (optionally) redefine the shooting nodes.

This is a wrapper of the <acados_model_name>_acados_create_with_discretization(...) C function. For constant sampling intervals, provide new_time_steps = nullptr as argument.

Parameters
n_time_stepsnumber of shooting nodes.
new_time_stepsC-array of sampling intervals (in seconds).
Returns
int (zero if all OK).

◆ internal_reset()

virtual int acados::AcadosSolver::internal_reset ( int  reset_qp_solver_mem = 1)
protectedpure virtual

Reset the solver memory and (opt.) the internal QP solver.

This is a wrapper of the <acados_model_name>_acados_reset(...) C function.

Parameters
reset_qp_solver_memReset if =1.
Returns
int (zero if all OK).

◆ internal_free()

virtual int acados::AcadosSolver::internal_free ( )
protectedpure virtual

Free the memory allocated for the solver.

This is a wrapper of the <acados_model_name>_acados_free(...) C function. Call internal_free() before internal_free_capsule().

Returns
int (zero if all OK).

◆ internal_free_capsule()

virtual int acados::AcadosSolver::internal_free_capsule ( )
protectedpure virtual

Free the memory allocated for the capsule.

This is a wrapper of the <acados_model_name>_acados_free_capsule(...) C function.

Returns
int (zero if all OK).

◆ internal_update_qp_solver_cond_N()

virtual int acados::AcadosSolver::internal_update_qp_solver_cond_N ( int  qp_solver_cond_N)
protectedpure virtual

Update the QP solver qp_solver_cond_N setting.

This is a wrapper of the <acados_model_name>_acados_update_qp_solver_cond_N(...) C function.

Parameters
qp_solver_cond_NNew horizon after partial condensing.
Returns
int (zero if all OK).

◆ internal_update_params()

virtual int acados::AcadosSolver::internal_update_params ( unsigned int  stage,
double *  value,
int  np 
)
protectedpure virtual

Internal update of the solver runtime parameters.

This is a wrapper of the <acados_model_name>_acados_update_params(...) C function.

Parameters
stageStage in [0;N].
valueParameter values (C-array).
npNumber of parameters.
Returns
int (zero if all OK).

◆ internal_update_params_sparse()

virtual int acados::AcadosSolver::internal_update_params_sparse ( unsigned int  stage,
int *  idx,
double *  p,
int  n_update 
)
protectedpure virtual

A sparse implementation of internal_update_params_sparse().

This is a wrapper of the <acados_model_name>_acados_update_params_sparse(...) C function.

Parameters
stageStage in [0;N].
idxParameter indexes (C-array).
pParameter values (C-array).
n_updateNumber of parameters to update.
Returns
int (zero if all OK).

◆ internal_solve()

virtual int acados::AcadosSolver::internal_solve ( )
protectedpure virtual

Solve the non-linear optimization`.

This is a wrapper of the <acados_model_name>_acados_solve(...) C function.

Returns
int (zero if all OK). See Acados documentation for a list of return flags.

◆ internal_print_stats()

virtual void acados::AcadosSolver::internal_print_stats ( ) const
protectedpure virtual

Print the solver stats (e.g., number of SQP iters, number of QP iters, etc.) to the console.

This is a wrapper of the <acados_model_name>_acados_print_stats(...) C function.

◆ get_nlp_in()

virtual ocp_nlp_in* acados::AcadosSolver::get_nlp_in ( ) const
pure virtual

Legacy C-function to retrieve the C-interface ocp_nlp_in property of the solver.

This is a wrapper of the auto-generated <acados_model_name>_acados_get_nlp_in(...) C function.

Returns
ocp_nlp_in* Pointer towards the ocp_nlp_in object.

◆ get_nlp_out()

virtual ocp_nlp_out* acados::AcadosSolver::get_nlp_out ( ) const
pure virtual

Legacy C-function to retrieve the C-interface ocp_nlp_out property of the solver.

This is a wrapper of the auto-generated <acados_model_name>_acados_get_nlp_out(...) C function.

Returns
ocp_nlp_out* Pointer towards the ocp_nlp_out object.

◆ get_sens_out()

virtual ocp_nlp_out* acados::AcadosSolver::get_sens_out ( ) const
pure virtual

Legacy C-function to retrieve the C-interface ocp_nlp_out property of the solver.

This is a wrapper of the auto-generated <acados_model_name>_acados_get_sens_out(...) C function. The function is used to retrieve the sensibility matrices.

Returns
ocp_nlp_out* Pointer towards the ocp_nlp_out object.

◆ get_nlp_solver()

virtual ocp_nlp_solver* acados::AcadosSolver::get_nlp_solver ( ) const
pure virtual

Legacy C-function to retrieve the C-interface ocp_nlp_solver property of the solver.

This is a wrapper of the auto-generated <acados_model_name>_acados_get_nlp_solver(...) C function.

Returns
ocp_nlp_solver* Pointer towards the ocp_nlp_solver object.

◆ get_nlp_config()

virtual ocp_nlp_config* acados::AcadosSolver::get_nlp_config ( ) const
pure virtual

Legacy C-function to retrieve the C-interface ocp_nlp_config property of the solver.

This is a wrapper of the auto-generated <acados_model_name>_acados_get_nlp_config(...) C function.

Returns
ocp_nlp_config* Pointer towards the ocp_nlp_config object.

◆ get_nlp_opts()

virtual void* acados::AcadosSolver::get_nlp_opts ( ) const
pure virtual

Legacy C-function to retrieve the C-interface get_nlp_opts property of the solver.

This is a wrapper of the auto-generated <acados_model_name>_acados_get_nlp_opts(...) C function.

Returns
void* Pointer towards the nlp_opts object.

◆ get_nlp_dims()

virtual ocp_nlp_dims* acados::AcadosSolver::get_nlp_dims ( ) const
pure virtual

Legacy C-function to retrieve the C-interface ocp_nlp_dims property of the solver that contains the dimensions of the problem.

This is a wrapper of the auto-generated <acados_model_name>_acados_get_nlp_dims(...) C function.

Returns
ocp_nlp_dims* Pointer towards the ocp_nlp_dims object.

◆ get_nlp_plan()

virtual ocp_nlp_plan_t* acados::AcadosSolver::get_nlp_plan ( ) const
pure virtual

Legacy C-function to retrieve the C-interface ocp_nlp_plan property of the solver.

This is a wrapper of the auto-generated <acados_model_name>_acados_get_nlp_plan(...) C function.

Returns
ocp_nlp_plan_t* Pointer towards the ocp_nlp_plan object.

◆ get_nlp_np()

virtual unsigned int acados::AcadosSolver::get_nlp_np ( ) const
pure virtual

Legacy C-function to retrieve the number of runtime parameters from the Acados capsule.

This function returns the field capsule->nlp_np where capsule is the internal pointer to the acados solver data.

Returns
unsigned int np

Member Data Documentation

◆ _dims

Dimensions acados::AcadosSolver::_dims
protected

Fixed dimensions of the imported Acados OCP.

◆ _x_index_map

IndexMap acados::AcadosSolver::_x_index_map
protected

Unordered map used to set or retrieve the values of diff. state variables by name.

◆ _z_index_map

IndexMap acados::AcadosSolver::_z_index_map
protected

Unordered map used to set or retrieve the values of algebraic state variables by name.

◆ _p_index_map

IndexMap acados::AcadosSolver::_p_index_map
protected

Unordered map used to set the values of runtime parameters by name.

◆ _u_index_map

IndexMap acados::AcadosSolver::_u_index_map
protected

Unordered map used to set or retrieve the values of control variables by name.


The documentation for this class was generated from the following file: