rosserial_windows packet loss while sending data to service server on ROS

asked 2017-10-16 11:56:33 -0600

_nobot.enter gravatar image

Hi,

I have a question about rosserial windows.

I made a Windows application which has two buttons as below.

  1. Open connection
  2. Send data to Service Server - which is Service client

In constructor of the dialog, I assigned ServiceClient pointer to node handle.
When I click Button #1, it should init node handle by calling initNode function and call spinOnce function.
When I click Button #2, it should call Call function to send data to ServiceServer and receive response.


My test was as shown below.

  1. Compile
  2. Click Button #1
  3. Click Button #2
  4. Wait for a while (longer than 30 sec)
  5. Click Button #2

I put simplified version of my code.

// ROSHandler class
class ROSHandler {
    protected:
        ros::NodeHandle node_handle_;
    private:
       ros::ServiceClient<request, response="">* client_;
    public:
        ROSHandler() {
            client_ = new ros::ServiceClient<request, response="">("TOPIC_NAME");
            node_handle_.serviceClient(*client_);
        }
        ~ROSHandler();
        bool Connect() {
            node_handle_.initNode(MASTER_IP);
            while (!node_handle_.connected())
            {
                node_handle_.spinOnce();
            }
            return (node_handle_.spinOnce() == 0);
        }
        bool Send() {
            Request req;
            Response res;
            // set values in req

            if (!node_handle_.connected()) {
                Connect();
            }

            client_->call(request, response);
            node_handle_.spinOnce();
            return response_.result; // return boolean
        }
};
void OnClickButton1 {
    Connect(); // connect function above
}

void OnClickButton2 {
    Send(); // send function above
}

Thanks! :D

edit retag flag offensive close merge delete