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

Building an action server and action client located in two separate packages

asked 2018-04-17 04:29:24 -0600

Delb gravatar image

updated 2018-04-17 04:30:11 -0600

Hi,

I have implemented an action server and an action client for my application. They are located in two different packages and I sometimes encounter an issue when running catkin_make : if I delete my /build and /devel folders the first catkin_make always fails (always because of the action messages not found during the compilation) but if I run catkin_make again there are no issues anymore. I suspect that the first time all the action messages are created but not correctly linked with my libraries so they are not found and the second time it's working since they have already been created.

So I'm aware this issue comes from my CMakeList.txt and package.xml configurations, I've followed the different actionlib tutorials where this configuration is detailled but it's always when the server and client are located in the same package.

I don't want you to correct my configuration, I want to correctly understand how it should be done, so my questions are :

  • Do I need to put the /action folder containing the action message in both packages ? (I've currently created only one folder inside the package containing the action server)
  • If not, what is the proper way to link the auto generated action message header files to the other package ?
  • What is the minimum required configuration for my CMakeList.txt and package.xml for my package containing the action server ?
  • Same question for the other package containing the action server ?
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
4

answered 2018-04-17 08:41:04 -0600

NEngelhard gravatar image

updated 2018-04-20 05:41:54 -0600

The best way is to create a third package that only contains the message definition. Otherwise you will need to build the server-package whenever you want to use the client-package and this can get messy if it has some external dependencies. This is especially if you want to run an action client on an arduino or other smaller system on which it is impossible or inconvenient to build the full project.

In most cases, this third package is called [base_name]_msgs to show that it only contains message (or action) definitions. Both other packages will only depend on this package and not on each other.

edit flag offensive delete link more

Comments

1

Thank you, now it's working. I did like the move_base_msgs package and now everything compile smoothly each time.

Delb gravatar image Delb  ( 2018-04-18 06:16:32 -0600 )edit
2

answered 2018-04-17 06:48:14 -0600

mgruhler gravatar image

updated 2018-04-17 06:48:38 -0600

I'll give it a try. Before answering your problem, I'll focus on your questions:

  1. No, you schouldn't do that! This will result in different msgs, as the package name is included as well (as e.g. std_msgs/String; there, std_msgs is the package). You will then not be able to use the Client and Server together.
  2. You don't link them, as they are only headers. Thus, you only #include (C++) them. In Python, you import them.
  3. Puh, this is a tough one. I'll recommend you'll go through the catkin documentation. Especially the sections about resolving dependencies and building and installing targets. This is obviously dependent on what you do, i.e. use C++, Python and/or Messages.
  4. as above.

Your main problem is most probably that you haven't properly declared the dependencies in the package where you use the Messages.

Assuming you have the Messages in pkg A and want to use them in pkg B as well, besides obviously having the respective <build_depend> on pkg A and find_packageing pkg A, you should add an add_dependencies(<ACTION_SERVER_NODE> ${catkin_EXPORTED_TARGETS}) in the CMakeLists.txt of pkg B, after your call to add_executable(<ACTION_SERVER_NODE> ...). See also the very bottom of this page. This tells catkin to first build all dependencies before building the respective target.

edit flag offensive delete link more

Comments

Thank you for the answer, you are right the add_dependencies(<ACTION_SERVER_NODE> ${catkin_EXPORTED_TARGETS}) is mandatory. But for my issue I succeeded thanks to @NEngelhard 's answer, I couldn't find the proper configuration without creating a new package containing only the action message.

Delb gravatar image Delb  ( 2018-04-18 06:11:29 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2018-04-17 04:29:24 -0600

Seen: 1,568 times

Last updated: Apr 20 '18