SMACC2
Loading...
Searching...
No Matches
cb_load_kml_mission.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
17
18namespace cl_px4_mr
19{
20
22 std::string absoluteKmlPath, std::vector<GeoPoint> fallbackBackbone)
23: path_(std::move(absoluteKmlPath)), fallback_(std::move(fallbackBackbone))
24{
25}
26
28{
29 if (kmlLoader_ == nullptr)
30 {
31 RCLCPP_ERROR(getLogger(), "CbLoadKmlMission: CpKmlMissionLoader component missing");
32 this->postPx4Failure();
33 return;
34 }
35
36 RCLCPP_INFO(getLogger(), "CbLoadKmlMission: loading backbone from '%s'", path_.c_str());
37 const KmlLoadResult result = kmlLoader_->loadFile(path_);
38
39 if (result.ok)
40 {
41 RCLCPP_INFO(
42 getLogger(), "CbLoadKmlMission: %zu backbone points loaded from file", result.pointCount);
43 this->postPx4Success();
44 return;
45 }
46
47 if (!fallback_.empty())
48 {
49 kmlLoader_->setMission(fallback_, "fallback:compiled-in");
50 RCLCPP_WARN(
51 getLogger(),
52 "CbLoadKmlMission: KML unavailable (%s) - using compiled-in fallback backbone (%zu points)",
53 result.error.c_str(), fallback_.size());
54 this->postPx4Success();
55 return;
56 }
57
58 RCLCPP_ERROR(
59 getLogger(), "CbLoadKmlMission: KML unavailable (%s) and no fallback backbone supplied",
60 result.error.c_str());
61 this->postPx4Failure();
62}
63
65
66} // namespace cl_px4_mr
CbLoadKmlMission(std::string absoluteKmlPath, std::vector< GeoPoint > fallbackBackbone={})
std::vector< GeoPoint > fallback_
void setMission(std::vector< GeoPoint > points, const std::string &source)
KmlLoadResult loadFile(const std::string &absolutePath)
virtual rclcpp::Logger getLogger() const