iit-DLSLab / Quadruped-PyMPC

A model predictive controller for quadruped robots based on the single rigid body model and written in python. Gradient-based (acados) or Sampling-based (jax).
216 stars 18 forks source link

Eliminate the use of global variables and global config files. #5

Open Danfoa opened 5 months ago

Danfoa commented 5 months ago

Most modules in this repository import a fixed repo-specific config file, config.py, and use it to load class-specific and function-specific attributes. This practice poses a problem, as external users must modify the modules and scripts to avoid using config.py.

For instance, to utilize the Acados_NMPC_Nominal class, the mpc_params used to define its attributes should be passed through the class constructor or as a DataClass configuration. Such that I as an external user can import only this class and use it without having to rely on modifying the config file of the repo, which I dont want to use.

As an example, the Centroidal_Model_Nominal model only uses config.py to load the config.mpc_params["use_foothold_optimization"] argument. This should be a class attribute set during initialization.

Maintaining the modularity of each class is essential for scaling both the code and the user base.