Skip to content

Commit

Permalink
Merge branch 'master' into ci_jazzy
Browse files Browse the repository at this point in the history
  • Loading branch information
bmagyar committed May 7, 2024
2 parents 1e01f25 + 607755e commit 880deb5
Show file tree
Hide file tree
Showing 41 changed files with 1,775 additions and 61 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/update-pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ name: Auto Update pre-commit
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * 0' # Run every Sunday at midnight
- cron: '0 0 1 * *' # Runs at 00:00, on day 1 of the month

jobs:
auto_update_and_create_pr:
Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ repos:
args: ["--ignore=D100,D101,D102,D103,D104,D105,D106,D107,D203,D212,D404"]

- repo: https://github.com/psf/black
rev: 24.3.0
rev: 24.4.2
hooks:
- id: black
args: ["--line-length=99"]
Expand All @@ -62,7 +62,7 @@ repos:

# CPP hooks
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v18.1.3
rev: v18.1.4
hooks:
- id: clang-format
args: ['-fallback-style=none', '-i']
Expand Down Expand Up @@ -132,7 +132,7 @@ repos:
exclude: CHANGELOG\.rst|\.(svg|pyc|drawio)$

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.28.1
rev: 0.28.2
hooks:
- id: check-github-workflows
args: ["--verbose"]
Expand Down
5 changes: 5 additions & 0 deletions controller_interface/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
Changelog for package controller_interface
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

4.9.0 (2024-04-30)
------------------
* return the proper const object of the pointer in the const method (`#1494 <https://github.com/ros-controls/ros2_control/issues/1494>`_)
* Contributors: Sai Kishor Kothakota

4.8.0 (2024-03-27)
------------------
* generate version.h file per package using the ament_generate_version_header (`#1449 <https://github.com/ros-controls/ros2_control/issues/1449>`_)
Expand Down
2 changes: 1 addition & 1 deletion controller_interface/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>4.8.0</version>
<version>4.9.0</version>
<description>Description of controller_interface</description>
<maintainer email="bence.magyar.robotics@gmail.com">Bence Magyar</maintainer>
<maintainer email="denis@stoglrobotics.de">Denis Štogl</maintainer>
Expand Down
6 changes: 6 additions & 0 deletions controller_manager/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
Changelog for package controller_manager
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

4.9.0 (2024-04-30)
------------------
* Deactivate the controllers when they return error similar to hardware (`#1499 <https://github.com/ros-controls/ros2_control/issues/1499>`_)
* Component parser: Get mimic information from URDF (`#1256 <https://github.com/ros-controls/ros2_control/issues/1256>`_)
* Contributors: Christoph Fröhlich, Sai Kishor Kothakota

4.8.0 (2024-03-27)
------------------
* generate version.h file per package using the ament_generate_version_header (`#1449 <https://github.com/ros-controls/ros2_control/issues/1449>`_)
Expand Down
6 changes: 6 additions & 0 deletions controller_manager/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,12 @@ if(BUILD_TESTING)
ros2_control_test_assets::ros2_control_test_assets
)

install(FILES test/test_controller_spawner_with_fallback_controllers.yaml
DESTINATION test)

install(FILES test/test_controller_spawner_with_type.yaml
DESTINATION test)

ament_add_gmock(test_hardware_management_srvs
test/test_hardware_management_srvs.cpp
)
Expand Down
7 changes: 7 additions & 0 deletions controller_manager/controller_manager/launch_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import warnings
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.substitutions import LaunchConfiguration, PythonExpression
Expand Down Expand Up @@ -61,6 +62,12 @@ def generate_load_controller_launch_description(
]

if controller_type:
warnings.warn(
"The 'controller_type' argument is deprecated and will be removed in future releases."
" Declare the controller type parameter in the param file instead.",
DeprecationWarning,
stacklevel=2,
)
spawner_arguments += ["--controller-type", controller_type]

if controller_params_file:
Expand Down
78 changes: 76 additions & 2 deletions controller_manager/controller_manager/spawner.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import sys
import time
import warnings
import yaml

