Program Listing for File pose_tree_manager.hpp
↰ Return to documentation for file (include/holoscan/pose_tree/pose_tree_manager.hpp)
/*
* SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef HOLOSCAN_POSE_TREE_POSE_TREE_MANAGER_HPP
#define HOLOSCAN_POSE_TREE_POSE_TREE_MANAGER_HPP
#include <memory>
#include <utility>
#include "holoscan/core/component_spec.hpp"
#include "holoscan/core/expected.hpp"
#include "holoscan/core/fragment_service.hpp"
#include "holoscan/core/parameter.hpp"
#include "holoscan/core/resource.hpp"
#include "holoscan/pose_tree/pose_tree.hpp"
#include "holoscan/pose_tree/pose_tree_ucx_client.hpp"
#include "holoscan/pose_tree/pose_tree_ucx_server.hpp"
namespace holoscan {
class PoseTree; // Forward declaration
class ComponentSpec;
class PoseTreeManager : public holoscan::Resource, public holoscan::DistributedAppService {
public:
enum class Error {
kNotInitialized = 0,
kServerError = 1,
kClientError = 2,
kAlreadyStarted = 3,
kNotStarted = 4,
kInternalError = 5,
};
template <typename T>
using expected = holoscan::expected<T, Error>;
using unexpected = holoscan::unexpected<Error>;
HOLOSCAN_RESOURCE_FORWARD_ARGS_SUPER(PoseTreeManager, holoscan::Resource)
PoseTreeManager() = default;
std::shared_ptr<Resource> resource() const override;
void resource(const std::shared_ptr<Resource>& resource) override;
void initialize() override;
void setup(holoscan::ComponentSpec& spec) override;
std::shared_ptr<PoseTree> tree();
std::shared_ptr<PoseTree> tree() const;
// AppService interface methods
void driver_start(std::string_view driver_ip) override;
void driver_shutdown() override;
void worker_connect(std::string_view driver_ip) override;
void worker_disconnect() override;
static const char* error_to_str(Error error);
protected:
// Internal methods that use expected for error handling
expected<void> driver_start_impl(std::string_view driver_ip);
expected<void> driver_shutdown_impl();
expected<void> worker_connect_impl(std::string_view driver_ip);
expected<void> worker_disconnect_impl();
private:
// Parameters for UCX connections
Parameter<int32_t> port_;
// Parameters for PoseTree::init
Parameter<int32_t> number_frames_;
Parameter<int32_t> number_edges_;
Parameter<int32_t> history_length_;
Parameter<int32_t> default_number_edges_;
Parameter<int32_t> default_history_length_;
Parameter<int32_t> edges_chunk_size_;
Parameter<int32_t> history_chunk_size_;
// Parameters for UCX timings
Parameter<int64_t> request_timeout_ms_;
Parameter<int64_t>
request_poll_sleep_us_;
Parameter<int64_t>
worker_progress_sleep_us_;
Parameter<int64_t> server_shutdown_timeout_ms_;
Parameter<int64_t>
server_shutdown_poll_sleep_ms_;
Parameter<int64_t> maximum_clients_;
std::shared_ptr<PoseTree> pose_tree_instance_;
std::unique_ptr<PoseTreeUCXServer> server_;
std::unique_ptr<PoseTreeUCXClient> client_;
std::weak_ptr<Resource> resource_;
};
} // namespace holoscan
#endif/* HOLOSCAN_POSE_TREE_POSE_TREE_MANAGER_HPP */