ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

cdellin's profile - activity

2016-07-06 01:40:20 -0500 marked best answer Actionlib reconnect problem (c++ , with test case)

I'm unable to get my action clients to reconnect to their servers for more than a single request when the connection is temporarily lost (e.g. when the server node is restarted). It may be that I'm doing something wrong with threading. I created a very simple test case [1] (server.cpp and client.cpp) to illustrate the problem.

To see the problem, simply start the client, and leave it running. It will report its connection status every second, and attempt to send a goal if it's connected. In another terminal, run the server, then stop it, and then start it again. The following is the full output of the client terminal, with comments denoting when I start and stop the server.

$ rosrun actionlib_cpp_disconnect client # in first terminal
client not connected, skipping goal=0!
client not connected, skipping goal=1!
#### here i started the server, second terminal
client connected, sending goal=2!
client connected, sending goal=3!
#### here i stopped the server, second terminal
client not connected, skipping goal=4!
client not connected, skipping goal=5!
#### here i started the server again, second terminal
[ WARN] [1375230239.830277763]: goalConnectCallback: Trying to add [/server] to goalSubscribers, but it is already in the goalSubscribers list
[ WARN] [1375230239.830734224]: cancelConnectCallback: Trying to add [/server] to cancelSubscribers, but it is already in the cancelSubscribers list
client connected, sending goal=6! # the first one after the reconnect always works ...
client not connected, skipping goal=7! # wtf? the server is running ...
client not connected, skipping goal=8!
client not connected, skipping goal=9!

Is this standard behaviour? So far, the only workaround I've found is to manually delete the action client whenever it reports that it's disconnected, and re-construct a new one in its place.

I'm using ROS Groovy on Ubuntu Precise 12.04 with actionlib version 1.9.11-0precise-20130325-2034-+0000.

Here's the server code:

void cb_goal(actionlib::ServerGoalHandle<actionlib::testaction> srv_handle)
{
  printf("server received new goal, goal=%d!\n", srv_handle.getGoal()->goal);
  srv_handle.setRejected();
}
int main(int argc, char **argv)
{
  ros::init(argc, argv, "server");
  ros::NodeHandle nh;
  actionlib::ActionServer<actionlib::testaction> server(nh, "action", cb_goal, false); /* auto_start = false */
  server.start();
  ros::spin();
  return 0;
}

Here's the client code:

void ros_spin()
{
  ros::spin();
}
int main(int argc, char** argv)
{
  ros::init(argc, argv, "client");
  ros::NodeHandle nh;
  actionlib::ActionClient<actionlib::testaction> client("action");
  boost::thread mythd(ros_spin);
  actionlib::TestGoal goal;
  goal.goal = 0;
  ros::Rate loop_rate(1.0);
  while (ros::ok())
  {
    if (client.isServerConnected())
    {
      printf("client connected, sending goal=%d!\n", goal.goal);
      client.sendGoal(goal);
    }
    else
    {
      printf("client not connected, skipping goal=%d!\n", goal.goal);
    }
    loop_rate.sleep();
    goal.goal++;
  }
  return 0;
}

[1] http://dellin.net/box/actionlib_cpp_disconnect.tar

2016-07-06 01:40:17 -0500 received badge  Great Question (source)
2016-06-17 18:24:54 -0500 received badge  Stellar Question (source)
2014-12-16 17:36:26 -0500 received badge  Favorite Question (source)
2014-10-12 22:35:12 -0500 received badge  Enlightened (source)
2014-10-09 04:42:29 -0500 received badge  Good Question (source)
2014-07-25 12:44:03 -0500 received badge  Taxonomist
2014-01-28 17:28:38 -0500 marked best answer How can I use catkin package resources with the devel space?

I'm having trouble using package resources from the devel space of a catkin workspace. After I successfully run catkin_make, I have new build and devel folders. If I source ws/devel/setup.bash, I can then run binaries and use libraries, scripts, etc as I'd expect. But what about package-relative resources?

First question: How to I specify these resources in the package's CMakeLists.txt? I wasn't able to find any examples in the docs. Here's what I've been doing:

$ cat ws/source/path/to/my_package/CMakeLists.txt
...
install(
  DIRECTORY my_resources DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
)
...

