1 Star 0 Fork 1

chuangshiji789/OptimTraj

forked from NUDTexplorer/OptimTraj 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
collectConstraints.m 1.15 KB
一键复制 编辑 原始数据 按行查看 历史
function [c, ceq] = collectConstraints(t,x,u,defects, pathCst, bndCst)
% [c, ceq] = collectConstraints(t,x,u,defects, pathCst, bndCst)
%
% OptimTraj utility function.
%
% Collects the defects, calls user-defined constraints, and then packs
% everything up into a form that is good for fmincon.
%
% INPUTS:
% t = time vector
% x = state matrix
% u = control matrix
% defects = defects matrix
% pathCst = user-defined path constraint function
% bndCst = user-defined boundary constraint function
%
% OUTPUTS:
% c = inequality constraint for fmincon
% ceq = equality constraint for fmincon
%
ceq_dyn = reshape(defects,numel(defects),1);
%%%% Compute the user-defined constraints:
if isempty(pathCst)
c_path = [];
ceq_path = [];
else
[c_pathRaw, ceq_pathRaw] = pathCst(t,x,u);
c_path = reshape(c_pathRaw,numel(c_pathRaw),1);
ceq_path = reshape(ceq_pathRaw,numel(ceq_pathRaw),1);
end
if isempty(bndCst)
c_bnd = [];
ceq_bnd = [];
else
t0 = t(1);
tF = t(end);
x0 = x(:,1);
xF = x(:,end);
[c_bnd, ceq_bnd] = bndCst(t0,x0,tF,xF);
end
%%%% Pack everything up:
c = [c_path;c_bnd];
ceq = [ceq_dyn; ceq_path; ceq_bnd];
end
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/chuangshiji789/OptimTraj.git
git@gitee.com:chuangshiji789/OptimTraj.git
chuangshiji789
OptimTraj
OptimTraj
master

搜索帮助

23e8dbc6 1850385 7e0993f3 1850385