Program Listing for File hms.hpp
↰ Return to documentation for file (include/psdk_wrapper/modules/hms.hpp
)
/*
* Copyright (C) 2024 Unmanned Life
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef PSDK_WRAPPER_INCLUDE_PSDK_WRAPPER_MODULES_HMS_HPP_
#define PSDK_WRAPPER_INCLUDE_PSDK_WRAPPER_MODULES_HMS_HPP_
#include <dji_hms.h> //NOLINT
#include <dji_hms_info_table.h> //NOLINT
#include <math.h>
#include <fstream>
#include <memory>
#include <nlohmann/json.hpp>
#include <rclcpp/rclcpp.hpp>
#include <rclcpp_lifecycle/lifecycle_node.hpp>
#include <shared_mutex>
#include <string>
#include "psdk_interfaces/msg/hms_info_msg.hpp"
#include "psdk_interfaces/msg/hms_info_table.hpp"
#include "psdk_wrapper/utils/json_utils.hpp"
namespace psdk_ros2
{
class HmsModule : public rclcpp_lifecycle::LifecycleNode
{
public:
explicit HmsModule(const std::string& name);
~HmsModule();
CallbackReturn on_configure(const rclcpp_lifecycle::State& state);
CallbackReturn on_activate(const rclcpp_lifecycle::State& state);
CallbackReturn on_cleanup(const rclcpp_lifecycle::State& state);
CallbackReturn on_deactivate(const rclcpp_lifecycle::State& state);
CallbackReturn on_shutdown(const rclcpp_lifecycle::State& state);
bool init();
bool deinit();
std::string hms_return_codes_path_;
private:
friend T_DjiReturnCode c_hms_callback(T_DjiHmsInfoTable hms_info_table);
T_DjiReturnCode hms_callback(T_DjiHmsInfoTable hms_info_table);
psdk_interfaces::msg::HmsInfoTable to_ros2_msg(
const T_DjiHmsInfoTable& hms_info_table, const nlohmann::json& codes,
const char* language = "en");
rclcpp_lifecycle::LifecyclePublisher<
psdk_interfaces::msg::HmsInfoTable>::SharedPtr hms_info_table_pub_;
std::shared_mutex publisher_mutex_;
mutable std::shared_mutex global_ptr_mutex_;
bool is_module_initialized_{false};
nlohmann::json hms_return_codes_json_;
};
extern std::shared_ptr<HmsModule> global_hms_ptr_;
} // namespace psdk_ros2
#endif // PSDK_WRAPPER_INCLUDE_PSDK_WRAPPER_MODULES_HMS_HPP_