Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

writing_new_controller docs fix (backport #790) #791

Merged
merged 1 commit into from
Oct 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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