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

dynamic reconfigure specific directory

asked 2018-06-21 08:30:41 -0500

mherrmann gravatar image

updated 2018-06-22 03:36:08 -0500

Using

generate_dynamic_reconfigure_options(ros/config/params.cfg)

in my CMakeLists.txt of a package, some strange directories within the package are created and I don't know why. Here is my structure before a build (top level is the catkin workspace with the toplevel CMakeLists.txt).

├── CMakeLists.txt -> /opt/ros/kinetic/share/catkin/cmake/toplevel.cmake
└── src
    └── pack_template
        ├── CMakeLists.txt
        ├── library
        │   ├── include
        │   │   └── lib.hpp
        │   └── src
        │       └── lib.cpp
        ├── package.xml
        └── ros
            ├── config
            │   └── params.cfg
            ├── include
            │   └── template
            │       └── template.hpp
            └── src
                └── template.cpp

I then use catkin build with this CMakeLists.txt

cmake_minimum_required(VERSION 2.8.3)
project(pack_template)

add_compile_options(-std=c++11)

find_package(catkin REQUIRED
  roscpp
  rospy
  std_msgs
  dynamic_reconfigure
)

generate_dynamic_reconfigure_options(
  ros/config/params.cfg
)

catkin_package(
  LIBRARIES ${PROJECT_NAME}
  CATKIN_DEPENDS std_msgs
)

include_directories(
  include
  ros/include
  library/include
  ${catkin_INCLUDE_DIRS}
  cfg/cpp
  ${Boost_INCLUDE_DIRS}
)

add_library(${PROJECT_NAME} STATIC
  library/src/lib.cpp
)

add_executable(${PROJECT_NAME}_node
  ros/src/template.cpp
)

set_target_properties(${PROJECT_NAME}_node PROPERTIES OUTPUT_NAME "example_node" PREFIX "")

add_dependencies(${PROJECT_NAME}_node 
  ${${PROJECT_NAME}_EXPORTED_TARGETS}
  ${catkin_EXPORTED_TARGETS}
)

target_link_libraries(${PROJECT_NAME}
  ${catkin_LIBRARIES}
)

target_link_libraries(${PROJECT_NAME}_node
  ${PROJECT_NAME}
  ${catkin_LIBRARIES}
  ${Boost_LIBRARY_DIR}
)

and my folder structure after a build looks (deleted some hopefully uninteresting things)

