Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Pinoxchio
apollo
提交
70bf6e26
A
apollo
项目概览
Pinoxchio
/
apollo
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
apollo
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
70bf6e26
编写于
7月 24, 2017
作者:
Q
Qi Luo
提交者:
Dong Li
7月 24, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Polish and fix MPC/QP solver
上级
68f6a785
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
20 addition
and
29 deletion
+20
-29
modules/common/math/mpc_solver.cc
modules/common/math/mpc_solver.cc
+4
-8
modules/common/math/mpc_solver_test.cc
modules/common/math/mpc_solver_test.cc
+13
-19
modules/common/math/qp_solver/BUILD
modules/common/math/qp_solver/BUILD
+1
-0
modules/common/math/qp_solver/qp_solver.h
modules/common/math/qp_solver/qp_solver.h
+2
-2
未找到文件。
modules/common/math/mpc_solver.cc
浏览文件 @
70bf6e26
...
...
@@ -120,16 +120,17 @@ void SolveLinearMPC(const Matrix &matrix_a,
matrix_uu
.
rows
());
Eigen
::
MatrixXd
matrix_inequality_constrain
=
Eigen
::
MatrixXd
::
Zero
(
matrix_ll
.
rows
()
+
matrix_uu
.
rows
(),
matrix_ll
.
rows
());
matrix_inequality_constrain
<<
matrix_inequality_constrain_ll
,
matrix_inequality_constrain_uu
;
matrix_inequality_constrain
<<
-
matrix_inequality_constrain_ll
,
-
matrix_inequality_constrain_uu
;
Eigen
::
MatrixXd
matrix_inequality_boundary
=
Eigen
::
MatrixXd
::
Zero
(
matrix_ll
.
rows
()
+
matrix_uu
.
rows
(),
matrix_ll
.
cols
());
matrix_inequality_boundary
<<
matrix_ll
,
matrix_uu
;
-
matrix_uu
;
Eigen
::
MatrixXd
matrix_equality_constrain
=
Eigen
::
MatrixXd
::
Zero
(
matrix_ll
.
rows
()
+
matrix_uu
.
rows
(),
matrix_ll
.
rows
());
Eigen
::
MatrixXd
matrix_equality_boundary
=
Eigen
::
MatrixXd
::
Zero
(
matrix_ll
.
rows
()
+
matrix_uu
.
rows
(),
matrix_ll
.
cols
());
std
::
unique_ptr
<
QPSolver
>
qp_solver
(
new
ActiveSetQPSolver
(
matrix_m1
,
matrix_m2
,
matrix_inequality_constrain
,
...
...
@@ -139,11 +140,6 @@ void SolveLinearMPC(const Matrix &matrix_a,
qp_solver
->
solve
();
matrix_v
=
qp_solver
->
params
();
/*
// Method 2: QP_SMO_Solver
SolveQPSMO(matrix_m1, matrix_m2, matrix_ll, matrix_uu, eps, max_iter,
&matrix_v);
i*/
for
(
unsigned
int
i
=
0
;
i
<
horizon
;
++
i
)
{
(
*
control
)[
i
]
=
matrix_v
.
block
(
i
*
(
*
control
)[
0
].
rows
(),
0
,
(
*
control
)[
0
].
rows
(),
1
);
...
...
modules/common/math/mpc_solver_test.cc
浏览文件 @
70bf6e26
...
...
@@ -21,7 +21,7 @@
namespace
apollo
{
namespace
common
{
namespace
math
{
/*
TEST
(
MPCSolverTest
,
MPC
)
{
const
int
STATES
=
4
;
const
int
CONTROLS
=
1
;
...
...
@@ -57,10 +57,10 @@ TEST(MPCSolverTest, MPC) {
R
<<
1
;
Eigen
::
MatrixXd
lower_bound
(
CONTROLS
,
1
);
lower_bound << -
0.2
;
lower_bound
<<
-
10
;
Eigen
::
MatrixXd
upper_bound
(
CONTROLS
,
1
);
upper_bound <<
0.6
;
upper_bound
<<
10
;
Eigen
::
MatrixXd
initial_state
(
STATES
,
1
);
initial_state
<<
0
,
...
...
@@ -80,7 +80,6 @@ TEST(MPCSolverTest, MPC) {
control_matrix
<<
0
;
std
::
vector
<
Eigen
::
MatrixXd
>
control
(
HORIZON
,
control_matrix
);
for
(
unsigned
int
i
=
0
;
i
<
control
.
size
();
++
i
)
{
for
(
unsigned
int
i
=
1
;
i
<
control
.
size
();
++
i
)
{
control
[
i
-
1
]
=
control
[
i
];
...
...
@@ -88,18 +87,17 @@ TEST(MPCSolverTest, MPC) {
SolveLinearMPC
(
A
,
B
,
C
,
Q
,
R
,
lower_bound
,
upper_bound
,
initial_state
,
reference
,
EPS
,
MAX_ITER
,
&
control
);
EXPECT_FLOAT_EQ
(
upper_bound
(
0
),
control
[
0
](
0
));
initial_state = A * initial_state + B * control[0](0) + C;
}
Eigen
::
MatrixXd
initial_state1
(
STATES
,
1
);
initial_state1 << 30
0
,
30
0
,
initial_state1
<<
30
,
30
,
0
,
0
;
Eigen
::
MatrixXd
reference_state1
(
STATES
,
1
);
reference_state1 <<
20
0,
20
0,
reference_state1
<<
0
,
0
,
0
,
0
;
...
...
@@ -107,7 +105,6 @@ TEST(MPCSolverTest, MPC) {
control_matrix
<<
0
;
std
::
vector
<
Eigen
::
MatrixXd
>
control1
(
HORIZON
,
control_matrix
);
for
(
unsigned
int
i
=
0
;
i
<
control1
.
size
();
++
i
)
{
for
(
unsigned
int
i
=
1
;
i
<
control
.
size
();
++
i
)
{
control1
[
i
-
1
]
=
control1
[
i
];
...
...
@@ -115,18 +112,17 @@ TEST(MPCSolverTest, MPC) {
SolveLinearMPC
(
A
,
B
,
C
,
Q
,
R
,
lower_bound
,
upper_bound
,
initial_state1
,
reference1
,
EPS
,
MAX_ITER
,
&
control1
);
EXPECT_FLOAT_EQ
(
lower_bound
(
0
),
control1
[
0
](
0
));
initial_state1 = A * initial_state1 + B * control1[0](0) + C;
}
Eigen
::
MatrixXd
initial_state2
(
STATES
,
1
);
initial_state2 << 30
0
,
30
0
,
initial_state2
<<
30
,
30
,
0
,
0
;
Eigen
::
MatrixXd
reference_state2
(
STATES
,
1
);
reference_state2 << 30
0
,
30
0
,
reference_state2
<<
30
,
30
,
0
,
0
;
...
...
@@ -141,11 +137,9 @@ TEST(MPCSolverTest, MPC) {
}
SolveLinearMPC
(
A
,
B
,
C
,
Q
,
R
,
lower_bound
,
upper_bound
,
initial_state2
,
reference2
,
EPS
,
MAX_ITER
,
&
control2
);
EXPECT_FLOAT_EQ(0.0, control2[0](0));
initial_state2 = A * initial_state2 + B * control2[0](0) + C;
}
EXPECT_NEAR
(
0.0
,
control2
[
0
](
0
),
1e-7
);
}
}
*/
}
// namespace math
}
// namespace common
}
// namespace apollo
...
...
modules/common/math/qp_solver/BUILD
浏览文件 @
70bf6e26
...
...
@@ -41,6 +41,7 @@ cc_library(
"//modules/common/math/qp_solver:qp_solver_gflags"
,
"@eigen//:eigen"
,
"@qp_oases//:qp_oases"
,
"//modules/common:log"
,
],
)
...
...
modules/common/math/qp_solver/qp_solver.h
浏览文件 @
70bf6e26
...
...
@@ -19,8 +19,8 @@
* @brief: quadratic programming base class
*
* min_x : q(x) = 0.5 * x^T * Q * x + x^T c
* with respect to: A * x = b (
in
equality constraint)
* C * x >= d (equality constraint)
* with respect to: A * x = b (equality constraint)
* C * x >= d (
in
equality constraint)
**/
#ifndef MODULES_COMMON_MATH_QP_SOLVER_QP_SOLVER_H_
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录