Go to the documentation of this file.
28 va_copy(args_copy, args);
29 const int required_len = vsnprintf(
nullptr, 0, fmt, args_copy);
30 if (required_len >= 0)
32 log_str.resize(required_len);
33 vsnprintf(&log_str[0], required_len + 1, fmt, args);
41 reinterpret_cast<NodeCommon*
>(user)->logCallback(level,
"MIP SDK: " + log_str);
50 MICROSTRAIN_ERROR(
node_,
"Unable to update device");
53 bool reconnected =
false;
54 int reconnect_attempt = 0;
57 MICROSTRAIN_WARN(
node_,
"Reconnect attempt %d...", reconnect_attempt);
60 MICROSTRAIN_INFO(
node_,
"Successfully reconnected to the device");
63 MICROSTRAIN_INFO(
node_,
"Reconfiguring device...");
81 std::this_thread::sleep_for(std::chrono::seconds(5));
86 throw std::runtime_error(
"Device disconnected");
96 const std::string& talker_id_str = nmea_message.sentence.substr(1, 2);
128 MICROSTRAIN_FATAL(
node_,
"%s", log_str.c_str());
131 MICROSTRAIN_ERROR(
node_,
"%s", log_str.c_str());
134 MICROSTRAIN_WARN(
node_,
"%s", log_str.c_str());
137 MICROSTRAIN_INFO(
node_,
"%s", log_str.c_str());
140 MICROSTRAIN_DEBUG(
node_,
"%s", log_str.c_str());
164 MICROSTRAIN_DEBUG(
node_,
"Reading config");
167 MICROSTRAIN_ERROR(
node_,
"Failed to read configuration for node");
170 MICROSTRAIN_DEBUG(
node_,
"Configuring Publishers");
173 MICROSTRAIN_ERROR(
node_,
"Failed to configure publishers");
177 MICROSTRAIN_DEBUG(
node_,
"Configuring Services");
180 MICROSTRAIN_ERROR(
node_,
"Failed to setup services");
203 MICROSTRAIN_DEBUG(
node_,
"Activating Subscribers");
206 MICROSTRAIN_ERROR(
node_,
"Failed to activate subscribers");
211 MICROSTRAIN_DEBUG(
node_,
"Activating publishers");
214 MICROSTRAIN_ERROR(
node_,
"Failed to activate publishers");
220 MICROSTRAIN_INFO(
node_,
"Resuming the device data streams");
223 MICROSTRAIN_ERROR(
node_,
"Failed to resume device data streams");
228 MICROSTRAIN_INFO(
node_,
"Node activated");
242 MICROSTRAIN_INFO(
node_,
"Forcing the device to idle");
247 MICROSTRAIN_ERROR(
node_,
"Unable to set node to idle");
RosTimerType main_parsing_timer_
bool shutdown()
Shuts down the node.
uint8_t mip_log_level
Logging level enum.
Contains service functions and service handles.
std::shared_ptr< RosMipDeviceMain > mip_device_
bool configure()
Configures the services.
constexpr auto NMEA_MAX_LENGTH
bool configure(RosNodeType *config_node)
Configures the node.
std::shared_ptr< RosMipDeviceAux > aux_device_
void logCallbackProxy(void *user, mip_log_level level, const char *fmt, va_list args)
void logCallback(const mip_log_level level, const std::string &log_str)
bool activate()
Activates the node.
void parseAndPublishMain()
Reads messages from the main port of the device, parses them, and publishes them.
double timer_update_rate_hz_
mip_cmd_result
Represents the status of a MIP command.
bool initialize(RosNodeType *init_node)
Initializes the node into an idle state.
bool configure_after_reconnect_
#define MIP_LOG_LEVEL_WARN
Warning logs are logged when something concerning happens that may or not be a mistake.
bool configure()
Configures the publishers.
Contains configuration information for the node, configures the device on startup This class holds th...
TypedResult< Resume > resume(C::mip_interface &device)
RosTimerType aux_parsing_timer_
RosNodeType * config_node_
void publish()
Publishes the message on the publisher.
bool activate()
Only technically needed for ROS2 lifecycle publishers, this will activate the publishers,...
Publisher< NMEASentenceMsg >::SharedPtr nmea_sentence_pub_
bool configure(RosNodeType *node)
Reads configuration, and configures the device.
void parseAndPublishAux()
Reads messages from the aux port of the device, parses them, and publishes them.
bool deactivate()
Deactivates the node.
#define MIP_LOG_LEVEL_INFO
Info logs are logged when some general info needs to be conveyed to the user.
#define MIP_LOG_LEVEL_DEBUG
Debug logs are logged for debug purposes.
std::string gnss_frame_id_[NUM_GNSS]
Base class for ROS1 and ROS2 nodes.
std::shared_ptr< MipPublisherMapping > mip_publisher_mapping_
#define MIP_LOG_LEVEL_ERROR
Error logs are logged when an error occurs.
bool activate()
Activates the subscribers.
Contains subscribers and the functions they call.
#define MIP_LOG_LEVEL_FATAL
Fatal logs are logged when an unrecoverable error occurs.
Contains ROS messages and the publishers that will publish them.
#define MIP_LOG_INIT(callback, level, user)
Helper macro used to initialize the MIP logger.
std::map< std::string, std::string > nmea_talker_id_to_frame_id_mapping_