Skip to content

Commit 74d64ee

Browse files
committed
Removing hack altering bool encodings when in "fixed type" mode
1 parent 8a6bd37 commit 74d64ee

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

mqtt_client/src/MqttClient.ros2.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -188,15 +188,14 @@ bool fixedMqtt2PrimitiveRos(mqtt::const_message_ptr mqtt_msg,
188188
*
189189
* @param [in] serialized_msg generic serialized ROS message
190190
* @param [in] msg_type ROS message type, e.g. `std_msgs/msg/String`
191-
* @param [in] fixed_encoding Truthfully this is just an ugly hack to change the encoding of bools in some cases
192191
* @param [out] primitive string representation of primitive message data
193192
*
194193
* @return true if primitive ROS message type was found
195194
* @return false if ROS message type is not primitive
196195
*/
197196
bool primitiveRosMessageToString(
198197
const std::shared_ptr<rclcpp::SerializedMessage>& serialized_msg,
199-
const std::string& msg_type, bool fixed_encoding, std::string& primitive) {
198+
const std::string& msg_type, std::string& primitive) {
200199

201200
bool found_primitive = true;
202201

@@ -207,10 +206,7 @@ bool primitiveRosMessageToString(
207206
} else if (msg_type == "std_msgs/msg/Bool") {
208207
std_msgs::msg::Bool msg;
209208
deserializeRosMessage(*serialized_msg, msg);
210-
if (fixed_encoding)
211-
primitive = msg.data ? "1" : "0";
212-
else
213-
primitive = msg.data ? "true" : "false";
209+
primitive = msg.data ? "true" : "false";
214210
} else if (msg_type == "std_msgs/msg/Char") {
215211
std_msgs::msg::Char msg;
216212
deserializeRosMessage(*serialized_msg, msg);
@@ -954,7 +950,7 @@ void MqttClient::ros2mqtt(
954950
// resolve ROS messages to primitive strings if possible
955951
std::string payload;
956952
bool found_primitive =
957-
primitiveRosMessageToString(serialized_msg, ros_msg_type.name, ros2mqtt.fixed_type, payload);
953+
primitiveRosMessageToString(serialized_msg, ros_msg_type.name, payload);
958954
if (found_primitive) {
959955
payload_buffer = std::vector<uint8_t>(payload.begin(), payload.end());
960956
} else {

0 commit comments

Comments
 (0)