You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/writing_new_controller.rst
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,7 @@ The following is a step-by-step guide to create source files, basic tests, and c
11
11
If the package for the controller does not exist, then create it first.
12
12
The package should have ``ament_cmake`` as a build type.
13
13
The easiest way is to search online for the most recent manual.
14
-
A helpful command to support this process is `ros2 pkg create`.
14
+
A helpful command to support this process is ``ros2 pkg create``.
15
15
Use the ``--help`` flag for more information on how to use it.
16
16
There is also an option to create library source files and compile rules to help you in the following steps.
17
17
@@ -33,10 +33,10 @@ The following is a step-by-step guide to create source files, basic tests, and c
33
33
34
34
4. Define the class of the controller, extending ``ControllerInterface``, e.g.,
35
35
.. code:: c++
36
-
class ControllerName : public controller_interface::ControllerInterface
36
+
class ControllerName : public controller_interface::ControllerInterface
37
37
38
38
5. Add a constructor without parameters and the following public methods overriding the ``ControllerInterface`` definition: ``init``, ``command_interface_configuration``, ``state_interface_configuration``, ``on_configure``, ``on_activate``, ``on_deactivate``, ``update``.
39
-
For exact definitions check the ``controller_interface/controller_interface.hpp`` header or one of the controllers from `ros2_controllers <https://github.com/ros-controls/ros2_controllers>`_.
39
+
For exact definitions check the ``controller_interface/controller_interface.hpp`` header or one of the controllers from `ros2_controllers <https://github.com/ros-controls/ros2_controllers>`_.
40
40
41
41
6. (optional) Often, controllers accept lists of joint names and interface names as parameters.
42
42
If so, you can add two protected string vectors to store those values.
@@ -76,7 +76,7 @@ The following is a step-by-step guide to create source files, basic tests, and c
76
76
5. **Writing export definition for pluginlib**
77
77
78
78
1. Create the ``<controller_name>.xml`` file in the package and add a definition of the library and controller's class which has to be visible for the pluginlib.
79
-
The easiest way to do that is to check other controllers in the `ros2_controllers <https://github.com/ros-controls/ros2_controllers>`_ package.
79
+
The easiest way to do that is to check other controllers in the `ros2_controllers <https://github.com/ros-controls/ros2_controllers>`_ package.
80
80
81
81
2. Usually, the plugin name is defined by the package (namespace) and the class name, e.g.,
82
82
``<controller_name_package>/<ControllerName>``.
@@ -85,9 +85,9 @@ The following is a step-by-step guide to create source files, basic tests, and c
85
85
86
86
6. **Writing simple test to check if the controller can be found and loaded**
87
87
88
-
1. Create the folder ``test`` in your package, if it does not exist already, and add a file named ``test_load_<controller_name>.cpp>.
88
+
1. Create the folder ``test`` in your package, if it does not exist already, and add a file named ``test_load_<controller_name>.cpp``.
89
89
90
-
2. You can safely copy the file's content for any controller defined in the `ros2_controllers <https://github.com/ros-controls/ros2_controllers>`_ package.
90
+
2. You can safely copy the file's content for any controller defined in the `ros2_controllers <https://github.com/ros-controls/ros2_controllers>`_ package.
91
91
92
92
3. Change the name of the copied test and in the last line, where controller type is specified put the name defined in ``<controller_name>.xml`` file, e.g., ``<controller_name_package>/<ControllerName>``.
93
93
@@ -112,7 +112,7 @@ The following is a step-by-step guide to create source files, basic tests, and c
112
112
7. In the test section add the following dependencies: ``ament_cmake_gmock``, ``controller_manager``, ``hardware_interface``, ``ros2_control_test_assets``.
113
113
114
114
8. Add compile definitions for the tests using the ``ament_add_gmock`` directive.
115
-
For details, see how it is done for controllers in the `ros2_controllers <https://github.com/ros-controls/ros2_controllers>`_ package.
115
+
For details, see how it is done for controllers in the `ros2_controllers <https://github.com/ros-controls/ros2_controllers>`_ package.
116
116
117
117
9. (optional) Add your controller`s library into ``ament_export_libraries`` before ``ament_package()``.
0 commit comments