Skip to content

Commit

Permalink
Update all demos using the description from topic rather than the par…
Browse files Browse the repository at this point in the history
…ameter (#456) (#472)

* 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 <saisastra3@gmail.com>
Co-authored-by: Felix Exner (fexner) <felix_mauch@web.de>
  • Loading branch information
3 people authored Mar 13, 2024
1 parent bb1e6ef commit 11d699b
Show file tree
Hide file tree
Showing 14 changed files with 61 additions and 28 deletions.
5 changes: 4 additions & 1 deletion example_1/bringup/launch/rrbot.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 4 additions & 1 deletion example_10/bringup/launch/rrbot.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 0 additions & 3 deletions example_11/bringup/launch/carlikebot.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 4 additions & 1 deletion example_12/bringup/launch/rrbot.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
28 changes: 15 additions & 13 deletions example_14/hardware/rrbot_actuator_without_feedback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
5 changes: 4 additions & 1 deletion example_2/bringup/launch/diffbot.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 4 additions & 1 deletion example_4/bringup/launch/rrbot_system_with_sensor.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 4 additions & 1 deletion example_6/bringup/launch/rrbot_modular_actuators.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion example_7/bringup/launch/r6bot_controller.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 4 additions & 1 deletion example_9/bringup/launch/rrbot.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 11d699b

Please sign in to comment.