ROS Package
How to package.
package.xml
Use package format 2.0, which removes the distinction between <run_depend>
and <build_depend>
and makes this more compact.
Use spaces, 2-wide as indentation.
Example:
CMakeLists.txt
You should use catkin_simple rather than the old-style catkin lists, since they make everything easier. Use spaces, 2-wide as indentation.
A few tips:
catkin_simple(ALL_DEPS_REQUIRED)
will make sure that all dependencies in the package.xml above are found on the system and loaded.Make a library called
${PROJECT_NAME}
and link any executables against it.If you're outputting messages, this is done automatically by catkin simple. However, if you have executables and messages in the same package (prefer not to do this, just have a whatever_msgs package instead), you need to add this to after your executable/library so that things are built in the right order:
add_dependencies(${PROJECT_NAME} ${${PROJECT_NAME}_EXPORTED_TARGETS})
See the documentation at the link above, and this example:
Folder/file structure
Your package should look something like the example below. See the ROS Package Documentation for more details.
Keep in mind:
Your headers should be in include/PACKAGE_NAME/header.h
Your source files should be in the src/ folder.
Ideally, if you have ROS parameters in your node, you should have the default values and descriptions in a .yaml file in the cfg folder.
Example default_local_planner_params.yaml. Always have units when available!
Last updated