39 getLogger(),
"%s: local position / trajectory setpoint component missing - posting failure",
59 std::vector<NedPoint> raw =
buildPath(current);
72 start.
yaw = std::numeric_limits<float>::quiet_NaN();
73 path_.push_back(start);
80 path_.back().yaw = std::isnan(v.yaw) ?
path_.back().yaw : v.yaw;
92 const float lag = speed / 0.95f;
97 "%s: leash %.1f m is below 1.2x the expected tracking lag (%.1f m at %.1f m/s) - effective "
98 "speed will be throttled to ~%.1f m/s",
105 this->
setTimeout(std::chrono::milliseconds(
static_cast<int64_t
>(seconds * 1000.0f)));
111 "%s: following %zu vertices, %.1f m at %.1f m/s (leash %.1f m) from NED (%.1f, %.1f, %.1f) "
112 "to (%.1f, %.1f, %.1f)",
131 getLogger(),
"%s: exiting at %.0f%% - holding at last setpoint (%.1f, %.1f, %.1f)",
145 const auto now = std::chrono::steady_clock::now();
146 float dt = std::chrono::duration<float>(now -
lastUpdateTime_).count();
148 dt = std::clamp(dt, 0.0f, 0.5f);
185 const float dz = std::fabs(vehicle.
z - end.
z);
190 getLogger(),
"%s: path complete (xy err %.2f m, z err %.2f m) - posting success",
200 if (
path_.size() < 2)
204 const size_t i0 = std::min(segmentIndex,
path_.size() - 2);
207 const float dx = b.
x - a.
x;
208 const float dy = b.
y - a.
y;
209 if (std::hypot(dx, dy) < 1e-3f)
213 return std::atan2(dy, dx);
230 if (std::isnan(cmd.
yaw))
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_
PathFollowerParams followerParams_
virtual const char * behaviorName() const
virtual void onPathCompleted()
float progressFraction() const
void setPositionNED(float x, float y, float z, float yaw=std::numeric_limits< float >::quiet_NaN())
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