Skip to content

Commit 2ce8153

Browse files
committed
removed: try blocks in KalmanCovariances
They are useless, on a second thought. The exception thrown in `ModelPredictiveControl.inv!` and the associated stacktrace is already clear enough.
1 parent c715b99 commit 2ce8153

1 file changed

Lines changed: 7 additions & 30 deletions

File tree

‎src/estimator/construct.jl‎

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -100,43 +100,20 @@ struct KalmanCovariances{
100100
invP̄ = empty_similar(P̂_0)
101101
else
102102
invP̄ = copy(P̂_0)
103-
try
104-
inv!(invP̄)
105-
catch err
106-
if err isa PosDefException
107-
error("P̂_0 is not positive definite")
108-
else
109-
rethrow()
110-
end
111-
end
103+
inv!(invP̄)
112104
end
113105
end
114-
Q̂ = Hermitian(Q̂, :L)
115-
R̂ = Hermitian(R̂, :L)
106+
Q̂ = Hermitian(Q̂, :L)
107+
R̂ = Hermitian(R̂, :L)
116108
if isnothing(He) # the following variables are only for MovingHorizonEstimator:
117109
invQ̂_He = empty_similar(Q̂)
118110
invR̂_He = empty_similar(R̂)
119111
else
120-
invQ̂, invR̂ = copy(Q̂), copy(R̂)
121-
try
122-
inv!(invQ̂)
123-
catch err
124-
if err isa PosDefException
125-
error("Q̂ is not positive definite")
126-
else
127-
rethrow()
128-
end
129-
end
112+
invQ̂ = copy(Q̂)
113+
inv!(invQ̂)
130114
invQ̂_He = Hermitian(repeatdiag(invQ̂, He), :L)
131-
try
132-
inv!(invR̂)
133-
catch err
134-
if err isa PosDefException
135-
error("R̂ is not positive definite")
136-
else
137-
rethrow()
138-
end
139-
end
115+
invR̂ = copy(R̂)
116+
inv!(invR̂)
140117
invR̂_He = Hermitian(repeatdiag(invR̂, He), :L)
141118
end
142119
return new{NT, Q̂C, R̂C}(P̂_0, P̂, Q̂, R̂, invP̄, invQ̂_He, invR̂_He)

0 commit comments

Comments
 (0)