Skip to content

Commit

Permalink
Merge branch 'master' into jtc/dynamic_parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
christophfroehlich authored Oct 9, 2023
2 parents f8784ea + f62fc3a commit 4876041
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions doc/writing_new_controller.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ The following is a step-by-step guide to create source files, basic tests, and c
3. Define a unique namespace for your controller. This is usually a package name written in ``snake_case``.

4. Define the class of the controller, extending ``ControllerInterface``, e.g.,

.. code:: c++
class ControllerName : public controller_interface::ControllerInterface

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``.
class ControllerName : public controller_interface::ControllerInterface

5. Add a constructor without parameters and the following public methods overriding the ``ControllerInterface`` definition: ``on_init``, ``command_interface_configuration``, ``state_interface_configuration``, ``on_configure``, ``on_activate``, ``on_deactivate``, ``update``.
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>`_.

6. (optional) Often, controllers accept lists of joint names and interface names as parameters.
Expand All @@ -48,9 +50,9 @@ The following is a step-by-step guide to create source files, basic tests, and c
1. Include the header file of your controller and add a namespace definition to simplify further development.

2. (optional) Implement a constructor if needed. There, you could initialize member variables.
This could also be done in the ``init`` method.
This could also be done in the ``on_init`` method.

3. Implement the ``init`` method. The first line usually calls the parent ``init`` method.
3. Implement the ``on_init`` method. The first line usually calls the parent ``on_init`` method.
Here is the best place to initialize the variables, reserve memory, and most importantly, declare node parameters used by the controller. If everything works fine return ``controller_interface::return_type::OK`` or ``controller_interface::return_type::ERROR`` otherwise.

4. Write the ``on_configure`` method. Parameters are usually read here, and everything is prepared so that the controller can be started.
Expand Down Expand Up @@ -105,6 +107,7 @@ The following is a step-by-step guide to create source files, basic tests, and c
4. Add ament dependencies needed by the library. You should add at least those listed under 1.

5. Export for pluginlib description file using the following command:

.. code:: cmake
pluginlib_export_plugin_description_file(controller_interface <controller_name>.xml)
Expand Down

0 comments on commit 4876041

Please sign in to comment.