SMACC2
Loading...
Searching...
No Matches
cb_follow_ned_path.cpp
Go to the documentation of this file.
1// Copyright 2026 RobosoftAI Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15/*****************************************************************************************************************
16 *
17 * Authors: Brett Aldrich
18 *
19 ******************************************************************************************************************/
20
22
23#include <algorithm>
24
25namespace cl_px4_mr
26{
27
28CbFollowNedPath::CbFollowNedPath(std::vector<NedPoint> path, PathFollowerParams follower)
29: CbPx4PathFollowerBase(follower), path_(std::move(path))
30{
31}
32
33void CbFollowNedPath::setPath(std::vector<NedPoint> path)
34{
35 path_ = std::move(path);
36 // the base drops degenerate segments, which would shift reachedCount()
37 for (size_t i = 1; i < path_.size(); ++i)
38 {
40 {
41 RCLCPP_WARN(
42 getLogger(),
43 "CbFollowNedPath: vertices %zu and %zu are closer than minSegmentLength (%.2f m) - the "
44 "follower will merge them and reachedCount() will be off by one from there on",
46 }
47 }
48}
49
51{
52 if (path_.empty())
53 {
54 return 0;
55 }
56 const size_t idx = carrotVertexIndex();
57 // with the entry position prepended, followed vertex i is route vertex i-1
58 const size_t reached = followerParams_.prependCurrentPosition ? idx : idx + 1;
59 return std::min(reached, path_.size());
60}
61
62} // namespace cl_px4_mr
CbFollowNedPath(std::vector< NedPoint > path={}, PathFollowerParams follower={})
const std::vector< NedPoint > & path() const
void setPath(std::vector< NedPoint > path)
std::vector< NedPoint > path_
virtual rclcpp::Logger getLogger() const
float nedDistance(const NedPoint &a, const NedPoint &b)