Skip to content

Commit 8f9a7ab

Browse files
committed
use interpolation parameters in robot path planning
1 parent 1862516 commit 8f9a7ab

1 file changed

Lines changed: 27 additions & 11 deletions

File tree

src/robot/path_planning.jl

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -183,18 +183,34 @@ function KinematicPTP(; time, name, q0 = 0, q1 = 1, qd_max=1, qdd_max=1)
183183
qdd = RealOutput(; nout)
184184
end
185185

186-
q_vec, qd_vec, qdd_vec = point_to_point(time; q0 = q0, q1 = q1, qd_max, qdd_max)
187-
188-
interp_eqs = map(1:nout) do i
189-
qfun = CubicSpline(q_vec[:, i], time; extrapolation=ExtrapolationType.Constant)
190-
qdfun = LinearInterpolation(qd_vec[:, i], time; extrapolation=ExtrapolationType.Constant)
191-
qddfun = ConstantInterpolation(qdd_vec[:, i], time; extrapolation=ExtrapolationType.Constant)
192-
[q.u[i] ~ qfun(t)
193-
qd.u[i] ~ qdfun(t)
194-
qdd.u[i] ~ qddfun(t)]
186+
q_vec, qd_vec, qdd_vec = point_to_point(time; q0, q1, qd_max, qdd_max)
187+
188+
eqs = Equation[]
189+
pars = []
190+
for i in 1:nout
191+
qfun_val = CubicSpline(q_vec[:, i], time; extrapolation=ExtrapolationType.Constant)
192+
qdfun_val = LinearInterpolation(qd_vec[:, i], time; extrapolation=ExtrapolationType.Constant)
193+
qddfun_val = ConstantInterpolation(qdd_vec[:, i], time; extrapolation=ExtrapolationType.Constant)
194+
195+
Tq = typeof(qfun_val)
196+
Tqd = typeof(qdfun_val)
197+
Tqdd = typeof(qddfun_val)
198+
199+
qfun_name = Symbol(:qfun_, i)
200+
qdfun_name = Symbol(:qdfun_, i)
201+
qddfun_name = Symbol(:qddfun_, i)
202+
203+
qfun_sym = only(@parameters ($qfun_name::Tq)(..) = qfun_val)
204+
qdfun_sym = only(@parameters ($qdfun_name::Tqd)(..) = qdfun_val)
205+
qddfun_sym = only(@parameters ($qddfun_name::Tqdd)(..) = qddfun_val)
206+
push!(pars, qfun_sym, qdfun_sym, qddfun_sym)
207+
208+
push!(eqs, q.u[i] ~ qfun_sym(t))
209+
push!(eqs, qd.u[i] ~ qdfun_sym(t))
210+
push!(eqs, qdd.u[i] ~ qddfun_sym(t))
195211
end
196-
eqs = reduce(vcat, interp_eqs)
197-
System(eqs, t; name, systems)
212+
213+
System(eqs, t, [], pars; name, systems)
198214
end
199215

200216
"""

0 commit comments

Comments
 (0)