File size: 5,040 Bytes
2d6bfa0 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
.. _contributing_ros:
Robot Operating System (ROS)
=============================
ROS packages naming and structure
----------------------------------
Creating a new package
^^^^^^^^^^^^^^^^^^^^^^^
* Naming
In order to create a new ROS package for one of the repositories some rules need to be considered:
1. The package name has always the following format:
.. code-block:: bash
prefix_my_package_name
2. Use the right prefix for every repository:
a. mas_domestic_robotics: *mdr_*
b. mas_industrial_robotics: *mir_*
c. mas_common_robotics: *mcr_*
3. Use lowercase.
4. Separate words in the package name by underscores (_).
Examples for creating packages according to the above described rules are as follows:
.. code-block:: bash
catkin create_pkg mdr_grasp_planning
catkin create_pkg mir_whole_body_control
catkin create_pkg mcr_object_detection
* Folder structure
Every ROS package within our repositories has to strictly match the following structure:
.. code-block:: bash
.
βββ common
β βββ config
β βββ include
β β βββ <package_name>
β βββ src
β β βββ <package_name>
β βββ test
β βββ tools
βββ ros
β βββ config
β βββ include
β β βββ <package_name>
β βββ launch
β β βββ <package_name>.launch
β βββ rviz
β β βββ <package_name>.rviz
β βββ scripts
β β βββ <package_name>
β βββ src
β β βββ <package_name>_node
β βββ test
β βββ tools
βββ CMakeLists.txt
βββ package.xml
βββ setup.py
βββ README.md
In short:
* ROS-independent code goes into the `common` folder
* the `ros` folder contains a ROS-wrapper for the functionality you are adding
Meta-packages
^^^^^^^^^^^^^^
If the package you are creating is meant to contain other packages inside of it, it needs to have instead the following structure:
.. code-block:: bash
./<meta_package_name>
βββ <meta_package_name>
βββ CMakeLists.txt
βββ package.xml
βββ README.md
.. note::
It is **extremely** important to maintain your *package.xml* up to date with its dependencies.
Not doing so results in the need of specialized tools or manual inspection of launch files and
source code to discover your package dependencies.
Messages, services and actions
-------------------------------
Creating a new message, service or action.
If your package defines its own messages, services or actions you should add them to the corresponding meta-package:
.. code-block:: bash
./<package_name>_msgs
βββ action
β βββ MyAction.action
βββ msg
β βββ MyMessage.msg
βββ srv
β βββ MyService.srv
βββ CMakeLists.txt
βββ package.xml
βββ README.md
.. note::
The *srv* file name should start with verb i.e. *RecognizeImage.srv*
Depending on the repository you are working on, the meta-package is related to the domain, e.g. *mdr_planning_msgs* or *mdr_navigation_actions*
Linting
--------
Running **roslint** with catkin
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Before merging into the main repository *roslint* is ran on all merge requests.
Unless all errors are resolved the merge request will be rejected. To test if your changes would pass the *roslint* test locally:
* Add the following lines to your `CMakelists.txt`:
.. code-block:: bash
find_package(catkin REQUIRED COMPONENTS roslint ...)
roslint_python() # pep8 linting
roslint_cpp() # ROS wrapper of Google's cpplint
Your *package.xm* should include *roslint* as a build dependency:
.. code-block:: bash
<build_depend>roslint</build_depend>
* Build target roslint:
* with `catkin_make`:
.. code-block:: bash
catkin_make roslint_<package_name>
* with `catkin_tools`:
.. code-block:: bash
catkin build --no-deps <package_name> --make-args roslint_<package_name>
* If build fail copy and execute the gray line that looks something like the following to see more detailed errors:
.. code-block:: bash
cd <package_source_directory>
catkin build --get-env <package_name> | catkin env -si /usr/bin/make roslint --jobserver-fds=6,7 -j; cd -
Running **catkin_lint**
^^^^^^^^^^^^^^^^^^^^^^^^^
You should also make sure that the *catkin_lint* tests pass;
running it from the root of your catkin workspace you can run:
.. code-block:: bash
catkin_lint --strict --ignore CRITICAL_VAR_APPEND,LINK_DIRECTORY src/mas_domestic_robotics
See Also:
* `roslint <http://wiki.ros.org/roslint>`_
* `catkin_lint <http://fkie.github.io/catkin_lint/>`_
Proposed linters:
* `C++ <https://github.com/cpplint/cpplint>`_
* `Python <https://www.pylint.org/>`_
* `ROS <http://wiki.ros.org/roslint>`_
|