40 getLogger(),
"%s: local position / trajectory setpoint component missing - posting failure",
60 std::vector<NedPoint> raw =
buildPath(current);
73 start.
yaw = std::numeric_limits<float>::quiet_NaN();
74 path_.push_back(start);
81 path_.back().yaw = std::isnan(v.yaw) ?
path_.back().yaw : v.yaw;
94 const float lag = speed / 0.95f;
99 "%s: leash %.1f m is below 1.2x the expected tracking lag (%.1f m at %.1f m/s) - effective "
100 "speed will be throttled to ~%.1f m/s",
107 this->
setTimeout(std::chrono::milliseconds(
static_cast<int64_t
>(seconds * 1000.0f)));
113 "%s: following %zu vertices, %.1f m at %.1f m/s (leash %.1f m) from NED (%.1f, %.1f, %.1f) "
114 "to (%.1f, %.1f, %.1f)%s",
119 :
" (tunnel centering requested but no component)")
137 getLogger(),
"%s: exiting at %.0f%% - holding at last setpoint (%.1f, %.1f, %.1f)",
151 const auto now = std::chrono::steady_clock::now();
152 float dt = std::chrono::duration<float>(now -
lastUpdateTime_).count();
154 dt = std::clamp(dt, 0.0f, 0.5f);
183 const size_t idx = ub == 0 ? 0 : ub - 1;
201 const float dz = std::fabs(vehicle.
z - end.
z);
206 getLogger(),
"%s: path complete (xy err %.2f m, z err %.2f m) - posting success",
216 if (
path_.size() < 2)
220 const size_t i0 = std::min(segmentIndex,
path_.size() - 2);
223 const float dx = b.
x - a.
x;
224 const float dy = b.
y - a.
y;
225 if (std::hypot(dx, dy) < 1e-3f)
229 return std::atan2(dy, dx);
246 if (std::isnan(cmd.
yaw))
275 const float misalign =
wrapPi(heading - cmd.
yaw);
276 if (std::fabs(misalign) > 0.7854f)
282 const float s = std::sin(heading);
283 const float c = std::cos(heading);
284 cmd.
x += lateral * s;
285 cmd.
y -= lateral * c;
CpVehicleLocalPosition * localPosition_
CpTrajectorySetpoint * trajectorySetpoint_
void setTimeout(std::chrono::milliseconds timeout)
std::chrono::steady_clock::time_point lastUpdateTime_
std::vector< NedPoint > path_
CbPx4PathFollowerBase(PathFollowerParams params={})
NedPoint commandFor(float s)
std::atomic< bool > active_
virtual std::vector< NedPoint > buildPath(const NedPoint ¤t)=0
virtual void onPathStarted(const std::vector< NedPoint > &)
float tangentYawAt(size_t segmentIndex) const
std::vector< float > cumLen_
CpTunnelCentering * tunnelCentering_
PathFollowerParams followerParams_
virtual const char * behaviorName() const
void applyCentering(NedPoint &cmd) const
std::atomic< size_t > carrotVertex_
virtual void onPathCompleted()
float progressFraction() const
void setPositionNED(float x, float y, float z, float yaw=std::numeric_limits< float >::quiet_NaN())
float verticalOffsetM() const
float lateralOffsetM() const
virtual rclcpp::Logger getLogger() const
NedPoint sampleAtArcLength(const std::vector< NedPoint > &path, const std::vector< float > &cum, float s, size_t *segmentIndex=nullptr)
float nedDistance(const NedPoint &a, const NedPoint &b)
float nedDistanceXY(const NedPoint &a, const NedPoint &b)
float wrapPi(float angle)
std::vector< float > cumulativeLengths(const std::vector< NedPoint > &path)
bool prependCurrentPosition