Skip to content

Commit

Permalink
Fixed diagnostic status key/value parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
chriseichmann committed May 8, 2023
1 parent a5711f9 commit fbadf57
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/lib/camera_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1137,12 +1137,19 @@ DiagnosticStatusMsg CameraNode::create_diagnostic_status(const uint8_t level, co
msg.message = parsed_json["description"];
}

for (json::iterator it = parsed_json.begin(); it != parsed_json.end(); it++)
for (auto& it : parsed_json.items())
{
diagnostic_msgs::msg::KeyValue obj;
obj.key = it.key();
obj.value = it.key();
msg.values.push_back(obj);
try
{
diagnostic_msgs::msg::KeyValue obj;
obj.key = it.key();
obj.value = it.value().dump();
msg.values.push_back(obj);
}
catch (const std::exception& e)
{
RCLCPP_WARN(logger_, "Couldn't parse entry of diagnostics status %s: %s", msg.name, e.what());
}
}

return msg;
Expand Down

0 comments on commit fbadf57

Please sign in to comment.