(but of course this isn't used for the devel space, right?)

Second question: How do I find these resources if I'm using the devel space?

My first try was rospack. Here's the result:

$ rospack find my_package
ws/build/path/to/my_package/catkin_generated/stamps/my_package

This location doesn't hold any resources (copies or links to the source space). (Or should it?)

I also stumbled upon catkin_find. Here's the result:

$ catkin_find my_package
ws/devel/share/my_package
ws/source/path/to/my_package

I suppose the second one is what I want? Is this always the right thing to do?

Sidenote: It appears through some magic that roslaunch knows where to look for launch files (or does it search everything in the catkin_find list?).

2014-01-28 17:28:27 -0500 marked best answer catkin / setup.py installation into devel space not working

Hey all,

I can't figure out how to correctly package a Python module so it shows up in my devel space after "catkin_make". I've tried every combination of setup.py and CMakeLists.txt that I can think of.

Let's say I have a ROS package called "my_package", and I'd like to have a Python module defined by "my_package.py" containing a function called "def myfunc()", so that from a different package, I could do "import my_package; my_package.myfunc()". After catkin_make, I expect things to be installed like this: devel/lib/python2.7/dist-packages/my_package.py. How do I write a CMakeLists.txt and setup.py for this package?

If this configuration is impossible, how do you recommend I structure a simple ROS package providing Python modules?

Thanks for your help!

Edit: I'm using Groovy.

2014-01-23 21:43:18 -0500 received badge  Good Answer (source)
2014-01-23 16:23:13 -0500 received badge  Nice Answer (source)
2014-01-23 12:58:50 -0500 received badge  Teacher (source)
2014-01-23 12:58:50 -0500 received badge  Self-Learner (source)
2014-01-23 12:58:50 -0500 received badge  Necromancer (source)
2014-01-23 11:26:22 -0500 answered a question Actionlib reconnect problem (c++ , with test case)

This issue [0] was fixed in actionlib upstream [1], and the patched version is included in Hydro. If you're stuck with Groovy or earlier, I think you might be out of luck.

Thanks to Dirk Thomas for finding the bug and writing the patch!

[0] https://github.com/ros/actionlib/issues/7

[1] https://github.com/ros/actionlib/pull/13

2013-12-02 11:53:19 -0500 marked best answer How to specify dependencies with "foo_msgs" catkin packages

Say I have two catkin packages, foo and foo_msgs, in my workspace. Here's how I currently have them set up:

project(foo_msgs)
find_package(catkin REQUIRED COMPONENTS message_generation)
add_message_files(
  DIRECTORY msg
  FILES foomsg.msg
)
generate_messages()
catkin_package(CATKIN_DEPENDS message_runtime)
project(foo)
find_package(catkin REQUIRED COMPONENTS foo_msgs)
catkin_package()
include_directories(include ${catkin_INCLUDE_DIRS})
add_executable(foo foo.cpp)

I find that if I catkin_make foo, the message isn't generated. Indeed, catkin_make foo_msgs is a no-op. catkin_make foo_msgs_gencpp works, however. In order to get foo to build correctly, I must add the following line to its CMakeLists.txt:

add_dependencies(foo foo_msgs_gencpp)

Is this by design? I'd expect that building the package foo_msgs would automatically generate all its messages. Is there a way to make that happen?

Edit: I've approved WilliamWoodall's answer, although KruseT's was just as useful. (I also added the include_directories() line to foo's CMakeLists.txt, which I initially forgot.)

It turns out my solution is correct; the foo_msgs_gencpp auto-target should be added as a dependency of the foo target. Note that there is some disagreement about whether a different solution should be supported by catkin; KruseT started a discussion on the topic here.

Since this type of explicit dependency auto-target (_gencpp and _genpy) is necessary for using ROS messages/actions/services in any executable, library, or script, I think it should be better documented (I found no reference to it in catkin/migrating_from_rosbuild). KruseT opened a related rosdistro issue here.

2013-12-01 04:36:58 -0500 received badge  Famous Question (source)
2013-08-28 11:54:07 -0500 received badge  Notable Question (source)
2013-08-28 10:58:41 -0500 received badge  Great Question (source)
2013-08-04 03:49:18 -0500 commented question Actionlib reconnect problem (c++ , with test case)

I submitted a bug against actionlib here: https://github.com/ros/actionlib/issues/7. I'll keep this question updated.

2013-08-01 22:13:58 -0500 received badge  Good Question (source)
2013-08-01 05:52:21 -0500 received badge  Popular Question (source)