Skip to content

Commit 197c0bb

Browse files
Merge pull request #1 from pavelacamposp/feature/pre-commit
Add `pre-commit` to project
2 parents 0ce6e41 + 94f4baa commit 197c0bb

File tree

11 files changed

+405
-260
lines changed

11 files changed

+405
-260
lines changed

.pre-commit-config.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
repos:
3+
- repo: https://github.com/pre-commit/pre-commit-hooks
4+
rev: v5.0.0
5+
hooks:
6+
- id: trailing-whitespace
7+
- id: end-of-file-fixer
8+
- id: check-yaml
9+
- repo: local
10+
hooks:
11+
- id: mypy
12+
name: mypy
13+
entry: mypy
14+
require_serial: true
15+
language: system
16+
types: [python]
17+
- repo: https://github.com/astral-sh/ruff-pre-commit
18+
rev: v0.11.4
19+
hooks:
20+
- id: ruff
21+
args: [--fix]
22+
- id: ruff-format
23+
- repo: https://github.com/codespell-project/codespell
24+
rev: v2.4.1
25+
hooks:
26+
- id: codespell
27+
files: ^.*\.(py|c|cpp|h|m|md|rst|yml)$
28+
- repo: https://github.com/adrienverge/yamllint
29+
rev: v1.37.0
30+
hooks:
31+
- id: yamllint
32+
args: ["--strict"]
33+
exclude: ^\.github/workflows/

LICENSE-APACHE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,4 +198,4 @@
198198
distributed under the License is distributed on an "AS IS" BASIS,
199199
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200200
See the License for the specific language governing permissions and
201-
limitations under the License.
201+
limitations under the License.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
# data_driven_quad_control
1+
# data_driven_quad_control

config/nonlinear_dd_mpc_params.yaml

Lines changed: 47 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
---
12
# Nonlinear Data-Driven MPC Parameters
2-
33
nonlinear_dd_mpc_ext_out_incr_in:
44
n: 2 # Estimated system order
55

@@ -32,35 +32,38 @@ nonlinear_dd_mpc_ext_out_incr_in:
3232
- [-1, 1]
3333
- [-1, 1]
3434

35-
alpha_reg_type: 1 # Alpha regularization type:
36-
# - 0 = Approximated → Regularized w.r.t. an approximation
37-
# of alpha_Lin^sr(D_t).
38-
# - 1 = Previous → Regularized w.r.t. a previous optimal
39-
# alpha value to encourage stationary
40-
# behavior.
41-
# - 2 = Zero → Regularized w.r.t. zero.
42-
35+
# Alpha regularization type:
36+
# - 0 = Approximated → Regularized w.r.t. an approximation
37+
# of alpha_Lin^sr(D_t).
38+
# - 1 = Previous → Regularized w.r.t. a previous optimal
39+
# alpha value to encourage stationary
40+
# behavior.
41+
# - 2 = Zero → Regularized w.r.t. zero.
42+
alpha_reg_type: 1
43+
4344
# Nonlinear MPC parameters for alpha_reg_type = 0 (Approximated)
4445
lamb_alpha_s: null # Regularization parameter for alpha_s (optional)
4546
lamb_sigma_s: null # Regularization parameter for sigma_s (optional)
46-
47+
4748
y_r: [1.0, 1.0, 1.0] # System output setpoint
4849

49-
ext_out_incr_in: true # Enables the following controller structure:
50-
# - true → Controller uses an extended output
51-
# representation (y_ext[k] = [y[k], u[k]])
52-
# and input increments where the control
53-
# input is updated incrementally as:
54-
# u[k] = u[k-1] + du[k-1].
55-
# - false → Standard controller operation. Direct
56-
# control input, without extensions.
50+
# Control system structure (Extendended Output and Input Increments):
51+
# - true → Controller uses an extended output
52+
# representation (y_ext[k] = [y[k], u[k]])
53+
# and input increments where the control
54+
# input is updated incrementally as:
55+
# u[k] = u[k-1] + du[k-1].
56+
# - false → Standard controller operation. Direct
57+
# control input, without extensions.
58+
ext_out_incr_in: true
5759

5860
# Tracking cost value threshold
5961
update_cost_threshold: null
6062

61-
n_n_mpc_step: true # Enable n-Step Data-Driven MPC:
62-
# - true = n-Step Data-Driven MPC
63-
# - false = 1-Step Data-Driven MPC
63+
# Enable n-Step Data-Driven MPC:
64+
# - true = n-Step Data-Driven MPC
65+
# - false = 1-Step Data-Driven MPC
66+
n_n_mpc_step: true
6467

6568
nonlinear_dd_mpc_approx_1_step:
6669
n: 2 # Estimated system order
@@ -97,32 +100,35 @@ nonlinear_dd_mpc_approx_1_step:
97100
- [-0.01, 0.01]
98101
- [-0.01, 0.01]
99102