├── build
│   ├── (...)
├── CMakeLists.txt -> /opt/ros/kinetic/share/catkin/cmake/toplevel.cmake
├── devel
│   ├── env.sh -> ~/catkin/dynamic_reconfigure_test/devel/.private/catkin_tools_prebuild/env.sh
│   ├── etc
│   │   └── (...)
│   ├── include
│   ├── lib
│   │   ├── libpack_template.a -> ~/catkin/dynamic_reconfigure_test/devel/.private/pack_template/lib/libpack_template.a
│   │   ├── pack_template
│   │   │   └── example_node -> ~/catkin/dynamic_reconfigure_test/devel/.private/pack_template/lib/pack_template/example_node
│   │   ├── pkgconfig
│   │   │   ├── catkin_tools_prebuild.pc -> ~/catkin/dynamic_reconfigure_test/devel/.private/catkin_tools_prebuild/lib/pkgconfig/catkin_tools_prebuild.pc
│   │   │   └── pack_template.pc -> ~/catkin/dynamic_reconfigure_test/devel/.private/pack_template/lib/pkgconfig/pack_template.pc
│   │   └── python2.7
│   │       └── dist-packages
│   │           └── pack_template
│   │               ├── cfg
│   │               │   └── __init__.py -> ~/catkin/dynamic_reconfigure_test/devel/.private/pack_template/lib/python2.7/dist-packages/pack_template/cfg/__init__.py
│   │               └── __init__.py -> ~/catkin/dynamic_reconfigure_test/devel/.private/pack_template/lib/python2.7/dist-packages/pack_template/__init__.py
│   ├── setup.bash -> ~/catkin/dynamic_reconfigure_test/devel/.private/catkin_tools_prebuild/setup.bash
│   ├── setup.sh -> ~/catkin/dynamic_reconfigure_test/devel/.private/catkin_tools_prebuild/setup.sh
│   ├── _setup_util.py -> ~/catkin/dynamic_reconfigure_test/devel/.private/catkin_tools_prebuild/_setup_util.py
│   ├── setup.zsh -> ~/catkin/dynamic_reconfigure_test/devel/.private/catkin_tools_prebuild/setup.zsh
│   └── share
│       ├── catkin_tools_prebuild
│       │   └── cmake
│       │       ├── catkin_tools_prebuildConfig.cmake -> ~/catkin/dynamic_reconfigure_test/devel/.private/catkin_tools_prebuild/share/catkin_tools_prebuild/cmake/catkin_tools_prebuildConfig.cmake
│       │       └── catkin_tools_prebuildConfig-version.cmake -> ~/catkin/dynamic_reconfigure_test/devel/.private/catkin_tools_prebuild/share/catkin_tools_prebuild/cmake/catkin_tools_prebuildConfig-version.cmake
│       └── pack_template
│           └── cmake
│               ├── pack_templateConfig.cmake -> ~/catkin/dynamic_reconfigure_test/devel/.private/pack_template/share/pack_template/cmake/pack_templateConfig.cmake
│               └── pack_templateConfig-version.cmake -> ~/catkin/dynamic_reconfigure_test/devel/.private/pack_template/share/pack_template/cmake/pack_templateConfig-version.cmake
├── logs
│   ├── (...)
└── src
    └── pack_template
        ├── cfg
        │   └── cpp
        │       └── pack_template
        │           └── templateConfig.h
        ├── CMakeLists.txt
        ├── docs
        │   ├── templateConfig.dox
        │   ├── templateConfig-usage.dox
        │   └── templateConfig.wikidoc
        ├── library
        │   ├── include
        │   │   └── lib.hpp
        │   └── src
        │       └── lib.cpp
        ├── package.xml
        ├── ros
        │   ├── config
        │   │   └── params.cfg
        │   ├── include
        │   │   └── template
        │   │       └── template.hpp
        │   └── src
        │       └── template.cpp
        └── src
            └── pack_template
                ├── cfg
                │   ├── __init__.py
                │   └── templateConfig.py
                └── __init__.py

Is there a way to define a target location to create these directories? I want them

  1. to be created in the subfolder ros, where all my ros dependent things are.
  2. the paramsConfig.h should go to ros/include not in src

Edit: There was a mistake in my original post, I edited the package structure. My plan was to put all ros-dependent stuff in package_main/ros/, hence there are an include and src directory. Second my ros-independent code should go to package_main/library src and include. Unfortunately by using ... (more)

edit retag flag offensive close merge delete

Comments

1

This directory listing is a little confusing. Can you please update your question with a copy and paste of the output of using tree?

jayess gravatar image jayess  ( 2018-06-22 01:12:17 -0500 )edit

2 Answers

Sort by » oldest newest most voted
2

answered 2018-06-25 05:17:25 -0500

gvdhoorn gravatar image

updated 2018-06-25 05:21:18 -0500

