From 044db05c476c1bd99132b511e491fc00c8eabd56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20Fr=C3=B6hlich?= Date: Sun, 18 Feb 2024 14:23:11 +0100 Subject: [PATCH 1/2] [CI] Use a single list for lint job (#451) * Use a single list for lint job * Add explicit keyword * Update broken links --- .github/workflows/ci-ros-lint.yml | 44 ++++++++----------- example_11/doc/userdoc.rst | 4 +- .../carlikebot_system.hpp | 2 +- 3 files changed, 21 insertions(+), 29 deletions(-) diff --git a/.github/workflows/ci-ros-lint.yml b/.github/workflows/ci-ros-lint.yml index a87d10281..68d3b0365 100644 --- a/.github/workflows/ci-ros-lint.yml +++ b/.github/workflows/ci-ros-lint.yml @@ -2,6 +2,22 @@ name: ROS Lint on: pull_request: +env: + package-name: + ros2_control_demo_example_1 + ros2_control_demo_example_2 + ros2_control_demo_example_3 + ros2_control_demo_example_4 + ros2_control_demo_example_5 + ros2_control_demo_example_6 + ros2_control_demo_example_7 + ros2_control_demo_example_8 + ros2_control_demo_example_9 + ros2_control_demo_example_10 + ros2_control_demo_example_11 + ros2_control_demo_example_12 + ros2_control_demo_example_14 + jobs: ament_lint: name: ament_${{ matrix.linter }} @@ -19,20 +35,7 @@ jobs: with: distribution: rolling linter: ${{ matrix.linter }} - package-name: - ros2_control_demo_example_1 - ros2_control_demo_example_2 - ros2_control_demo_example_3 - ros2_control_demo_example_4 - ros2_control_demo_example_5 - ros2_control_demo_example_6 - ros2_control_demo_example_7 - ros2_control_demo_example_8 - ros2_control_demo_example_9 - ros2_control_demo_example_10 - ros2_control_demo_example_11 - ros2_control_demo_example_12 - ros2_control_demo_example_14 + package-name: ${{ env.package-name }} ament_lint_100: name: ament_${{ matrix.linter }} @@ -49,15 +52,4 @@ jobs: distribution: rolling linter: cpplint arguments: "--linelength=100 --filter=-whitespace/newline" - package-name: - ros2_control_demo_example_1 - ros2_control_demo_example_2 - ros2_control_demo_example_3 - ros2_control_demo_example_4 - ros2_control_demo_example_5 - ros2_control_demo_example_6 - ros2_control_demo_example_7 - ros2_control_demo_example_8 - ros2_control_demo_example_9 - ros2_control_demo_example_12 - ros2_control_demo_example_14 + package-name: ${{ env.package-name }} diff --git a/example_11/doc/userdoc.rst b/example_11/doc/userdoc.rst index c2dbb96d2..1d40c0cad 100644 --- a/example_11/doc/userdoc.rst +++ b/example_11/doc/userdoc.rst @@ -121,10 +121,10 @@ Files used for this demos * Controllers yaml: `carlikebot_controllers.yaml `__ * URDF file: `carlikebot.urdf.xacro `__ - * Description: `carlikebot_description.urdf.xacro `__ + * Description: `carlikebot.urdf.xacro `__ * ``ros2_control`` tag: `carlikebot.ros2_control.xacro `__ -* RViz configuration: `carlikebot.rviz `__ +* RViz configuration: `carlikebot.rviz `__ * Hardware interface plugin: `carlikebot_system.cpp `__ diff --git a/example_11/hardware/include/ros2_control_demo_example_11/carlikebot_system.hpp b/example_11/hardware/include/ros2_control_demo_example_11/carlikebot_system.hpp index 1fc539332..0043699bd 100644 --- a/example_11/hardware/include/ros2_control_demo_example_11/carlikebot_system.hpp +++ b/example_11/hardware/include/ros2_control_demo_example_11/carlikebot_system.hpp @@ -45,7 +45,7 @@ struct JointValue struct Joint { - Joint(const std::string & name) : joint_name(name) + explicit Joint(const std::string & name) : joint_name(name) { state = JointValue(); command = JointValue(); From d472f5ea4f67f8c81051ed6297528872b59e85e2 Mon Sep 17 00:00:00 2001 From: "Felix Exner (fexner)" Date: Sun, 3 Mar 2024 19:23:16 +0100 Subject: [PATCH 2/2] Update all demos using the description from topic rather than the parameter (#456) * Updated demos * Example 14: Check for NaN in write method Since activation of the "hardware" takes some time, the resource manager might try to write the initial NaN value to the hardware. This commit adds a check to the write method for that. --------- Co-authored-by: Sai Kishor Kothakota --- example_1/bringup/launch/rrbot.launch.py | 2 +- example_10/bringup/launch/rrbot.launch.py | 2 +- .../bringup/launch/carlikebot.launch.py | 8 +----- example_12/bringup/launch/rrbot.launch.py | 2 +- ...ck_sensors_for_position_feedback.launch.py | 2 +- .../rrbot_actuator_without_feedback.cpp | 28 ++++++++++--------- example_2/bringup/launch/diffbot.launch.py | 2 +- .../rrbot_system_multi_interface.launch.py | 2 +- .../launch/rrbot_system_with_sensor.launch.py | 2 +- ...rbot_system_with_external_sensor.launch.py | 2 +- .../launch/rrbot_modular_actuators.launch.py | 2 +- .../bringup/launch/r6bot_controller.launch.py | 2 +- ...ansmissions_system_position_only.launch.py | 2 +- example_9/bringup/launch/rrbot.launch.py | 2 +- 14 files changed, 28 insertions(+), 32 deletions(-) diff --git a/example_1/bringup/launch/rrbot.launch.py b/example_1/bringup/launch/rrbot.launch.py index e25a132ab..0de1813d1 100644 --- a/example_1/bringup/launch/rrbot.launch.py +++ b/example_1/bringup/launch/rrbot.launch.py @@ -67,7 +67,7 @@ def generate_launch_description(): control_node = Node( package="controller_manager", executable="ros2_control_node", - parameters=[robot_description, robot_controllers], + parameters=[robot_controllers], output="both", ) robot_state_pub_node = Node( diff --git a/example_10/bringup/launch/rrbot.launch.py b/example_10/bringup/launch/rrbot.launch.py index 9326d4690..7e975d565 100644 --- a/example_10/bringup/launch/rrbot.launch.py +++ b/example_10/bringup/launch/rrbot.launch.py @@ -50,7 +50,7 @@ def generate_launch_description(): control_node = Node( package="controller_manager", executable="ros2_control_node", - parameters=[robot_description, robot_controllers], + parameters=[robot_controllers], output="both", ) robot_state_pub_node = Node( diff --git a/example_11/bringup/launch/carlikebot.launch.py b/example_11/bringup/launch/carlikebot.launch.py index a15ea1256..4a7adce19 100644 --- a/example_11/bringup/launch/carlikebot.launch.py +++ b/example_11/bringup/launch/carlikebot.launch.py @@ -78,7 +78,6 @@ def generate_launch_description(): parameters=[robot_controllers], output="both", remappings=[ - ("~/robot_description", "/robot_description"), ("/bicycle_steering_controller/tf_odometry", "/tf"), ], condition=IfCondition(remap_odometry_tf), @@ -88,9 +87,7 @@ def generate_launch_description(): executable="ros2_control_node", parameters=[robot_controllers], output="both", - remappings=[ - ("~/robot_description", "/robot_description"), - ], + remappings=[], condition=UnlessCondition(remap_odometry_tf), ) robot_state_pub_bicycle_node = Node( @@ -98,9 +95,6 @@ def generate_launch_description(): executable="robot_state_publisher", output="both", parameters=[robot_description], - remappings=[ - ("~/robot_description", "/robot_description"), - ], ) rviz_node = Node( package="rviz2", diff --git a/example_12/bringup/launch/rrbot.launch.py b/example_12/bringup/launch/rrbot.launch.py index 07b4a486b..b89c521ed 100644 --- a/example_12/bringup/launch/rrbot.launch.py +++ b/example_12/bringup/launch/rrbot.launch.py @@ -53,7 +53,7 @@ def generate_launch_description(): control_node = Node( package="controller_manager", executable="ros2_control_node", - parameters=[robot_description, robot_controllers], + parameters=[robot_controllers], output="both", ) robot_state_pub_node = Node( diff --git a/example_14/bringup/launch/rrbot_modular_actuators_without_feedback_sensors_for_position_feedback.launch.py b/example_14/bringup/launch/rrbot_modular_actuators_without_feedback_sensors_for_position_feedback.launch.py index f988a5c70..6c263c12d 100644 --- a/example_14/bringup/launch/rrbot_modular_actuators_without_feedback_sensors_for_position_feedback.launch.py +++ b/example_14/bringup/launch/rrbot_modular_actuators_without_feedback_sensors_for_position_feedback.launch.py @@ -96,7 +96,7 @@ def generate_launch_description(): control_node = Node( package="controller_manager", executable="ros2_control_node", - parameters=[robot_description, robot_controllers], + parameters=[robot_controllers], output="both", ) robot_state_pub_node = Node( diff --git a/example_14/hardware/rrbot_actuator_without_feedback.cpp b/example_14/hardware/rrbot_actuator_without_feedback.cpp index 3c7a6b887..6feb8067c 100644 --- a/example_14/hardware/rrbot_actuator_without_feedback.cpp +++ b/example_14/hardware/rrbot_actuator_without_feedback.cpp @@ -183,21 +183,23 @@ hardware_interface::return_type RRBotActuatorWithoutFeedback::read( hardware_interface::return_type ros2_control_demo_example_14::RRBotActuatorWithoutFeedback::write( const rclcpp::Time & /*time*/, const rclcpp::Duration & /*period*/) { - // START: This part here is for exemplary purposes - Please do not copy to your production code - RCLCPP_INFO( - rclcpp::get_logger("RRBotActuatorWithoutFeedback"), "Writing command: %f", hw_joint_command_); - - // Simulate sending commands to the hardware - std::ostringstream data; - data << hw_joint_command_; - RCLCPP_INFO( - rclcpp::get_logger("RRBotActuatorWithoutFeedback"), "Sending data command: %s", - data.str().c_str()); - send(sock_, data.str().c_str(), strlen(data.str().c_str()), 0); + if (std::isfinite(hw_joint_command_)) + { + // START: This part here is for exemplary purposes - Please do not copy to your production code + RCLCPP_INFO( + rclcpp::get_logger("RRBotActuatorWithoutFeedback"), "Writing command: %f", hw_joint_command_); - RCLCPP_INFO(rclcpp::get_logger("RRBotActuatorWithoutFeedback"), "Joints successfully written!"); - // END: This part here is for exemplary purposes - Please do not copy to your production code + // Simulate sending commands to the hardware + std::ostringstream data; + data << hw_joint_command_; + RCLCPP_INFO( + rclcpp::get_logger("RRBotActuatorWithoutFeedback"), "Sending data command: %s", + data.str().c_str()); + send(sock_, data.str().c_str(), strlen(data.str().c_str()), 0); + RCLCPP_INFO(rclcpp::get_logger("RRBotActuatorWithoutFeedback"), "Joints successfully written!"); + // END: This part here is for exemplary purposes - Please do not copy to your production code + } return hardware_interface::return_type::OK; } diff --git a/example_2/bringup/launch/diffbot.launch.py b/example_2/bringup/launch/diffbot.launch.py index 7a71af0b8..04b454a0f 100644 --- a/example_2/bringup/launch/diffbot.launch.py +++ b/example_2/bringup/launch/diffbot.launch.py @@ -73,7 +73,7 @@ def generate_launch_description(): control_node = Node( package="controller_manager", executable="ros2_control_node", - parameters=[robot_description, robot_controllers], + parameters=[robot_controllers], output="both", ) robot_state_pub_node = Node( diff --git a/example_3/bringup/launch/rrbot_system_multi_interface.launch.py b/example_3/bringup/launch/rrbot_system_multi_interface.launch.py index e10c7997e..969cf745f 100644 --- a/example_3/bringup/launch/rrbot_system_multi_interface.launch.py +++ b/example_3/bringup/launch/rrbot_system_multi_interface.launch.py @@ -119,7 +119,7 @@ def generate_launch_description(): control_node = Node( package="controller_manager", executable="ros2_control_node", - parameters=[robot_description, robot_controllers], + parameters=[robot_controllers], output="both", ) robot_state_pub_node = Node( diff --git a/example_4/bringup/launch/rrbot_system_with_sensor.launch.py b/example_4/bringup/launch/rrbot_system_with_sensor.launch.py index b95039147..857d5963e 100644 --- a/example_4/bringup/launch/rrbot_system_with_sensor.launch.py +++ b/example_4/bringup/launch/rrbot_system_with_sensor.launch.py @@ -111,7 +111,7 @@ def generate_launch_description(): control_node = Node( package="controller_manager", executable="ros2_control_node", - parameters=[robot_description, robot_controllers], + parameters=[robot_controllers], output="both", ) robot_state_pub_node = Node( diff --git a/example_5/bringup/launch/rrbot_system_with_external_sensor.launch.py b/example_5/bringup/launch/rrbot_system_with_external_sensor.launch.py index 229195642..675499902 100755 --- a/example_5/bringup/launch/rrbot_system_with_external_sensor.launch.py +++ b/example_5/bringup/launch/rrbot_system_with_external_sensor.launch.py @@ -111,7 +111,7 @@ def generate_launch_description(): control_node = Node( package="controller_manager", executable="ros2_control_node", - parameters=[robot_description, robot_controllers], + parameters=[robot_controllers], output="both", ) robot_state_pub_node = Node( diff --git a/example_6/bringup/launch/rrbot_modular_actuators.launch.py b/example_6/bringup/launch/rrbot_modular_actuators.launch.py index 24821fd70..8c097d899 100644 --- a/example_6/bringup/launch/rrbot_modular_actuators.launch.py +++ b/example_6/bringup/launch/rrbot_modular_actuators.launch.py @@ -119,7 +119,7 @@ def generate_launch_description(): control_node = Node( package="controller_manager", executable="ros2_control_node", - parameters=[robot_description, robot_controllers], + parameters=[robot_controllers], output="both", ) robot_state_pub_node = Node( diff --git a/example_7/bringup/launch/r6bot_controller.launch.py b/example_7/bringup/launch/r6bot_controller.launch.py index bc3e048ba..135c69453 100644 --- a/example_7/bringup/launch/r6bot_controller.launch.py +++ b/example_7/bringup/launch/r6bot_controller.launch.py @@ -52,7 +52,7 @@ def generate_launch_description(): control_node = Node( package="controller_manager", executable="ros2_control_node", - parameters=[robot_description, robot_controllers], + parameters=[robot_controllers], remappings=[ ( "/forward_position_controller/commands", diff --git a/example_8/bringup/launch/rrbot_transmissions_system_position_only.launch.py b/example_8/bringup/launch/rrbot_transmissions_system_position_only.launch.py index f42999770..4476a3f35 100644 --- a/example_8/bringup/launch/rrbot_transmissions_system_position_only.launch.py +++ b/example_8/bringup/launch/rrbot_transmissions_system_position_only.launch.py @@ -96,7 +96,7 @@ def generate_launch_description(): control_node = Node( package="controller_manager", executable="ros2_control_node", - parameters=[robot_description, robot_controllers], + parameters=[robot_controllers], output="both", ) robot_state_pub_node = Node( diff --git a/example_9/bringup/launch/rrbot.launch.py b/example_9/bringup/launch/rrbot.launch.py index 2a61c1cee..fbc54bcc0 100644 --- a/example_9/bringup/launch/rrbot.launch.py +++ b/example_9/bringup/launch/rrbot.launch.py @@ -68,7 +68,7 @@ def generate_launch_description(): control_node = Node( package="controller_manager", executable="ros2_control_node", - parameters=[robot_description, robot_controllers], + parameters=[robot_controllers], output="both", ) robot_state_pub_node = Node(