from controller_manager import (
configure_controller,
Expand Down Expand Up @@ -135,6 +136,21 @@ def is_controller_loaded(node, controller_manager, controller_name):
return any(c.name == controller_name for c in controllers)


def get_parameter_from_param_file(controller_name, parameter_file, parameter_name):
with open(parameter_file) as f:
parameters = yaml.safe_load(f)
if controller_name in parameters:
value = parameters[controller_name]
if not isinstance(value, dict) or "ros__parameters" not in value:
raise RuntimeError(
f"YAML file : {parameter_file} is not a valid ROS parameter file for controller : {controller_name}"
)
if parameter_name in parameters[controller_name]["ros__parameters"]:
return parameters[controller_name]["ros__parameters"][parameter_name]
else:
return None


def main(args=None):
rclpy.init(args=args, signal_handler_options=SignalHandlerOptions.NO)
parser = argparse.ArgumentParser()
Expand Down Expand Up @@ -170,7 +186,7 @@ def main(args=None):
parser.add_argument(
"-t",
"--controller-type",
help="If not provided it should exist in the controller manager namespace",
help="If not provided it should exist in the controller manager namespace (deprecated)",
default=None,
required=False,
)
Expand All @@ -194,16 +210,31 @@ def main(args=None):
action="store_true",
required=False,
)
parser.add_argument(
"--fallback_controllers",
help="Fallback controllers list are activated as a fallback strategy when the"
" spawned controllers fail. When the argument is provided, it takes precedence over"
" the fallback_controllers list in the param file",
default=None,
nargs="+",
)

command_line_args = rclpy.utilities.remove_ros_args(args=sys.argv)[1:]
args = parser.parse_args(command_line_args)
controller_names = args.controller_names
controller_manager_name = args.controller_manager
controller_namespace = args.namespace
param_file = args.param_file
controller_type = args.controller_type
controller_manager_timeout = args.controller_manager_timeout

if args.controller_type:
warnings.filterwarnings("always")
warnings.warn(
"The '--controller-type' argument is deprecated and will be removed in future releases."
" Declare the controller type parameter in the param file instead.",
DeprecationWarning,
)

if param_file and not os.path.isfile(param_file):
raise FileNotFoundError(errno.ENOENT, os.strerror(errno.ENOENT), param_file)

Expand All @@ -226,6 +257,8 @@ def main(args=None):
return 1

for controller_name in controller_names:
fallback_controllers = args.fallback_controllers
controller_type = args.controller_type
prefixed_controller_name = controller_name
if controller_namespace:
prefixed_controller_name = controller_namespace + "/" + controller_name
Expand All @@ -237,6 +270,10 @@ def main(args=None):
+ bcolors.ENDC
)
else:
if not controller_type and param_file:
controller_type = get_parameter_from_param_file(
controller_name, param_file, "type"
)
if controller_type:
parameter = Parameter()
parameter.name = prefixed_controller_name + ".type"
Expand Down Expand Up @@ -301,6 +338,43 @@ def main(args=None):
)
return 1

if not fallback_controllers and param_file:
fallback_controllers = get_parameter_from_param_file(
controller_name, param_file, "fallback_controllers"
)

if fallback_controllers:
parameter = Parameter()
parameter.name = prefixed_controller_name + ".fallback_controllers"
parameter.value = get_parameter_value(string_value=str(fallback_controllers))

response = call_set_parameters(
node=node, node_name=controller_manager_name, parameters=[parameter]
)
assert len(response.results) == 1
result = response.results[0]
if result.successful:
node.get_logger().info(
bcolors.OKCYAN
+ 'Setting fallback_controllers to ["'
+ ",".join(fallback_controllers)
+ '"] for '
+ bcolors.BOLD
+ prefixed_controller_name
+ bcolors.ENDC
)
else:
node.get_logger().fatal(
bcolors.FAIL
+ 'Could not set fallback_controllers to ["'
+ ",".join(fallback_controllers)
+ '"] for '
+ bcolors.BOLD
+ prefixed_controller_name
+ bcolors.ENDC
)
return 1

ret = load_controller(node, controller_manager_name, controller_name)
if not ret.ok:
node.get_logger().fatal(
Expand Down
2 changes: 1 addition & 1 deletion controller_manager/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>4.8.0</version>
<version>4.9.0</version>
<description>Description of controller_manager</description>
<maintainer email="bence.magyar.robotics@gmail.com">Bence Magyar</maintainer>
<maintainer email="denis@stoglrobotics.de">Denis Štogl</maintainer>
Expand Down
Loading

0 comments on commit 880deb5

Please sign in to comment.