Skip to content

Commit 69db0da

Browse files
authored
Merge pull request #5 from JuliaComputing/fbc/dyad-translation
Translate models from MTK to Dyad
2 parents db29b24 + cad1c35 commit 69db0da

74 files changed

Lines changed: 4250 additions & 1276 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Project.toml

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,46 @@ authors = ["Fredrik Bagge Carlson"]
44
version = "0.2.0"
55

66
[deps]
7-
ControlSystemsBase = "aaaaaaaa-a6ca-5380-bf3e-84a91bcd477e"
8-
ControlSystemsMTK = "687d7614-c7e5-45fc-bfc3-9ee385575c88"
9-
DyadControlSystems = "6f9e59d0-2838-4fee-9bce-c163a6c9592b"
10-
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
7+
BlockComponents = "1ef5d832-be8e-447f-9f2c-8b5d17d15fd3"
8+
DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab"
9+
DyadInterface = "99806f68-afab-45ca-9d8c-ceff6bc61f54"
10+
Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a"
1111
ModelingToolkit = "961ee093-0014-501f-94e3-6117800e7a78"
12-
ModelingToolkitStandardLibrary = "16a59e39-deab-5bd0-87e4-056b12336739"
13-
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
12+
Moshi = "2e0e35c7-a2e4-4343-998d-7ef72827ed2d"
13+
MultibodyComponents = "01883e52-22cd-4538-b14d-b44f958a131d"
1414
OrdinaryDiffEqDefault = "50262376-6c5a-4cf5-baba-aaf4f84d72d7"
15-
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
15+
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
16+
RotationalComponents = "824fa3ed-d7dc-4365-8bdf-ac77a1ac2011"
17+
RuntimeGeneratedFunctions = "7e49a35a-f44a-4d26-94aa-eba1b4ca6b47"
1618
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
17-
WGLMakie = "276b4fcb-3e11-5398-bf8b-a0c2d153d008"
19+
Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7"
1820

1921
[compat]
20-
ControlSystemsMTK = "2.5.0"
21-
Makie = "0.24.8"
22-
ModelingToolkitStandardLibrary = "2.25.0"
23-
Plots = "1.41.2"
22+
BlockComponents = "4"
23+
DelimitedFiles = "1"
24+
DyadInterface = "6, 7"
25+
Markdown = "1"
26+
ModelingToolkit = "11"
27+
Moshi = "0.3"
28+
MultibodyComponents = "0.2"
29+
OrdinaryDiffEqDefault = "1.12.0, 2"
30+
PrecompileTools = "1"
31+
RotationalComponents = "2"
32+
RuntimeGeneratedFunctions = "0.5.17"
2433
StaticArrays = "1.9.15"
25-
WGLMakie = "0.13.8"
34+
Symbolics = "7"
35+
julia = "1.12"
36+
37+
[dyad]
38+
kernel = "3.2.0"
2639

2740
[extras]
41+
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
42+
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
43+
DyadInterface = "99806f68-afab-45ca-9d8c-ceff6bc61f54"
44+
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
45+
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
2846
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
2947

3048
[targets]
31-
test = ["Test"]
49+
test = ["CSV", "DataFrames", "DyadInterface", "OrdinaryDiffEq", "Plots", "Test"]

