35#include <auterion_sdk/exception/exception.hpp>
36#include <rclcpp/rclcpp.hpp>
43class ParameterManager;
59 skip_flight_controller_connection_check = skip;
77 skip_message_compatibility_check = skip;
93 if (timeout.count() <= 0) {
95 "flight_controller_connection_timeout must be positive (got: " +
96 std::to_string(timeout.count()) +
"s)."};
98 flight_controller_connection_timeout = timeout;
102 void validate()
const {
103 if (skip_flight_controller_connection_check && !skip_message_compatibility_check) {
105 "Cannot check message compatibility if connection check is skipped. "
106 "Enable flight controller connection check, or disable message compatibility "
111 bool skip_flight_controller_connection_check{
false};
112 bool skip_message_compatibility_check{
true};
113 std::chrono::seconds flight_controller_connection_timeout{15};
121 SDK(
int argc,
char** argv,
const std::string& node_name);
125 [[deprecated(
"Use run(RunOptions) instead, this method will be removed in a future release.")]]
133 _skip_flight_controller_connection_check = skip;
138 rclcpp::Node::SharedPtr defaultRosHandle()
const {
return _default_ros_node; }
140 rclcpp::Time now()
const {
return _default_ros_node->now(); }
142 void addNode(rclcpp::Node::SharedPtr node) { _executor->add_node(node); }
143 void removeNode(rclcpp::Node::SharedPtr node) { _executor->remove_node(node); }
145 const rclcpp::executors::SingleThreadedExecutor::UniquePtr& executor()
const {
150 template <
typename T>
151 static constexpr void verify_param() {
152 static_assert(std::is_same<T, bool>::value || std::is_same<T, int64_t>::value ||
153 std::is_same<T, int>::value || std::is_same<T, float>::value ||
154 std::is_same<T, double>::value || std::is_same<T, std::string>::value ||
155 std::is_same<T, std::vector<bool>>::value ||
156 std::is_same<T, std::vector<int64_t>>::value ||
157 std::is_same<T, std::vector<int>>::value ||
158 std::is_same<T, std::vector<float>>::value ||
159 std::is_same<T, std::vector<double>>::value ||
160 std::is_same<T, std::vector<std::string>>::value,
161 "Unsupported parameter data type");
175 template <
typename T>
177 std::function<
void(
const T&)> on_change_callback =
nullptr) {
191 template <
typename T>
197 rclcpp::Node::SharedPtr _default_ros_node;
198 rclcpp::executors::SingleThreadedExecutor::UniquePtr _executor;
199 bool _skip_flight_controller_connection_check{
false};
200 std::unique_ptr<ParameterManager> _parameter_manager;
205 std::function<
void(
const bool&)> on_change_callback);
209 std::function<
void(
const int64_t&)> on_change_callback);
212int SDK::getParameter(
const std::string& name, std::function<
void(
const int&)> on_change_callback);
216 std::function<
void(
const float&)> on_change_callback);
220 std::function<
void(
const double&)> on_change_callback);
224 std::function<
void(
const std::string&)> on_change_callback);
228 const std::string& name, std::function<
void(
const std::vector<bool>&)> on_change_callback);
232 const std::string& name, std::function<
void(
const std::vector<int64_t>&)> on_change_callback);
236 std::function<
void(
const std::vector<int>&)> on_change_callback);
240 const std::string& name, std::function<
void(
const std::vector<float>&)> on_change_callback);
244 const std::string& name, std::function<
void(
const std::vector<double>&)> on_change_callback);
248 const std::string& name,
249 std::function<
void(
const std::vector<std::string>&)> on_change_callback);
273void SDK::setParameter(
const std::string& name,
const std::vector<int64_t>& value);
282void SDK::setParameter(
const std::string& name,
const std::vector<double>& value);
285void SDK::setParameter(
const std::string& name,
const std::vector<std::string>& value);
Exception thrown for invalid arguments.
Definition exception.hpp:82
SDK execution class. All callbacks are called on the same thread.
Definition auterion.hpp:119
T getParameter(const std::string &name, std::function< void(const T &)> on_change_callback=nullptr)
Get a parameter value and optionally register a callback for changes.
Definition auterion.hpp:176
void setParameter(const std::string &name, const T &value)
Set a parameter.
Definition auterion.hpp:192
void setSkipFlightControllerConnectionCheck(bool skip)
Definition auterion.hpp:132
Options for SDK run() method.
Definition auterion.hpp:50
RunOptions & withSkipFlightControllerConnectionCheck(bool skip)
Skip the check for flight controller connection.
Definition auterion.hpp:58
RunOptions & withFlightControllerConnectionTimeout(std::chrono::seconds timeout)
Set the timeout for the flight controller connection check.
Definition auterion.hpp:92
RunOptions & withSkipMessageCompatibilityCheck(bool skip)
Skip the check for message compatibility.
Definition auterion.hpp:76