Skip to content
Snippets Groups Projects
Commit 774291ef authored by Johannes Mey's avatar Johannes Mey
Browse files

minor improvements in logging

parent 7024ab4c
Branches
No related tags found
No related merge requests found
...@@ -28,7 +28,7 @@ nng_socket sock; ...@@ -28,7 +28,7 @@ nng_socket sock;
int rv; int rv;
void sendSelection(const std::string &object) { void sendSelection(const std::string &object) {
ROS_INFO_STREAM("Selecting random object: " << object); ROS_INFO_STREAM("Sending selection of: " << object);
Selection selection; Selection selection;
selection.set_id(object); selection.set_id(object);
int length = selection.ByteSize(); int length = selection.ByteSize();
...@@ -40,12 +40,6 @@ void sendSelection(const std::string &object) { ...@@ -40,12 +40,6 @@ void sendSelection(const std::string &object) {
} }
} }
std::string ProtoToJson(const google::protobuf::Message &proto) {
std::string json;
google::protobuf::util::MessageToJsonString(proto, &json);
return json;
}
int main(int argc, char **argv) { int main(int argc, char **argv) {
GOOGLE_PROTOBUF_VERIFY_VERSION; GOOGLE_PROTOBUF_VERIFY_VERSION;
...@@ -67,8 +61,7 @@ int main(int argc, char **argv) { ...@@ -67,8 +61,7 @@ int main(int argc, char **argv) {
ROS_WARN_STREAM("nng_dial returned: " << nng_strerror(rv) << ". Trying to connect again in one second..."); ROS_WARN_STREAM("nng_dial returned: " << nng_strerror(rv) << ". Trying to connect again in one second...");
connection_retry_rate.sleep(); connection_retry_rate.sleep();
} }
ROS_INFO_STREAM("nng_dial returned: " << nng_strerror(rv) << " (which is the translation of error code " << rv ROS_INFO_STREAM("NNG connection established to " << URL);
<< "). Connection established!");
ros::Rate loop_rate(200); ros::Rate loop_rate(200);
ros::Rate pause_rate(ros::Duration(2)); // seconds ros::Rate pause_rate(ros::Duration(2)); // seconds
...@@ -159,6 +152,7 @@ int main(int argc, char **argv) { ...@@ -159,6 +152,7 @@ int main(int argc, char **argv) {
pause_rate.sleep(); pause_rate.sleep();
std::string object{objects[distribution(rng)]}; std::string object{objects[distribution(rng)]};
ROS_INFO_STREAM("Selecting random object: " << object);
sendSelection(object); sendSelection(object);
// wait again, then send the bin object // wait again, then send the bin object
...@@ -171,6 +165,9 @@ int main(int argc, char **argv) { ...@@ -171,6 +165,9 @@ int main(int argc, char **argv) {
std::string bin{bins[binDistribution(rng)]}; std::string bin{bins[binDistribution(rng)]};
ROS_INFO_STREAM("Selecting random bin: " << bin); ROS_INFO_STREAM("Selecting random bin: " << bin);
sendSelection(bin); sendSelection(bin);
// wait some time before starting the next selection
pause_rate.sleep();
} }
} }
} else if (rv == NNG_EAGAIN) { } else if (rv == NNG_EAGAIN) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment