Gazebo | Ignition | Community
Ask Your Question
0

How do I catkin-depend on the SDFormat library?

asked 2013-12-28 09:51:48 -0600

David Lu gravatar image

I have a ROS-hydro catkinized package that depends on SDFormat library, but can't figure out how to get it to link properly to the SDFormat library.

edit retag flag offensive close merge delete

Comments

Are you trying to build sdformat in a catkin workspace or just link to a system install of sdformat?

scpeters gravatar imagescpeters ( 2013-12-30 16:29:22 -0600 )edit

Specifically, I'm trying to get a package that uses the SDFormat library to build on the ROS build farm.

David Lu gravatar imageDavid Lu ( 2013-12-31 14:56:49 -0600 )edit

3 Answers

Sort by ยป oldest newest most voted
1

answered 2013-12-30 16:34:44 -0600

scpeters gravatar image

SDFormat is not a catkin package; it is a plain cmake package. Gazebo uses pkg-config to find sdformat and explicitly links against the sdformat libraries where necessary.

If you also want to build sdformat from source in a catkin workspace, you will need to add a package.xml file (see the package_xml branch in sdformat for an example).

edit flag offensive delete link more
1

answered 2014-01-02 21:25:25 -0600

joq gravatar image

updated 2014-01-03 19:43:39 -0600

Normally, you would add a system dependency on sdformat, which is released with Hydro. Unfortunately, it does not seem to have been defined via rosdep yet. You should probably contribute the missing definition to fix that problem.

Then, in your package.xml, add:

<build_depend>sdformat</build_depend>
<run_depend>sdformat</run_depend>

With sdformat installed, in your CMakeLists.txt, find the SDF system library:

find_package(PkgConfig REQUIRED)
pkg_check_modules(SDF sdformat REQUIRED)
include_directories(include ${SDF_INCLUDE_DIRS})

Then your own code will need something like this to build with it:

add_executable(your_node ${YOUR_NODE_SOURCES})
target_link_libraries(your_node
                      ${catkin_LIBRARIES}
                      ${SDF_LIBRARIES})
edit flag offensive delete link more

Comments

1

You actually need to search for sdformat: pkg_check_modules(SDF sdformat REQUIRED). It's a quirk of Gazebo's cmake setup; we already had variables with prefix SDF_ spread out, so we search for sdformat, but with variables named SDF. Sorry if that's a confusing example.

scpeters gravatar imagescpeters ( 2014-01-03 17:14:36 -0600 )edit

Thanks for the correction. Are the `SDF_INCLUDE_DIRS` and `SDF_LIBRARIES` variable names I had guessed correct?

joq gravatar imagejoq ( 2014-01-03 19:41:22 -0600 )edit

Yes, I believe that SDF_INCLUDEDIRS and SDFLIBRARIES are correct.

scpeters gravatar imagescpeters ( 2014-01-06 11:28:55 -0600 )edit
0

answered 2014-01-02 02:56:00 -0600

as addition to scpeters answer:

You can add sdformat as system dependency. You can do so by calling the catkin_create_pkg script with the parameter -s sdformat. This should solve the problem without adding a package.xml.

If you already have a package you can just add sdformat like you would do with gazebo. If you are already linking gazebo as sysdep this should not be necessary...

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-12-28 09:51:48 -0600

Seen: 1,109 times

Last updated: Jan 03 '14