You're reading the documentation for an older, but still supported, version of ROS 2. For information on the latest version, please have a look at Jazzy.

gpio_controllers

This is a collection of controllers for hardware interfaces of type GPIO (<gpio> tag in the URDF).

gpio_command_controller

gpio_command_controller let the user expose command interfaces of given GPIO interfaces and publishes state interfaces of the configured command interfaces.

Description of controller’s interfaces

  • /<controller_name>/gpio_states [control_msgs/msg/DynamicJointState]: Publishes all state interfaces of the given GPIO interfaces.

  • /<controller_name>/commands [control_msgs/msg/DynamicJointState]: A subscriber for configured command interfaces.

Parameters

This controller uses the generate_parameter_library to handle its parameters. The parameter definition file located in the src folder contains descriptions for all the parameters used by the controller.

gpios (string_array)

List of gpios

Read only: True

Constraints:

  • length is greater than 0

  • contains no duplicates

command_interfaces.<gpios>.interfaces (string_array)

List of command interfaces for each gpio.

Read only: True

Default: {}

Constraints:

  • contains no duplicates

state_interfaces.<gpios>.interfaces (string_array)

List of state interfaces for each gpio. If empty all available gpios’ states are used.

Read only: True

Default: {}

Constraints:

  • contains no duplicates

The controller expects at least one GPIO interface and the corresponding command interface names or state interface. However, these Command and State interfaces are optional. The controller behaves as a broadcaster when no Command Interface is present, thereby publishing the configured GPIO state interfaces if set.

Note

When no state or command interface is provided in the param file, the controller will fail during initialization.

gpio_command_controller:
  ros__parameters:
    type: gpio_controllers/GpioCommandController
    gpios:
      - Gpio1
      - Gpio2
    command_interfaces:
      Gpio1:
        - interfaces:
          - dig.1
          - dig.2
          - dig.3
      Gpio2:
        - interfaces:
          - ana.1
          - ana.2
    state_interfaces:
      Gpio2:
        - interfaces:
          - ana.1
          - ana.2

With the above-defined controller configuration, the controller will accept commands for all gpios’ interfaces and will only publish the state of Gpio2.