-
Notifications
You must be signed in to change notification settings - Fork 310
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'humble' into mergify/bp/humble/pr-742
- Loading branch information
Showing
35 changed files
with
1,076 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
controller_interface/include/semantic_components/range_sensor.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// Copyright 2023 flochre | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#ifndef SEMANTIC_COMPONENTS__RANGE_SENSOR_HPP_ | ||
#define SEMANTIC_COMPONENTS__RANGE_SENSOR_HPP_ | ||
|
||
#include <limits> | ||
#include <string> | ||
#include <vector> | ||
|
||
#include "semantic_components/semantic_component_interface.hpp" | ||
#include "sensor_msgs/msg/range.hpp" | ||
|
||
namespace semantic_components | ||
{ | ||
class RangeSensor : public SemanticComponentInterface<sensor_msgs::msg::Range> | ||
{ | ||
public: | ||
explicit RangeSensor(const std::string & name) : SemanticComponentInterface(name, 1) | ||
{ | ||
interface_names_.emplace_back(name_ + "/" + "range"); | ||
} | ||
|
||
virtual ~RangeSensor() = default; | ||
|
||
/** | ||
* Return Range reported by a sensor | ||
* | ||
* \return value of the range in meters | ||
*/ | ||
float get_range() { return state_interfaces_[0].get().get_value(); } | ||
|
||
/// Return Range message with range in meters | ||
/** | ||
* Constructs and return a Range message from the current values. | ||
* \return Range message from values; | ||
*/ | ||
bool get_values_as_message(sensor_msgs::msg::Range & message) | ||
{ | ||
// update the message values | ||
message.range = get_range(); | ||
|
||
return true; | ||
} | ||
}; | ||
|
||
} // namespace semantic_components | ||
|
||
#endif // SEMANTIC_COMPONENTS__RANGE_SENSOR_HPP_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
<?xml-model href="http://download.ros.org/schema/package_format2.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?> | ||
<package format="2"> | ||
<name>controller_interface</name> | ||
<version>2.29.0</version> | ||
<version>2.33.0</version> | ||
<description>Description of controller_interface</description> | ||
<maintainer email="[email protected]">Bence Magyar</maintainer> | ||
<maintainer email="[email protected]">Denis Štogl</maintainer> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
:github_url: https://github.com/ros-controls/ros2_control/blob/{REPOS_FILE_BRANCH}/controller_manager/doc/controller_chaining.rst | ||
|
||
.. _controller_chaining: | ||
|
||
Controller Chaining / Cascade Control | ||
====================================== | ||
|
||
This document proposes a minimal-viable-implementation of serial controller chaining as described in `Chaining Controllers design document <https://github.com/ros-controls/roadmap/blob/master/design_drafts/controller_chaining.md>`__. | ||
Cascade control is a specific type of controller chaining. | ||
|
||
|
||
Scope of the Document and Background Knowledge | ||
------------------------------------------------------- | ||
|
||
This approach focuses only on serial chaining of controllers and tries to reuse existing mechanisms for it. | ||
It focuses on `inputs and outputs of a controller <https://github.com/ros-controls/roadmap/blob/master/design_drafts/controller_chaining.md#input--outputs-of-a-controller>`__ and their management in the controller manager. | ||
The concept of `controller groups <https://github.com/ros-controls/roadmap/blob/master/design_drafts/controller_chaining.md#controller-group>`__ will be introduced only for clarity reasons, and its only meaning is that controllers in that group can be updated in arbitrary order. | ||
This doesn't mean that the controller groups as described `in the controller chaining document <https://github.com/ros-controls/roadmap/blob/master/design_drafts/controller_chaining.md#controller-group>`__ will not be introduced and used in the future. | ||
Nevertheless, the author is convinced that this would add only unnecessary complexity at this stage, although in the long term they *could* provide clearer structure and interfaces. | ||
|
||
Motivation, Purpose and Use | ||
--------------------------------- | ||
|
||
To describe the intent of this document, lets focus on the simple yet sufficient example `Example 2 from 'controllers_chaining' design docs <https://github.com/ros-controls/roadmap/blob/master/design_drafts/controller_chaining.md#example-2>`__: | ||
|
||
.. image:: images/chaining_example2.png | ||
:alt: Example2 | ||
|
||
|
||
In this example, we want to chain 'position_tracking' controller with 'diff_drive_controller' and two PID controllers. | ||
Let's now imagine a use-case where we don't only want to run all those controllers as a group, but also flexibly add preceding steps. | ||
This means the following: | ||
|
||
1. When a robot is started, we want to check if motor velocity control is working properly and therefore only PID controllers are activated. | ||
At this stage we can control the input of PID controller also externally using topics. | ||
However, these controllers also provide virtual interfaces, so we can chain them. | ||
2. Then "diff_drive_controller" is activated and attaches itself to the virtual input interfaces of PID controllers. | ||
PID controllers also get informed that they are working in chained mode and therefore disable their external interface through subscriber. | ||
Now we check if kinematics of differential robot is running properly. | ||
3. After that, "position_tracking" can be activated and attached to "diff_drive_controller" that disables its external interfaces. | ||
4. If any of the controllers is deactivated, also all preceding controllers are deactivated. | ||
|
||
|
||
Implementation | ||
-------------- | ||
|
||
A Controller Base-Class: ChainableController | ||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
A ``ChainableController`` extends ``ControllerInterface`` class with ``virtual InterfaceConfiguration input_interface_configuration() const = 0`` method. | ||
This method should implement for each controller that **can be preceded** by another controller exporting all the input interfaces. | ||
For simplicity reasons, it is assumed for now that controller's all input interfaces are used. | ||
Therefore, do not try to implement any exclusive combinations of input interfaces, but rather write multiple controllers if you need exclusivity. | ||
|
||
The ``ChainableController`` base class implements ``void set_chained_mode(bool activate)`` that sets an internal flag that a controller is used by another controller (in chained mode) and calls ``virtual void on_set_chained_mode(bool activate) = 0`` that implements controller's specific actions when chained modes is activated or deactivated, e.g., deactivating subscribers. | ||
|
||
As an example, PID controllers export one virtual interface ``pid_reference`` and stop their subscriber ``<controller_name>/pid_reference`` when used in chained mode. 'diff_drive_controller' controller exports list of virtual interfaces ``<controller_name>/v_x``, ``<controller_name>/v_y``, and ``<controller_name>/w_z``, and stops subscribers from topics ``<controller_name>/cmd_vel`` and ``<controller_name>/cmd_vel_unstamped``. Its publishers can continue running. | ||
|
||
Inner Resource Management | ||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
After configuring a chainable controller, controller manager calls ``input_interface_configuration`` method and takes ownership over controller's input interfaces. | ||
This is the same process as done by ``ResourceManager`` and hardware interfaces. | ||
Controller manager maintains "claimed" status of interface in a vector (the same as done in ``ResourceManager``). | ||
|
||
|
||
Activation and Deactivation Chained Controllers | ||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
Chained controllers must be activated and deactivated together or in the proper order. | ||
This means you must first activate all following controllers to have the preceding one activated. | ||
For the deactivation there is the inverse rule - all preceding controllers have to be deactivated before the following controller is deactivated. | ||
One can also think of it as an actual chain, you can not add a chain link or break the chain in the middle. | ||
|
||
|
||
Debugging outputs | ||
---------------------------- | ||
|
||
Flag ``unavailable`` on reference interface does not provide much information about anything at the moment. So don't get confused by it. The reason we have it are internal implementation reasons irelevant for the usage. | ||
|
||
|
||
Closing remarks | ||
---------------------------- | ||
|
||
- Maybe addition of the new controller's type ``ChainableController`` is not necessary. It would also be feasible to add implementation of ``input_interface_configuration()`` method into ``ControllerInterface`` class with default result ``interface_configuration_type::NONE``. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
<?xml-model href="http://download.ros.org/schema/package_format2.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?> | ||
<package format="2"> | ||
<name>controller_manager</name> | ||
<version>2.29.0</version> | ||
<version>2.33.0</version> | ||
<description>Description of controller_manager</description> | ||
<maintainer email="[email protected]">Bence Magyar</maintainer> | ||
<maintainer email="[email protected]">Denis Štogl</maintainer> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?> | ||
<package format="3"> | ||
<name>controller_manager_msgs</name> | ||
<version>2.29.0</version> | ||
<version>2.33.0</version> | ||
<description>Messages and services for the controller manager.</description> | ||
<maintainer email="[email protected]">Bence Magyar</maintainer> | ||
<maintainer email="[email protected]">Denis Štogl</maintainer> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.