Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Open Dynamic Robot Initiative
Web Operator
Commits
a429aba8
Commit
a429aba8
authored
Oct 15, 2021
by
Guilhem Saurel
Browse files
publish string repr of eigen stuff
parent
a626aed4
Changes
2
Hide whitespace changes
Inline
Side-by-side
include/qrw/mqtt-interface.hpp
View file @
a429aba8
...
...
@@ -21,7 +21,7 @@ class MqttInterface {
std
::
mutex
data_m
;
bool
getRun
();
//
std::string getValues();
std
::
string
getValues
();
std
::
string
getBattery
();
};
#endif
/* !MQTT_INTERFACE_HPP */
src/mqtt-interface.cpp
View file @
a429aba8
...
...
@@ -50,13 +50,19 @@ void MqttInterface::start() {
MQTTClient_subscribe
(
client
,
"/odri/commands"
,
0
);
MQTTClient_deliveryToken
token
;
char
*
battery_c
;
// char* values_c;
std
::
string
values_s
;
std
::
string
battery_s
;
char
*
values_c
;
char
*
battery_c
;
while
(
getRun
())
{
battery_c
=
getBattery
().
data
();
values_s
=
getValues
();
battery_s
=
getBattery
();
values_c
=
values_s
.
data
();
battery_c
=
battery_s
.
data
();
MQTTClient_publish
(
client
,
"/odri/battery"
,
strlen
(
battery_c
),
battery_c
,
0
,
0
,
&
token
);
MQTTClient_publish
(
client
,
"/odri/values"
,
strlen
(
values_c
),
values_c
,
0
,
0
,
&
token
);
std
::
this_thread
::
sleep_for
(
std
::
chrono
::
milliseconds
(
100
));
}
...
...
@@ -75,6 +81,13 @@ bool MqttInterface::getRun() {
return
run_
;
}
std
::
string
MqttInterface
::
getValues
()
{
std
::
lock_guard
<
std
::
mutex
>
guard
(
data_m
);
std
::
stringstream
ret
;
ret
<<
values_
.
transpose
();
return
ret
.
str
();
}
std
::
string
MqttInterface
::
getBattery
()
{
std
::
lock_guard
<
std
::
mutex
>
guard
(
data_m
);
std
::
string
ret
=
std
::
to_string
(
battery_
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment