|
| | CbPx4PathFollowerBase (PathFollowerParams params={}) |
| |
| virtual | ~CbPx4PathFollowerBase () |
| |
| template<typename TOrthogonal , typename TSourceObject > |
| void | onStateOrthogonalAllocation () |
| |
| void | setFollowerParams (const PathFollowerParams ¶ms) |
| |
| const PathFollowerParams & | followerParams () const |
| |
| void | onEntry () override |
| |
| void | onExit () override |
| |
| void | update () override |
| |
| template<typename TOrthogonal , typename TSourceObject > |
| void | onStateOrthogonalAllocation () |
| |
| virtual | ~CbPx4ClientBehaviorBase () |
| |
| void | setTimeout (std::chrono::milliseconds timeout) |
| |
| bool | hasTimeout () const |
| |
| template<typename TOrthogonal , typename TSourceObject > |
| void | onStateOrthogonalAllocation () |
| |
| virtual | ~SmaccAsyncClientBehavior () |
| |
| template<typename TCallback , typename T > |
| smacc2::SmaccSignalConnection | onSuccess (TCallback callback, T *object) |
| |
| template<typename TCallback , typename T > |
| smacc2::SmaccSignalConnection | onFinished (TCallback callback, T *object) |
| |
| template<typename TCallback , typename T > |
| smacc2::SmaccSignalConnection | onFailure (TCallback callback, T *object) |
| |
| void | requestForceFinish () |
| |
| void | executeOnEntry () override |
| |
| void | executeOnExit () override |
| |
| void | waitOnEntryThread (bool requestFinish) |
| |
| template<typename TCallbackMethod , typename T > |
| smacc2::SmaccSignalConnection | onSuccess (TCallbackMethod callback, T *object) |
| |
| template<typename TCallbackMethod , typename T > |
| smacc2::SmaccSignalConnection | onFinished (TCallbackMethod callback, T *object) |
| |
| template<typename TCallbackMethod , typename T > |
| smacc2::SmaccSignalConnection | onFailure (TCallbackMethod callback, T *object) |
| |
| | ISmaccClientBehavior () |
| |
| virtual | ~ISmaccClientBehavior () |
| |
| ISmaccStateMachine * | getStateMachine () |
| |
| std::string | getName () const |
| |
| template<typename SmaccClientType > |
| void | requiresClient (SmaccClientType *&storage) |
| |
| template<typename SmaccComponentType > |
| void | requiresComponent (SmaccComponentType *&storage, ComponentRequirement requirementType=ComponentRequirement::SOFT) |
| |
| template<typename SmaccComponentType > |
| void | requiresComponent (std::string name, SmaccComponentType *&storage, ComponentRequirement requirementType=ComponentRequirement::SOFT) |
| |
| | ISmaccUpdatable () |
| |
| | ISmaccUpdatable (rclcpp::Duration duration) |
| |
| void | executeUpdate (rclcpp::Node::SharedPtr node) |
| |
| void | setUpdatePeriod (rclcpp::Duration duration) |
| |
| void cl_px4_mr::CbPx4PathFollowerBase::onEntry |
( |
| ) |
|
|
overridevirtual |
Reimplemented from smacc2::ISmaccClientBehavior.
Definition at line 35 of file cb_px4_path_follower_base.cpp.
36{
38 {
39 RCLCPP_ERROR(
40 getLogger(),
"%s: local position / trajectory setpoint component missing - posting failure",
43 return;
44 }
46 {
47 RCLCPP_ERROR(
50 return;
51 }
52
53 NedPoint current;
59
60 std::vector<NedPoint> raw =
buildPath(current);
61 if (raw.empty())
62 {
63 RCLCPP_ERROR(
66 return;
67 }
68
71 {
72 NedPoint start = current;
73 start.yaw = std::numeric_limits<float>::quiet_NaN();
74 path_.push_back(start);
75 }
76 for (const NedPoint & v : raw)
77 {
79 {
80
81 path_.back().yaw = std::isnan(v.yaw) ?
path_.back().yaw : v.yaw;
82 continue;
83 }
85 }
86
92
94 const float lag = speed / 0.95f;
96 {
97 RCLCPP_WARN(
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",
102 }
103
105 {
107 this->
setTimeout(std::chrono::milliseconds(
static_cast<int64_t
>(seconds * 1000.0f)));
109 }
110
111 RCLCPP_INFO(
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)")
120 : "");
122
127}
CpTrajectorySetpoint * trajectorySetpoint_
void setTimeout(std::chrono::milliseconds timeout)
std::chrono::steady_clock::time_point lastUpdateTime_
NedPoint commandFor(float s)
std::atomic< bool > active_
virtual std::vector< NedPoint > buildPath(const NedPoint ¤t)=0
virtual void onPathStarted(const std::vector< NedPoint > &)
virtual const char * behaviorName() const
void setPositionNED(float x, float y, float z, float yaw=std::numeric_limits< float >::quiet_NaN())
virtual rclcpp::Logger getLogger() const
float nedDistance(const NedPoint &a, const NedPoint &b)
std::vector< float > cumulativeLengths(const std::vector< NedPoint > &path)
bool prependCurrentPosition
References active_, cl_px4_mr::PathFollowerParams::autoTimeoutFactor, behaviorName(), buildPath(), carrotVertex_, commandFor(), cumLen_, cl_px4_mr::cumulativeLengths(), entryHeading_, followerParams_, cl_px4_mr::CpVehicleLocalPosition::getHeading(), smacc2::ISmaccClientBehavior::getLogger(), cl_px4_mr::CpVehicleLocalPosition::getX(), cl_px4_mr::CpVehicleLocalPosition::getY(), cl_px4_mr::CpVehicleLocalPosition::getZ(), cl_px4_mr::PathFollowerParams::groundSpeed, cl_px4_mr::CbPx4ClientBehaviorBase::hasTimeout(), cl_px4_mr::CpVehicleLocalPosition::isValid(), lastCmd_, lastProgressDecile_, lastUpdateTime_, cl_px4_mr::PathFollowerParams::leash, cl_px4_mr::CbPx4ClientBehaviorBase::localPosition_, cl_px4_mr::PathFollowerParams::minSegmentLength, cl_px4_mr::nedDistance(), onPathStarted(), path_, cl_px4_mr::CbPx4ClientBehaviorBase::postPx4Failure(), cl_px4_mr::PathFollowerParams::prependCurrentPosition, sCarrot_, cl_px4_mr::CpTrajectorySetpoint::setPositionNED(), cl_px4_mr::CbPx4ClientBehaviorBase::setTimeout(), totalLen_, cl_px4_mr::CbPx4ClientBehaviorBase::trajectorySetpoint_, tunnelCentering_, cl_px4_mr::PathFollowerParams::useTunnelCentering, cl_px4_mr::NedPoint::x, cl_px4_mr::NedPoint::y, cl_px4_mr::NedPoint::yaw, and cl_px4_mr::NedPoint::z.
| void cl_px4_mr::CbPx4PathFollowerBase::update |
( |
| ) |
|
|
overridevirtual |
Reimplemented from cl_px4_mr::CbPx4ClientBehaviorBase.
Definition at line 142 of file cb_px4_path_follower_base.cpp.
143{
145
147 {
148 return;
149 }
150
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);
155
157 {
158
159 return;
160 }
161
162 NedPoint vehicle;
166
167
168
172 {
174 }
175
178
179
180
181 {
183 const size_t idx = ub == 0 ? 0 : ub - 1;
185 }
186
189 {
191 RCLCPP_INFO(
193 }
194
195
196
198 {
201 const float dz = std::fabs(vehicle.z - end.z);
203 {
205 RCLCPP_INFO(
206 getLogger(),
"%s: path complete (xy err %.2f m, z err %.2f m) - posting success",
210 }
211 }
212}
virtual void onPathCompleted()
float nedDistanceXY(const NedPoint &a, const NedPoint &b)
References active_, cl_px4_mr::PathFollowerParams::arrivalXyTol, cl_px4_mr::PathFollowerParams::arrivalZTol, behaviorName(), carrotVertex_, commandFor(), cumLen_, followerParams_, smacc2::ISmaccClientBehavior::getLogger(), cl_px4_mr::CpVehicleLocalPosition::getX(), cl_px4_mr::CpVehicleLocalPosition::getY(), cl_px4_mr::CpVehicleLocalPosition::getZ(), cl_px4_mr::PathFollowerParams::groundSpeed, cl_px4_mr::CpVehicleLocalPosition::isValid(), lastCmd_, lastProgressDecile_, lastUpdateTime_, cl_px4_mr::PathFollowerParams::leash, cl_px4_mr::CbPx4ClientBehaviorBase::localPosition_, cl_px4_mr::nedDistance(), cl_px4_mr::nedDistanceXY(), onPathCompleted(), path_, cl_px4_mr::CbPx4ClientBehaviorBase::postPx4Success(), progressFraction(), sCarrot_, cl_px4_mr::CpTrajectorySetpoint::setPositionNED(), totalLen_, cl_px4_mr::CbPx4ClientBehaviorBase::trajectorySetpoint_, cl_px4_mr::CbPx4ClientBehaviorBase::update(), cl_px4_mr::NedPoint::x, cl_px4_mr::NedPoint::y, cl_px4_mr::NedPoint::yaw, and cl_px4_mr::NedPoint::z.