Ask Your Question
0

[actionlib] Problems when try to connect client <=> server

asked 2014-10-07 07:19:04 -0600

Andromeda gravatar image

updated 2014-10-07 13:15:11 -0600

Hi Guys, since 2 day working with my code I found what is causing troubles. I cannot establish a working connection between a client and move_base server. Since my code is really huge I m going to report here just the interesting part which is a sintetic version of my code.

#include <actionlib/client/simple_action_client.h>
#include <actionlib/client/terminal_state.h>

#include <move_base_msgs/MoveBaseAction.h>
#include <move_base_msgs/MoveBaseGoal.h>

//######################## ACTIONLIB #################################################
/* Here the function used to reach the and keep track of the goals                  */
typedef actionlib::SimpleActionClient<move_base_msgs::MoveBaseAction> MoveBaseClient;

/* Definitions of variables for the goal positions */
move_base_msgs::MoveBaseGoal goal_;

int main( int argc, char **argv ) {

    ros::init( argc, argv, "pelican_driver" );

    ros::NodeHandle nh;
    ros::NodeHandle nh_private( "~" );


    MoveBaseClient ac_( "move_base", true );

    //######################## ACTIONLIB #################################################
    /* The server connection for the actionlib must be checked for 60 [sec] before going on... */
    ROS_INFO( "Checking the reply from the server..." );
    if( ac_.isServerConnected() ) 
        ROS_INFO( "Connected!" );
    if( !ac_.isServerConnected( ) ) 
        ROS_INFO( "Not connected" );      <= I GET ALL THE TIME "NOT CONNECTED"

    ros::spin();

    return 0;
}

2 Words more: my code works perfectly when I uncomment the line with waitForServer and I play with the whole code since weeks. Uncommenting that line it stucks literally on the above line and doesn't work anymore. It stops the created classes (which have a timer inside to run some program at a given loop), resulting in the fatidic

[ WARN] [1412682893.011742911]: Waiting on transform from base_link to map to become available before running costmap, tf error: Could not find a connection between 'map' and 'base_link' because they are not part of the same tree.Tf has two or more unconnected trees.

(furthermore this is interesting for all the people looking for the reason they get that error. In my case the reason is quite simple: stucking at that point my code is not able to publish the transformation odom => base_link. So check this if you have to deal with).

Again: commenting that single line of code, my code works like a charm and all tf transformations/trees are identified as you can see in the following figure:

image description

Since my code is really quite a copy of this tutorial, I cannot find any solution to get rid of this problem. In my launch file I start at first the driver of my robot (the code above honestly speaking), then the map_server and then the move_base

<launch>

    <!-- Launch the driver of the robot -->
    <include file="$(find quadrotor)/launch/robot_driver.launch" />

    <!-- Launch map_server with a blank map -->
    <node name="map_server" pkg="map_server" type="map_server" args="$(find quadrotor)/maps/blank_map.yaml" />

    <!-- Launch move_base and load all navigation parameters -->
    <include file="$(find quadrotor)/launch/move_base.launch" />

    <!-- Run a static transform between /odom and /map -->
    <node pkg="tf" type="static_transform_publisher" name="odom_map_broadcaster" args="0 0 0 0 0 0 /map /odom 100" />

</launch>

I ve tried to invert the order without success. What should I now do?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2014-10-07 12:10:26 -0600

paulbovbel gravatar image

Immediate steps:

  • Try removing that weird while loop, just use ac.waitForServer() if you want to block until a connection is made. While loop without a code block is ambiguous, though I'm not sure if could lead to undefined behaviour.

  • You should not be running both the static transform and the fake_localization, they are doing the same thing.

That should guarantee the map-> odom transform should be working. I'm guessing your robot_driver is providing odom -> base_link, and you've tested that that is working correctly.

Now, which node is running the above MoveClient code? Just want to make sure it's not interfering with your robot_driver in any way.

Also, can you connect and issue goals to move_base using the handy dandy debug tool rosrun actionlib axclient.py /move_base?

edit flag offensive delete link more

Comments

Thanks Paul. I ve updated the topics and tried all your suggestions (see code above again). No one works. But you have arose an interesting question. Which node? The same as my robot_driver. The driver and MoveClient are under the same node Is that the problem?

Andromeda gravatar imageAndromeda ( 2014-10-07 13:18:52 -0600 )edit

Yes, that will be a problem, especially if you're running everything as one thread. You could potentially multi-thread, but to do it the ROS way you should isolate functionality to nodes.

paulbovbel gravatar imagepaulbovbel ( 2014-10-07 13:51:20 -0600 )edit

Traditionally the driver node will at most subscribe to movement commands and publish odometry information .

paulbovbel gravatar imagepaulbovbel ( 2014-10-07 13:51:50 -0600 )edit

Also, a clean way to post your whole drive node would be using http://gist.github.com

paulbovbel gravatar imagepaulbovbel ( 2014-10-07 13:53:29 -0600 )edit

good idea, but I may not publish the code due to (my) copyrights. At least not yet!

Andromeda gravatar imageAndromeda ( 2014-10-07 14:25:51 -0600 )edit
0

answered 2014-10-07 14:24:01 -0600

Andromeda gravatar image

Paul was right... Never start driver and actionlib under the same node. After I separated both file and respective classes the client get connected with the server.

Paul for president

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2014-10-07 07:19:04 -0600

Seen: 1,910 times

Last updated: Oct 07 '14