1001101_QI 2022-05-17 21:01 采纳率: 89.5%
浏览 33
已结题

C++这一句啥意思呀std::pair<double, double> p_n;

下面这一句:
std::pair<double, double> p_n;
完整代码:

  //调用函数七:判断两节点之间是否有障碍物
  //obstacleFree
  bool RRTstarPlannerROS::obstacleFree(Node node_nearest, double px, double py)
  {
    std::pair<double, double> p_n;
    p_n.first = 0.0;
    p_n.second = 0.0;

    double dist = distance(node_nearest.x, node_nearest.y, px, py);
    if (dist < resolution_)
    {
      if (collision(px, py))
        return false;
      else
        return true;
    }
    else
    {
      int value = int(floor(dist/resolution_));
      double theta = atan2(py - node_nearest.y, px - node_nearest.x);
      int n = 1;
      for (int i = 0;i < value; i++)
      {
        p_n.first = node_nearest.x + n*resolution_*cos(theta);
        p_n.second = node_nearest.y + n*resolution_*sin(theta);
        if (collision(p_n.first, p_n.second))
          return false;
        n++;
      }
      return true;
    }
  }

  • 写回答

1条回答 默认 最新

  • filanlu 2022-05-17 21:42
    关注

    pair可以看成一个两个成员的结构体

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 6月1日
  • 已采纳回答 5月24日
  • 创建了问题 5月17日