|
@@ -113,9 +113,9 @@ class FG_eval_half_agv {
|
|
|
}
|
|
|
|
|
|
|
|
|
- if(m_statu.size()==2+8){
|
|
|
+ if(m_statu.size()==2+12){
|
|
|
//与障碍物的距离
|
|
|
- for(int i=0;i<4;++i) {
|
|
|
+ for(int i=0;i<6;++i) {
|
|
|
double ox=m_statu[2+i*2];
|
|
|
double oy=m_statu[2+i*2+1];
|
|
|
for (int t = 0; t < N; ++t) {
|
|
@@ -125,7 +125,7 @@ class FG_eval_half_agv {
|
|
|
* */
|
|
|
CppAD::AD<double> ra=(ox-vars[nx+t])*CppAD::cos(vars[nth+t]) -(oy-vars[ny+t])*CppAD::sin(vars[nth+t]);
|
|
|
CppAD::AD<double> rb=(ox-vars[nx+t])*CppAD::sin(vars[nth+t]) +(oy-vars[ny+t])*CppAD::cos(vars[nth+t]);
|
|
|
- fg[1 + nobs + N*i+t] = CppAD::pow(ra/obs_w,8)+CppAD::pow(rb/obs_w,8);
|
|
|
+ fg[1 + nobs + N*i+t] = CppAD::pow(ra/obs_w,8)+CppAD::pow(rb/obs_h,8);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -237,9 +237,13 @@ MpcError LoadedMPC::solve(Trajectory trajectory, Pose2d target,Eigen::VectorXd s
|
|
|
* 障碍物是否进入 碰撞检测范围内
|
|
|
*/
|
|
|
float distance=Pose2d::distance(obs_relative_pose_,Pose2d(0,0,0));
|
|
|
- if(distance<5){
|
|
|
- n_constraints = N * (5+4);
|
|
|
+ bool find_obs=false;
|
|
|
+ if(distance<20){
|
|
|
+ //printf(" mpc find obs ,w=%f,h=%f\n",obs_w_,obs_h_);
|
|
|
+ find_obs=true;
|
|
|
}
|
|
|
+ if(find_obs) n_constraints = N * (5+6);
|
|
|
+
|
|
|
Dvector constraints_lowerbound(n_constraints);
|
|
|
Dvector constraints_upperbound(n_constraints);
|
|
|
for (int i = 0; i < n_constraints; i++)
|
|
@@ -261,8 +265,8 @@ MpcError LoadedMPC::solve(Trajectory trajectory, Pose2d target,Eigen::VectorXd s
|
|
|
}
|
|
|
|
|
|
// 与障碍物保持距离的约束
|
|
|
- if(distance<5) {
|
|
|
- for (int i = nobs; i < nobs + 4*N; ++i) {
|
|
|
+ if(find_obs) {
|
|
|
+ for (int i = nobs; i < nobs + 6*N; ++i) {
|
|
|
constraints_lowerbound[i] = 1.0;
|
|
|
constraints_upperbound[i] = 1e19;
|
|
|
}
|
|
@@ -289,10 +293,12 @@ MpcError LoadedMPC::solve(Trajectory trajectory, Pose2d target,Eigen::VectorXd s
|
|
|
}
|
|
|
|
|
|
Eigen::VectorXd statu_velocity(2);
|
|
|
- if(distance<5){
|
|
|
- statu_velocity=Eigen::VectorXd(2+8);
|
|
|
- std::vector<Pose2d> vertexs=Pose2d::generate_rectangle_vertexs(obs_relative_pose_,2.5,1.3);
|
|
|
+ if(find_obs){
|
|
|
+ statu_velocity=Eigen::VectorXd(2+12);
|
|
|
+
|
|
|
+ std::vector<Pose2d> vertexs=Pose2d::generate_rectangle_vertexs(obs_relative_pose_,obs_w_*2,obs_h_*2);
|
|
|
for(int i=0;i<vertexs.size();++i){
|
|
|
+ //std::cout<<"vetex:"<<vertexs[i]<<std::endl;
|
|
|
statu_velocity[2+i*2]=vertexs[i].x();
|
|
|
statu_velocity[2+i*2+1]=vertexs[i].y();
|
|
|
}
|
|
@@ -328,7 +334,7 @@ MpcError LoadedMPC::solve(Trajectory trajectory, Pose2d target,Eigen::VectorXd s
|
|
|
{
|
|
|
printf(" mpc failed statu : %d input: %.4f %.5f(%.5f) relative:(%f,%f) \n",solution.status,line_velocity,
|
|
|
wmg,angular,obs_relative_pose_.x(),obs_relative_pose_.y());
|
|
|
- if (solution.status == CppAD::ipopt::solve_result<Dvector>::invalid_number_detected)
|
|
|
+ if (solution.status == CppAD::ipopt::solve_result<Dvector>::local_infeasibility)
|
|
|
return no_solution;
|
|
|
return failed;
|
|
|
}
|
|
@@ -348,9 +354,9 @@ MpcError LoadedMPC::solve(Trajectory trajectory, Pose2d target,Eigen::VectorXd s
|
|
|
if (solve_angular < 0) correct_angular = -correct_angular;
|
|
|
}
|
|
|
///-----
|
|
|
- printf("input : %.4f %.5f(%.5f) output : %.4f %.5f(%.5f) ref : %.3f relative:(%f,%f) time:%.3f\n",
|
|
|
+ printf("input : %.4f %.5f(%.5f) output : %.4f %.5f(%.5f) ref : %.3f obs relative:(%f,%f) time:%.3f\n",
|
|
|
line_velocity,wmg,angular,solve_velocity,solve_angular,correct_angular,
|
|
|
- ref_velocity,targetPoseInAGV.x(),targetPoseInAGV.y(),time);
|
|
|
+ ref_velocity,obs_relative_pose_.x(),obs_relative_pose_.y(),time);
|
|
|
if(solve_velocity>=0 && solve_velocity<min_velocity_)
|
|
|
solve_velocity=min_velocity_;
|
|
|
if(solve_velocity<0 && solve_velocity>-min_velocity_)
|