getNextStates()函数的功能

 


/**
 * Compute the possible next moves according to
 * the kinematic bicycle model constraints.
 *根据运动自行车模型约束计算可能的下一步移动。
 * Kinematic Bicycle Model centered the rear wheel.运动自行车模型以后轮为中心。
 *
 */
 //vector<State> 返回值类型   State::对象内部函数
std::vector<State> State::getNextStates()
{
  std::vector<State> next;
  State state;

  // Bicycle model parameters自行车模型参数
  double alpha = 0;
  double d_theta = 0;
  double radius = 0; // rotation radius转弯半径
  double dist = 30.0; // distance travelled within a unit time
                      //单位时间内的行进距离
  // Try out possible values of alpha尝试可能的alpha值
  // among 3 angles: [-VEH_M_ALPHA, 0, VEH_M_ALPHA].
  for (alpha = -VEH_M_ALPHA; alpha <= VEH_M_ALPHA + 0.001;alpha += VEH_M_ALPHA)
  {
    //单位时间航向角的增量
    d_theta = dist * tan(alpha * PI / 180) / VEH_LEN;//#define VEH_LEN 34   车辆轴距

    if (abs(d_theta) < 0.001) { // Forward 前进
      state.x = x + dist * cos(theta * 2.0 * PI / Theta);//#define Theta 72
      //theta * 2.0 * PI / Theta  不懂这样算的目的是什么
      state.y = y + dist * sin(theta * 2.0 * PI / Theta);
      state.theta = theta;
    }
    else
    { // Turning 转向
      // Bicycle model centered at the rear wheel以后轮为中心的自行车模型
      radius = VEH_LEN / tan(alpha * PI / 180);

        //#define Theta 72 // maximal angle
        //#define Theta_Res 5 // angle resolution 角度分辨率
      state.x = x + radius * sin(theta * 2.0 * PI / Theta + d_theta)
                  - radius * sin(theta * 2.0 * PI / Theta);
      state.y = y - radius * cos(theta * 2.0 * PI / Theta + d_theta)
                  + radius * cos(theta * 2.0 * PI / Theta);
        

      // new theta = theta + d_theta
      double new_theta = theta + d_theta * 180 / PI / Theta_Res;

      // normalize
      if (new_theta > 0) {
        state.theta = fmod(new_theta, Theta);//new_theta除以Theta之后的余数
      }
      else {
        state.theta = new_theta + Theta;
      }
    }

    // Convert to grid-map coordinates.
    state.gx = state.x / Grid_Res;//#define Grid_Res 10
    state.gy = state.y / Grid_Res;
    state.gtheta = state.theta + 0.01;

    next.push_back(state);
  }


  return next;
}

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值