After looking at the example package you provided (and fixing some issues with it, please make sure things compile on your own machine in the future), I believe the following is the problem (from #q69583 in fact):

from dynamic_reconfigure.parameter_generator import *

This is the line you would use for the old version of dynamic_reconfigure, ie: the one for rosbuild. For Catkin, the line should read:

from dynamic_reconfigure.parameter_generator_catkin import *

note the _catkin suffix there.

I would suggest to take a look at the How to Write Your First .cfg File tutorial, just to see whether the .cfg file contains some other rosbuild-isms.


Edit: changes to the pkg and files I had to make:

  • the .cfg file was not executable
  • the Start() prototype in the .cpp file did not agree with the one in the header
  • the prototype for Stop() in the .cpp file included an extra S, prefixed to the class name
  • the CMakeLists.txt referenced Boost twice without a find_package(Boost ..) anywhere
  • the CMakeLists.txt referenced a non-existing include directory

In addition, with the Catkin version of the dynamic_reconfigure generator, the cfg/cpp directory should not be on the include path any longer.

edit flag offensive delete link more

Comments

Sorry, I did some mistakes creating the package. However, the line from dynamic_reconfigre.parameter_generator_catkin import * did the trick. Thank you very much.

mherrmann gravatar image mherrmann  ( 2018-06-25 06:32:57 -0500 )edit
2

answered 2018-06-21 08:55:35 -0500

Hi,

when one wants to use dynamic_reconfigure usually crates cfg folder as you did. You do not need __init__.py in the cfg folder.

after that you should call following in your CMakeLists.txt:

generate_dynamic_reconfigure_options( cfg/params.cfg )

To answer concrete on your questions.

You should never change default target locations of your files in ROS in that way you will just get problems. ROS will after building the workspace with the package automatically create in your ros folder build and devel subfolder. When you execute source ros/devel/setup.bash you will have all paths of your system set-up correctly.

  1. They will be crate in the sub folder ros/devel all header files for cpp and modules for python
  2. You will get your generated headers in ros/devel/include/_package_name_/include

For more detail see: https://wiki.ros.org/catkin/workspaces and https://wiki.ros.org/dynamic_reconfigure

edit flag offensive delete link more

Comments

Thanks for your reply, a few thoughts. 1. The __init__.py are empty and auto-generated. I don't want them, but catkin build always creates them. 2. ROS creates everything in devel as it should, but it also creates described files, hence I have two distinct src dirs, which confuses very much :-(

mherrmann gravatar image mherrmann  ( 2018-06-21 09:51:05 -0500 )edit
  1. This is something strange with your workspace. It would make sense to create a new and clean one.... I never got something like this....
  2. Why do you have two distinct src dirs? Can you show your structure?
destogl gravatar image destogl  ( 2018-06-21 10:25:10 -0500 )edit
  1. I tried so, it's always the same, two empty __init__.py files.
  2. I will update my structure in the old post, I made a mistake there, sorry.
mherrmann gravatar image mherrmann  ( 2018-06-22 01:05:46 -0500 )edit
1

I agree with @destogl: generated sources (such as those for dynamic_reconfigure) should not show up in your package directory, but should go into the devel folder. The cfg dir you show at the top of your tree output, is that really where the .h ends up? Can you show your CMakeLists.txt?

gvdhoorn gravatar image gvdhoorn  ( 2018-06-22 01:39:59 -0500 )edit

What exactly is showing your updated structure? A package?

usually multiple src folders are not a problem if added correctly in CMakeLists.txt.

Could you show following:

  1. Structure of your package before compilation,
  2. Your CMakeLists.txt file and
  3. Structure after compilation
destogl gravatar image destogl  ( 2018-06-22 02:16:22 -0500 )edit

I edited my original post again and tried to post the questioned parts. I had to delete a lot of generated files, hopefully you can see the problem?

mherrmann gravatar image mherrmann  ( 2018-06-22 03:37:12 -0500 )edit
1

First thing I notice is that you have the top-level CMakeLists.txt in the workspace root, instead of in the source space. unlink CMakeLists.txt in your workspace root.

gvdhoorn gravatar image gvdhoorn  ( 2018-06-22 04:07:51 -0500 )edit

I would also rm -rf the pack_template/cfg/cpp dir. It should not be there.

gvdhoorn gravatar image gvdhoorn  ( 2018-06-22 04:08:44 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2018-06-21 08:30:41 -0500

Seen: 775 times

Last updated: Jun 25 '18