100-
alpha_reg_type: 1 # Alpha regularization type:
101-
# - 0 = Approximated → Regularized w.r.t. an approximation
102-
# of alpha_Lin^sr(D_t).
103-
# - 1 = Previous → Regularized w.r.t. a previous optimal
104-
# alpha value to encourage stationary
105-
# behavior.
106-
# - 2 = Zero → Regularized w.r.t. zero.
107-
103+
# Alpha regularization type:
104+
# - 0 = Approximated → Regularized w.r.t. an approximation
105+
# of alpha_Lin^sr(D_t).
106+
# - 1 = Previous → Regularized w.r.t. a previous optimal
107+
# alpha value to encourage stationary
108+
# behavior.
109+
# - 2 = Zero → Regularized w.r.t. zero.
110+
alpha_reg_type: 1
111+
108112
# Nonlinear MPC parameters for alpha_reg_type = 0 (Approximated)
109113
lamb_alpha_s: 1 # Regularization parameter for alpha_s (optional)
110114
lamb_sigma_s: 1.0e5 # Regularization parameter for sigma_s (optional)
111-
115+
112116
y_r: [1.0, 1.0, 1.0] # System output setpoint
113117

114-
ext_out_incr_in: false # Enables the following controller structure:
115-
# - true → Controller uses an extended output
116-
# representation (y_ext[k] = [y[k], u[k]])
117-
# and input increments where the control
118-
# input is updated incrementally as:
119-
# u[k] = u[k-1] + du[k-1].
120-
# - false → Standard controller operation. Direct
121-
# control input, without extensions.
118+
# Control system structure (Extendended Output and Input Increments):
119+
# - true → Controller uses an extended output
120+
# representation (y_ext[k] = [y[k], u[k]])
121+
# and input increments where the control
122+
# input is updated incrementally as:
123+
# u[k] = u[k-1] + du[k-1].
124+
# - false → Standard controller operation. Direct
125+
# control input, without extensions.
126+
ext_out_incr_in: false
122127

123128
# Tracking cost value threshold
124129
update_cost_threshold: null
125130

126-
n_n_mpc_step: false # Enable n-Step Data-Driven MPC:
127-
# - true = n-Step Data-Driven MPC
128-
# - false = 1-Step Data-Driven MPC
131+
# Enable n-Step Data-Driven MPC:
132+
# - true = n-Step Data-Driven MPC
133+
# - false = 1-Step Data-Driven MPC
134+
n_n_mpc_step: false

pyproject.toml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
[build-system]
2+
requires = ["setuptools >= 77.0.3"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "data_driven_quad_control"
7+
version = "0.1.0"
8+
authors = [
9+
{ name = "Pável A. Campos-Peña", email = "pcamposp@uni.pe" }
10+
]
11+
description = "Data-driven control for drones in Genesis: data-driven MPC and reinforcement learning"
12+
readme = {file = "README.md", content-type = "text/markdown"}
13+
requires-python = ">=3.10.0"
14+
dependencies = [
15+
"genesis_world >=0.2.1",
16+
"numpy >=2.2.4",
17+
"torch >=2.6.0",
18+
]
19+
license = "MIT AND Apache-2.0"
20+
license-files = ["LICEN[CS]E*"]
21+
keywords = ["drone", "control-systems", "data-driven", "reinforcement-learning"]
22+
classifiers = [
23+
"Programming Language :: Python :: 3",
24+
"License :: OSI Approved :: MIT License",
25+
"License :: OSI Approved :: Apache Software License",
26+
"Operating System :: OS Independent",
27+
]
28+
29+
[project.urls]
30+
Homepage = "https://github.com/pavelacamposp/data_driven_quad_control.git"
31+
32+
[tool.setuptools]
33+
package-dir = {"" = "src"}
34+
35+
[tool.ruff]
36+
line-length = 79
37+
extend-exclude = ["__pycache__"]
38+
39+
[tool.ruff.lint]
40+
extend-select = ["I", "D", "B", "C4", "E", "F", "W"]
41+
ignore = [
42+
"D100",
43+
"D101",
44+
"D102",
45+
"D103",
46+
"D104",
47+
"D105",
48+
"D106",
49+
"D107",
50+
"D203",
51+
"D212",
52+
]
53+
54+
[tool.mypy]
55+
ignore_missing_imports = true
56+
disallow_untyped_defs = true
57+
strict_optional = true
58+
warn_unused_ignores = true
59+
disable_error_code = ["type-arg"]

requirements-dev.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
git+https://github.com/pavelacamposp/direct_data_driven_mpc.git
2+
genesis_world==0.2.1
3+
numpy==2.2.4
4+
torch==2.6.0
5+
pre-commit
6+
ruff
7+
mypy

requirements.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
git+https://github.com/pavelacamposp/direct_data_driven_mpc.git
2+
genesis_world==0.2.1
3+
numpy==2.2.4
4+
torch==2.6.0

0 commit comments

Comments
 (0)