Using a ROS Kinetic node as both a SimpleActionServer and SimpleActionClient
I have a class that provides a SimpleActionServer and when I interact with it using a SimpleActionClient in another node everything works as expected. I am now trying to write a rostest case for the server class. When I run the test case the server initializes fine but the client blocks forever in waitForServer(). If I start my standalone client node it immediately connects to the server in the test case and can send a new goal.
Is running an action server and client from the same process supported? If not, how can I test my action server?
TEST(Node, testActionServer) {
ServerClass srv; // constructor starts the action server
actionlib::SimpleActionClient<mynamespace::GoalAction> ac("/myActionServer", true);
ROS_INFO("Waiting for server...")
ac.waitForServer();
ROS_INFO("Connected to server");
// Do stuff like send a goal.
}
The code for creating the simple action client was copy and pasted directly from the stand alone node.