| 64 | } |
| 65 | |
| 66 | double ViewNode::computeCost(const Vector3d& p1, const Vector3d& p2, const double& y1, |
| 67 | const double& y2, const Vector3d& v1, const double& yd1, vector<Vector3d>& path) |
| 68 | { |
| 69 | // Cost of position change |
| 70 | double pos_cost = ViewNode::searchPath(p1, p2, path) / vm_; |
| 71 | |
| 72 | // Consider velocity change |
| 73 | if (v1.norm() > 1e-3) { |
| 74 | Vector3d dir = (p2 - p1).normalized(); |
| 75 | Vector3d vdir = v1.normalized(); |
| 76 | double diff = acos(vdir.dot(dir)); |
| 77 | pos_cost += w_dir_ * diff; |
| 78 | // double vc = v1.dot(dir); |
| 79 | // pos_cost += w_dir_ * pow(vm_ - fabs(vc), 2) / (2 * vm_ * am_); |
| 80 | // if (vc < 0) |
| 81 | // pos_cost += w_dir_ * 2 * fabs(vc) / am_; |
| 82 | } |
| 83 | |
| 84 | // Cost of yaw change |
| 85 | double diff = fabs(y2 - y1); |
| 86 | diff = min(diff, 2 * M_PI - diff); |
| 87 | double yaw_cost = diff / yd_; |
| 88 | return max(pos_cost, yaw_cost); |
| 89 | |
| 90 | // // Consider yaw rate change |
| 91 | // if (fabs(yd1) > 1e-3) |
| 92 | // { |
| 93 | // double diff1 = y2 - y1; |
| 94 | // while (diff1 < -M_PI) |
| 95 | // diff1 += 2 * M_PI; |
| 96 | // while (diff1 > M_PI) |
| 97 | // diff1 -= 2 * M_PI; |
| 98 | // double diff2 = diff1 > 0 ? diff1 - 2 * M_PI : 2 * M_PI + diff1; |
| 99 | // } |
| 100 | // else |
| 101 | // { |
| 102 | // } |
| 103 | } |
| 104 | |
| 105 | double ViewNode::computePathLen(const Eigen::Vector3d& pose1, const Eigen::Vector3d& pose2) |
| 106 | { |