From dbe4d19cfe80879c72cc67e3a805d34de4139f34 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Wed, 13 Mar 2024 11:41:07 +0100 Subject: [PATCH] Update all demos using the description from topic rather than the parameter (#456) (#472) (#473) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Use correct remapping for iron/humble * 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 Co-authored-by: Felix Exner (fexner) (cherry picked from commit 11d699bd63c79f8a6ed9e4876c2d42a41e705596) Co-authored-by: Christoph Fröhlich --- example_1/bringup/launch/rrbot.launch.py | 5 +++- example_10/bringup/launch/rrbot.launch.py | 5 +++- .../bringup/launch/carlikebot.launch.py | 3 -- example_12/bringup/launch/rrbot.launch.py | 5 +++- ...ck_sensors_for_position_feedback.launch.py | 5 +++- .../rrbot_actuator_without_feedback.cpp | 28 ++++++++++--------- example_2/bringup/launch/diffbot.launch.py | 5 +++- .../rrbot_system_multi_interface.launch.py | 5 +++- .../launch/rrbot_system_with_sensor.launch.py | 5 +++- ...rbot_system_with_external_sensor.launch.py | 5 +++- .../launch/rrbot_modular_actuators.launch.py | 5 +++- .../bringup/launch/r6bot_controller.launch.py | 3 +- ...ansmissions_system_position_only.launch.py | 5 +++- example_9/bringup/launch/rrbot.launch.py | 5 +++- 14 files changed, 61 insertions(+), 28 deletions(-) diff --git a/example_1/bringup/launch/rrbot.launch.py b/example_1/bringup/launch/rrbot.launch.py index e25a132ab..975677fe1 100644 --- a/example_1/bringup/launch/rrbot.launch.py +++ b/example_1/bringup/launch/rrbot.launch.py @@ -67,8 +67,11 @@ def generate_launch_description(): control_node = Node( package="controller_manager", executable="ros2_control_node", - parameters=[robot_description, robot_controllers], + parameters=[robot_controllers], output="both", + remappings=[ + ("~/robot_description", "/robot_description"), + ], ) robot_state_pub_node = Node( package="robot_state_publisher", diff --git a/example_10/bringup/launch/rrbot.launch.py b/example_10/bringup/launch/rrbot.launch.py index c1986fb16..f085790f8 100644 --- a/example_10/bringup/launch/rrbot.launch.py +++ b/example_10/bringup/launch/rrbot.launch.py @@ -65,8 +65,11 @@ def generate_launch_description(): control_node = Node( package="controller_manager", executable="ros2_control_node", - parameters=[robot_description, robot_controllers], + parameters=[robot_controllers], output="both", + remappings=[ + ("~/robot_description", "/robot_description"), + ], ) robot_state_pub_node = Node( package="robot_state_publisher", diff --git a/example_11/bringup/launch/carlikebot.launch.py b/example_11/bringup/launch/carlikebot.launch.py index a15ea1256..231abde30 100644 --- a/example_11/bringup/launch/carlikebot.launch.py +++ b/example_11/bringup/launch/carlikebot.launch.py @@ -98,9 +98,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..9bd3880e5 100644 --- a/example_12/bringup/launch/rrbot.launch.py +++ b/example_12/bringup/launch/rrbot.launch.py @@ -53,8 +53,11 @@ def generate_launch_description(): control_node = Node( package="controller_manager", executable="ros2_control_node", - parameters=[robot_description, robot_controllers], + parameters=[robot_controllers], output="both", + remappings=[ + ("~/robot_description", "/robot_description"), + ], ) robot_state_pub_node = Node( package="robot_state_publisher", 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..8acdf84ce 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,8 +96,11 @@ def generate_launch_description(): control_node = Node( package="controller_manager", executable="ros2_control_node", - parameters=[robot_description, robot_controllers], + parameters=[robot_controllers], output="both", + remappings=[ + ("~/robot_description", "/robot_description"), + ], ) robot_state_pub_node = Node( package="robot_state_publisher", 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..f70b415ce 100644 --- a/example_2/bringup/launch/diffbot.launch.py +++ b/example_2/bringup/launch/diffbot.launch.py @@ -73,8 +73,11 @@ def generate_launch_description(): control_node = Node( package="controller_manager", executable="ros2_control_node", - parameters=[robot_description, robot_controllers], + parameters=[robot_controllers], output="both", + remappings=[ + ("~/robot_description", "/robot_description"), + ], ) robot_state_pub_node = Node( package="robot_state_publisher", 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..c197fa5e9 100644 --- a/example_3/bringup/launch/rrbot_system_multi_interface.launch.py +++ b/example_3/bringup/launch/rrbot_system_multi_interface.launch.py @@ -119,8 +119,11 @@ def generate_launch_description(): control_node = Node( package="controller_manager", executable="ros2_control_node", - parameters=[robot_description, robot_controllers], + parameters=[robot_controllers], output="both", + remappings=[ + ("~/robot_description", "/robot_description"), + ], ) robot_state_pub_node = Node( package="robot_state_publisher", 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..86de28714 100644 --- a/example_4/bringup/launch/rrbot_system_with_sensor.launch.py +++ b/example_4/bringup/launch/rrbot_system_with_sensor.launch.py @@ -111,8 +111,11 @@ def generate_launch_description(): control_node = Node( package="controller_manager", executable="ros2_control_node", - parameters=[robot_description, robot_controllers], + parameters=[robot_controllers], output="both", + remappings=[ + ("~/robot_description", "/robot_description"), + ], ) robot_state_pub_node = Node( package="robot_state_publisher", 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..8fe324224 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,8 +111,11 @@ def generate_launch_description(): control_node = Node( package="controller_manager", executable="ros2_control_node", - parameters=[robot_description, robot_controllers], + parameters=[robot_controllers], output="both", + remappings=[ + ("~/robot_description", "/robot_description"), + ], ) robot_state_pub_node = Node( package="robot_state_publisher", diff --git a/example_6/bringup/launch/rrbot_modular_actuators.launch.py b/example_6/bringup/launch/rrbot_modular_actuators.launch.py index 24821fd70..5f15324f5 100644 --- a/example_6/bringup/launch/rrbot_modular_actuators.launch.py +++ b/example_6/bringup/launch/rrbot_modular_actuators.launch.py @@ -119,8 +119,11 @@ def generate_launch_description(): control_node = Node( package="controller_manager", executable="ros2_control_node", - parameters=[robot_description, robot_controllers], + parameters=[robot_controllers], output="both", + remappings=[ + ("~/robot_description", "/robot_description"), + ], ) robot_state_pub_node = Node( package="robot_state_publisher", diff --git a/example_7/bringup/launch/r6bot_controller.launch.py b/example_7/bringup/launch/r6bot_controller.launch.py index bc3e048ba..d0bf6f403 100644 --- a/example_7/bringup/launch/r6bot_controller.launch.py +++ b/example_7/bringup/launch/r6bot_controller.launch.py @@ -52,8 +52,9 @@ def generate_launch_description(): control_node = Node( package="controller_manager", executable="ros2_control_node", - parameters=[robot_description, robot_controllers], + parameters=[robot_controllers], remappings=[ + ("~/robot_description", "/robot_description"), ( "/forward_position_controller/commands", "/position_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..664531655 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,8 +96,11 @@ def generate_launch_description(): control_node = Node( package="controller_manager", executable="ros2_control_node", - parameters=[robot_description, robot_controllers], + parameters=[robot_controllers], output="both", + remappings=[ + ("~/robot_description", "/robot_description"), + ], ) robot_state_pub_node = Node( package="robot_state_publisher", diff --git a/example_9/bringup/launch/rrbot.launch.py b/example_9/bringup/launch/rrbot.launch.py index 2a61c1cee..f180c990e 100644 --- a/example_9/bringup/launch/rrbot.launch.py +++ b/example_9/bringup/launch/rrbot.launch.py @@ -68,8 +68,11 @@ def generate_launch_description(): control_node = Node( package="controller_manager", executable="ros2_control_node", - parameters=[robot_description, robot_controllers], + parameters=[robot_controllers], output="both", + remappings=[ + ("~/robot_description", "/robot_description"), + ], ) robot_state_pub_node = Node( package="robot_state_publisher",