Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Example 13] Give the controller type as parameter in ctrl namespace #561

Merged
merged 3 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions example_13/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ endif()
set(THIS_PACKAGE_INCLUDE_DEPENDS
)

# Specify the required version of ros2_control
find_package(controller_manager 4.0.0)
# Handle the case where the required version is not found
if(NOT controller_manager_FOUND)
message(FATAL_ERROR "ros2_control version 4.0.0 or higher is required. "
"Are you using the correct branch of the ros2_control_demos repository?")
endif()

# find dependencies
find_package(ament_cmake REQUIRED)
foreach(Dependency IN ITEMS ${THIS_PACKAGE_INCLUDE_DEPENDS})
Expand Down
39 changes: 9 additions & 30 deletions example_13/bringup/config/three_robots_controllers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,36 +15,6 @@ controller_manager:
joint_state_broadcaster:
type: joint_state_broadcaster/JointStateBroadcaster

# RRBot controllers
rrbot_joint_state_broadcaster:
type: joint_state_broadcaster/JointStateBroadcaster

rrbot_position_controller:
type: forward_command_controller/ForwardCommandController

rrbot_external_fts_broadcaster:
type: force_torque_sensor_broadcaster/ForceTorqueSensorBroadcaster

# RRBot with sensor controllers
rrbot_with_sensor_joint_state_broadcaster:
type: joint_state_broadcaster/JointStateBroadcaster

rrbot_with_sensor_position_controller:
type: forward_command_controller/ForwardCommandController

rrbot_with_sensor_fts_broadcaster:
type: force_torque_sensor_broadcaster/ForceTorqueSensorBroadcaster

# ThreeDofBot controllers
threedofbot_joint_state_broadcaster:
type: joint_state_broadcaster/JointStateBroadcaster

threedofbot_position_controller:
type: forward_command_controller/ForwardCommandController

threedofbot_pid_gain_controller:
type: forward_command_controller/ForwardCommandController

# global joint_state_broadcaster
# joint_state_broadcaster:
# ros__parameters:
Expand All @@ -53,6 +23,7 @@ controller_manager:
# RRBot controllers
rrbot_joint_state_broadcaster:
ros__parameters:
type: joint_state_broadcaster/JointStateBroadcaster
use_local_topics: True
joints:
- rrbot_joint1
Expand All @@ -62,20 +33,23 @@ rrbot_joint_state_broadcaster:

rrbot_position_controller:
ros__parameters:
type: forward_command_controller/ForwardCommandController
joints:
- rrbot_joint1
- rrbot_joint2
interface_name: position

rrbot_external_fts_broadcaster:
ros__parameters:
type: force_torque_sensor_broadcaster/ForceTorqueSensorBroadcaster
sensor_name: rrbot_tcp_fts_sensor
frame_id: rrbot_tool_link


# RRBot with sensor controllers
rrbot_with_sensor_joint_state_broadcaster:
ros__parameters:
type: joint_state_broadcaster/JointStateBroadcaster
use_local_topics: True
joints:
- rrbot_with_sensor_joint1
Expand All @@ -85,20 +59,23 @@ rrbot_with_sensor_joint_state_broadcaster:

rrbot_with_sensor_position_controller:
ros__parameters:
type: forward_command_controller/ForwardCommandController
joints:
- rrbot_with_sensor_joint1
- rrbot_with_sensor_joint2
interface_name: position

rrbot_with_sensor_fts_broadcaster:
ros__parameters:
type: force_torque_sensor_broadcaster/ForceTorqueSensorBroadcaster
interface_names.force.x: rrbot_with_sensor_tcp_fts_sensor/force.x
interface_names.torque.z: rrbot_with_sensor_tcp_fts_sensor/torque.z
frame_id: rrbot_with_sensor_tool_link

# ThreeDofBot controllers
threedofbot_joint_state_broadcaster:
ros__parameters:
type: joint_state_broadcaster/JointStateBroadcaster
use_local_topics: True
joints:
- threedofbot_joint1
Expand All @@ -110,6 +87,7 @@ threedofbot_joint_state_broadcaster:

threedofbot_position_controller:
ros__parameters:
type: forward_command_controller/ForwardCommandController
joints:
- threedofbot_joint1
- threedofbot_joint2
Expand All @@ -118,6 +96,7 @@ threedofbot_position_controller:

threedofbot_pid_gain_controller:
ros__parameters:
type: forward_command_controller/ForwardCommandController
joints:
- threedofbot_joint1
- threedofbot_joint2
Expand Down
30 changes: 21 additions & 9 deletions example_13/bringup/launch/three_robots.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,38 +117,40 @@ def generate_launch_description():
rrbot_joint_state_broadcaster_spawner = Node(
package="controller_manager",
executable="spawner",
arguments=["rrbot_joint_state_broadcaster"],
arguments=["rrbot_joint_state_broadcaster", "--param-file", robot_controllers],
)
rrbot_position_controller_spawner = Node(
package="controller_manager",
executable="spawner",
arguments=["rrbot_position_controller"],
arguments=["rrbot_position_controller", "--param-file", robot_controllers],
)
# External FTS broadcaster
rrbot_external_fts_broadcaster_spawner = Node(
package="controller_manager",
executable="spawner",
arguments=["rrbot_external_fts_broadcaster"],
arguments=["rrbot_external_fts_broadcaster", "--param-file", robot_controllers],
)

# RRBot controllers
rrbot_with_sensor_joint_state_broadcaster_spawner = Node(
package="controller_manager",
executable="spawner",
arguments=["rrbot_with_sensor_joint_state_broadcaster"],
arguments=["rrbot_with_sensor_joint_state_broadcaster", "--param-file", robot_controllers],
)
rrbot_with_sensor_position_controller_spawner = Node(
package="controller_manager",
executable="spawner",
arguments=[
"rrbot_with_sensor_position_controller",
"--inactive",
"--param-file",
robot_controllers,
],
)
rrbot_with_sensor_fts_broadcaster_spawner = Node(
package="controller_manager",
executable="spawner",
arguments=["rrbot_with_sensor_fts_broadcaster"],
arguments=["rrbot_with_sensor_fts_broadcaster", "--param-file", robot_controllers],
)

# ThreeDofBot controllers
Expand All @@ -157,20 +159,30 @@ def generate_launch_description():
executable="spawner",
arguments=[
"threedofbot_joint_state_broadcaster",
"-c",
"/controller_manager",
"--inactive",
"--param-file",
robot_controllers,
],
)
threedofbot_position_controller_spawner = Node(
package="controller_manager",
executable="spawner",
arguments=["threedofbot_position_controller", "--inactive"],
arguments=[
"threedofbot_position_controller",
"--inactive",
"--param-file",
robot_controllers,
],
)
threedofbot_pid_gain_controller_spawner = Node(
package="controller_manager",
executable="spawner",
arguments=["threedofbot_pid_gain_controller", "--inactive"],
arguments=[
"threedofbot_pid_gain_controller",
"--inactive",
"--param-file",
robot_controllers,
],
)

# Command publishers
Expand Down
3 changes: 3 additions & 0 deletions example_13/test/test_three_robots_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ def tearDown(self):

def test_node_start(self, proc_output):
check_node_running(self.node, "robot_state_publisher")
check_node_running(self.node, "rrbot_position_command_publisher")
check_node_running(self.node, "rrbot_with_sensor_position_command_publisher")
check_node_running(self.node, "threedofbot_position_command_publisher")

def test_behavior(self, proc_output):

Expand Down
Loading