Go to the documentation of this file.
35 #include <mqtt_client_interfaces/IsConnected.h>
36 #include <mqtt/async_client.h>
59 public virtual mqtt::callback,
60 public virtual mqtt::iaction_listener {
68 virtual void onInit()
override;
84 bool loadParameter(
const std::string& key, std::string& value);
97 bool loadParameter(
const std::string& key, std::string& value,
111 template <
typename T>
127 template <
typename T>
141 template <
typename T>
142 bool loadParameter(
const std::string& key, std::vector<T>& value);
157 template <
typename T>
171 std::filesystem::path
resolvePath(
const std::string& path_string);
205 const std::string& ros_topic);
223 void mqtt2ros(mqtt::const_message_ptr mqtt_msg,
254 void connected(
const std::string& cause)
override;
283 mqtt_client_interfaces::IsConnected::Request& request,
284 mqtt_client_interfaces::IsConnected::Response&
response);
316 void on_success(
const mqtt::token& token)
override;
326 void on_failure(
const mqtt::token& token)
override;
339 std::filesystem::path
365 std::filesystem::path
key;
479 template <
typename T>
483 NODELET_DEBUG(
"Retrieved parameter '%s' = '%s'", key.c_str(),
484 std::to_string(value).c_str());
489 template <
typename T>
491 const T& default_value) {
495 NODELET_ERROR(
"Parameter '%s' has wrong data type", key.c_str());
496 NODELET_WARN(
"Parameter '%s' not set, defaulting to '%s'", key.c_str(),
500 NODELET_DEBUG(
"Retrieved parameter '%s' = '%s'", key.c_str(),
501 std::to_string(value).c_str());
506 template <
typename T>
511 NODELET_DEBUG(
"Retrieved parameter '%s' = '[%s]'", key.c_str(),
512 fmt::format(
"{}", fmt::join(value,
", ")).c_str());
517 template <
typename T>
519 const std::vector<T>& default_value)
523 NODELET_WARN(
"Parameter '%s' not set, defaulting to '%s'", key.c_str(),
524 fmt::format(
"{}", fmt::join(value,
", ")).c_str());
526 NODELET_DEBUG(
"Retrieved parameter '%s' = '%s'", key.c_str(),
527 fmt::format(
"{}", fmt::join(value,
", ")).c_str());
540 template <
typename T>
544 buffer.resize(length);
int qos
last-will QoS value
int size
client buffer size
const std::string response
void mqtt2ros(mqtt::const_message_ptr mqtt_msg, const ros::WallTime &arrival_stamp=ros::WallTime::now())
Publishes a ROS message received via MQTT to ROS.
struct mqtt_client::MqttClient::Ros2MqttInterface::@4 ros
ROS-related variables.
std::string password
decryption password for private key
void setupClient()
Sets up the client connection options and initializes the client object.
void on_success(const mqtt::token &token) override
Callback for when a MQTT action succeeds.
#define NODELET_ERROR(...)
std::filesystem::path resolvePath(const std::string &path_string)
Converts a string to a path object resolving paths relative to ROS_HOME.
Struct containing client parameters.
void mqtt2primitive(mqtt::const_message_ptr mqtt_msg)
Publishes a primitive message received via MQTT to ROS.
ros::Publisher publisher
generic ROS publisher
void on_failure(const mqtt::token &token) override
Callback for when a MQTT action fails.
struct mqtt_client::MqttClient::Mqtt2RosInterface::@6 mqtt
MQTT-related variables.
bool getParam(const std::string &key, bool &b) const
void delivery_complete(mqtt::delivery_token_ptr token) override
Callback for when delivery for a MQTT message has been completed.
bool is_connected_
Status variable keeping track of connection status to broker.
std::filesystem::path key
client private keyfile
uint32_t serializationLength(const boost::array< T, N > &t)
#define NODELET_WARN(...)
int max_inflight
maximum number of inflight messages
struct mqtt_client::MqttClient::ClientConfig::@1 buffer
client buffer-related variables
bool loadParameter(const std::string &key, std::string &value)
Loads requested ROS parameter from parameter server.
ClientConfig client_config_
Client parameters.
struct mqtt_client::MqttClient::ClientConfig::@3 tls
SSL/TLS-related variables.
std::shared_ptr< mqtt::async_client > client_
MQTT client variable.
std::string message
last-will message
int version
TLS version (https://github.com/eclipse/paho.mqtt.cpp/blob/master/src/mqtt/ssl_options....
Struct containing variables related to a MQTT2ROS connection.
std::string topic
last-will topic
static const std::string kRosMsgTypeMqttTopicPrefix
MQTT topic prefix under which ROS message type information is published.
bool clean_session
whether client requests clean session
topic_tools::ShapeShifter shape_shifter
ROS msg type ShapeShifter.
void ros2mqtt(const topic_tools::ShapeShifter::ConstPtr &ros_msg, const std::string &ros_topic)
Serializes and publishes a generic ROS message to the MQTT broker.
struct mqtt_client::MqttClient::ClientConfig::@2 last_will
last-will-related variables
ros::Publisher latency_publisher
ROS publisher for latency.
struct mqtt_client::MqttClient::Mqtt2RosInterface::@7 ros
ROS-related variables.
std::filesystem::path directory
client buffer directory
std::string topic
ROS topic.
mqtt::connect_options connect_options_
MQTT client connection options.
Struct containing variables related to a ROS2MQTT connection.
bool primitive
whether to publish as primitive message
ROS Nodelet for sending and receiving ROS messages via MQTT.
ros::NodeHandle private_node_handle_
Private ROS node handle.
std::vector< std::string > alpn_protos
list of ALPN protocols
bool hasParam(const std::string &key) const
void message_arrived(mqtt::const_message_ptr mqtt_msg) override
Callback for when the client receives a MQTT message from the broker.
void connected(const std::string &cause) override
Callback for when the client has successfully connected to the broker.
bool isConnectedService(mqtt_client_interfaces::IsConnected::Request &request, mqtt_client_interfaces::IsConnected::Response &response)
ROS service returning whether the client is connected to the broker.
BrokerConfig broker_config_
Broker parameters.
static const std::string kLatencyRosTopicPrefix
ROS topic prefix under which ROS2MQTT2ROS latencies are published.
std::map< std::string, Mqtt2RosInterface > mqtt2ros_
MQTT2ROS connection variables sorted by MQTT topic.
std::filesystem::path certificate
client certificate
bool enabled
whether client buffer is enabled
bool stamped
whether timestamp is injected
std::map< std::string, Ros2MqttInterface > ros2mqtt_
ROS2MQTT connection variables sorted by ROS topic.
void setup()
Initializes broker connection and subscriptions.
void connection_lost(const std::string &cause) override
Callback for when the client has lost connection to the broker.
bool stamped
whether to inject timestamp in MQTT message
ros::ServiceServer is_connected_service_
ROS Service server for providing connection status.
struct mqtt_client::MqttClient::Ros2MqttInterface::@5 mqtt
MQTT-related variables.
std::filesystem::path ca_certificate
public CA certificate trusted by client
double keep_alive_interval
keep-alive interval
std::string topic
MQTT topic.
bool latched
whether to latch ROS message
int queue_size
ROS publisher queue size.
ros::Subscriber subscriber
generic ROS subscriber
std::string host
broker host
void connect()
Connects to the broker using the member client and options.
void serializeRosMessage(const T &msg, std::vector< uint8_t > &buffer)
T param(const std::string ¶m_name, const T &default_val) const
std::string id
client unique ID
int queue_size
ROS subscriber queue size.
bool enabled
whether to connect via SSL/TLS
struct mqtt_client::MqttClient::BrokerConfig::@0 tls
SSL/TLS-related variables.
bool isConnected()
Returns whether the client is connected to the broker.
Namespace for the mqtt_client package.
void serialize(Stream &stream, const boost::array< T, N > &t)
Struct containing broker parameters.
bool retained
whether last-will is retained
virtual void onInit() override
Initializes nodelet when nodelet is loaded.
void loadParameters()
Loads ROS parameters from parameter server.
ros::NodeHandle node_handle_
ROS node handle.
bool retained
whether to retain MQTT message
#define NODELET_DEBUG(...)
mqtt_client
Author(s): Lennart Reiher
, Bastian Lampe , Christian Wende
autogenerated on Thu Oct 5 2023 02:09:10