strands-project / mongodb_store

MongoDB tools for storing and analysing runs of ROS systems.
BSD 3-Clause "New" or "Revised" License
49 stars 72 forks source link

Error when calling service #284

Open siddux opened 12 months ago

siddux commented 12 months ago

Hi, I am trying to build a node which include a messageStoreProxy instance and a service server. For instance, I just created a dummy code to show the behavior:

#include <ros/ros.h>
#include <std_srvs/SetBool.h>
#include <geometry_msgs/Pose.h>
#include <mongodb_store/message_store.h>

bool serviceCallback(std_srvs::SetBool::Request& req,
                    std_srvs::SetBool::Response& res)
{
  return true;
}

void unused_function(mongodb_store::MessageStoreProxy& store)
{
  geometry_msgs::Pose stored;
    std::string name("test");
    std::string id(store.insertNamed(name, stored));
}

int main(int argc, char **argv)
{
  ros::init(argc, argv, "test_node");
  ros::NodeHandle nh;

  mongodb_store::MessageStoreProxy messageStore(nh, "test_collection");

  ros::ServiceServer srv = nh.advertiseService("/test_srv", serviceCallback);

  ros::Rate rate(10);

  while(ros::ok)
  {
    ros::spinOnce();
    rate.sleep();
  }
  return 0;
}

I run the node along with mongodb_store and when I call the service I get the following error and the node dies: ERROR: transport error completing service call: unable to receive data from sender, check sender's logs for details And any log file is saved.

Debugging the code I noticed that commenting out the "insertNamed..." line solves the error but I can't understand it because it's a line which is never executed. Any idea on where can be the problem and how to solve it?

Thanks.