0
$\begingroup$

Rosanswers logo

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 ?

Originally posted by Delb on ROS Answers with karma: 3907 on 2018-04-17

Post score: 0

$\endgroup$

2 Answers 2

0
$\begingroup$

Rosanswers logo

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.


Originally posted by NEngelhard with karma: 3519 on 2018-04-17

This answer was ACCEPTED on the original site

Post score: 4


Original comments

Comment by Delb on 2018-04-18:
Thank you, now it's working. I did like the move_base_msgs package and now everything compile smoothly each time.

$\endgroup$
0
$\begingroup$

Rosanswers logo

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.


Originally posted by mgruhler with karma: 12390 on 2018-04-17

This answer was NOT ACCEPTED on the original site

Post score: 2


Original comments

Comment by Delb on 2018-04-18:
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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.