README.md

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,51 @@
11
# DyadBotComponents
2-
2+
3+
Dyad models of a two-wheeled balancing robot, together with controller
4+
architectures and controller-tuning scripts.
5+
6+
## Models (`dyad/`)
7+
8+
Plant models:
9+
10+
- `PlanarDyadBot`: planar model of the robot. A wheel rolling without slip,
11+
an inverted-pendulum body mounted on the wheel axis through a motor
12+
(`SimpleMotor`), and an IMU-like sensor. Inputs/outputs: motor torque in,
13+
position/velocity/tilt/tilt-rate out.
14+
- `DyadBot3D`: three-dimensional model with two individually spinning wheels
15+
with slip-based ground contact, allowing the body to tilt.
16+
17+
Closed-loop models around the planar plant:
18+
19+
- `AngleControlledDyadBot`: single PID loop stabilizing the tilt angle.
20+
- `CascadeControlledDyadBot`: cascade control with an inner tilt-angle loop
21+
and an outer position loop; all six controller gains are exposed as
22+
tunable top-level parameters.
23+
- `CascadeFFDyadBot`: the cascade extended with a feedforward generator
24+
(state-space system loaded from `data/ff_*.csv`) providing filtered
25+
position reference, tilt-angle feedforward and torque feedforward.
26+
- `LQGControlledDyadBot`: LQG controller with reference feedforward and
27+
integral action (state-space system loaded from `data/lqg_*.csv`).
28+
- `LQGTuningDyadBot`: analysis model used by the LQG design script.
29+
30+
## Controller tuning scripts (`scripts/`)
31+
32+
Each script activates the `scripts/` environment and can be run directly:
33+
34+
- `tune_angle_pid.jl`: PID autotuning of the inner angle loop
35+
(`PIDAutotuningAnalysisSpec`).
36+
- `tune_cascade_pid.jl`: PID autotuning of the outer position loop, plus
37+
robustness analysis (sensitivity functions, disk margins).
38+
- `tune_cascade_structured.jl`: structured tuning of all six cascade gains
39+
simultaneously (`StructuredAutoTuningProblem`) with per-loop sensitivity
40+
bounds and a pole-location constraint.
41+
- `compute_feedforward.jl`: computes the feedforward generator for
42+
`CascadeFFDyadBot` and stores it in `data/`.
43+
- `tune_lqg.jl`: LQG design (`LQGAnalysisSpec`) producing the controller
44+
used by `LQGControlledDyadBot`, stored in `data/`.
45+
46+
## Julia utilities (`src/`)
47+
48+
- `IMUKalmanFilter`: discrete-time Kalman filter for tilt estimation from
49+
gyro and accelerometer measurements, suitable for embedded use.
50+
- `balance_original.jl`: standalone Julia implementation of the original
51+
balance controller (not part of the package module).

assets/DyadBot3D.svg

Lines changed: 23 additions & 0 deletions
Loading

assets/PlanarDyadBot.svg

Lines changed: 26 additions & 0 deletions
Loading

data/ff_A.csv

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
-10.0,0.0,0.0,0.0,0.0,0.0
2+
-14.385214660422909,-28.180074429831286,6.410957714417602,-0.3411861344383693,5.624997830982584,0.42550666094531925
3+
0.0,-27.524943331176765,-9.07237685893729,2.716590525931721,7.52990536282097,2.0594837118224145
4+
0.0,0.0,-14.932517117613333,-5.81703692175721,-3.1098000123955742,0.39739413587492434
5+
0.0,0.0,0.0,6.515632666548096,0.17171105464563033,2.7772990425184405
6+
0.0,0.0,0.0,0.0,-2.919195371780299,-3.217509975872825

data/ff_B.csv

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
-4.0
2+
0.0
3+
0.0
4+
0.0
5+
0.0
6+
0.0

data/ff_C.csv

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
0.0,0.0,0.0,-5.7658425775341495,2.6953018995043134,0.6805161973061168
2+
0.0,0.0,0.0,-0.4228284556858375,0.19765547263031624,-1.393408592697625
3+
0.0,-0.7188567800353611,-0.44401143629627576,0.26102985042304827,0.05274672879236995,0.05575624395194494

data/ff_D.csv

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
0.0
2+
0.0
3+
0.0

data/ff_nx.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
6

data/lqg_A.csv

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
-104539.89472164716,-82946.37940461024,170471.733649769,-43438.76079375156,-8.881784197001252e-16,0.0,0.0,0.0,0.0,0.0
2+
12.645799600219386,-456.2882268933356,-31.342868024024973,-114.52536290621838,0.0,0.0,0.0,0.0,0.0,0.0
3+
0.0,0.0027478141674490697,0.14090008323445188,0.6162346940531964,0.0,0.0,0.0,0.0,0.0,0.0
4+
0.0,-0.0016211798221957199,-8.476450333092181,-3.333553335344639,0.0,0.0,0.0,0.0,0.0,0.0
5+
0.0,368.24823974916546,22.424506481378156,92.86343832465782,-1.0e-12,0.0,0.0,0.0,0.0,0.0
6+
0.0,0.0,0.0,0.0,0.0,-104539.89472164716,-82946.37940461024,170471.733649769,-43438.76079375156,-8.881784197001252e-16
7+
0.0,0.0,0.0,0.0,0.0,12.645799600219386,-456.2882268933356,-31.342868024024973,-114.52536290621838,0.0
8+
0.0,0.0,0.0,0.0,0.0,0.0,0.0027478141674490697,0.14090008323445188,0.6162346940531964,0.0
9+
0.0,0.0,0.0,0.0,0.0,0.0,-0.0016211798221957199,-8.476450333092181,-3.333553335344639,0.0
10+
0.0,0.0,0.0,0.0,0.0,0.0,368.24823974916546,22.424506481378156,92.86343832465782,-1.0e-12

0 commit comments

Comments
 (0)