Skip to content

Commit

Permalink
Use spawner instead of cli verbs
Browse files Browse the repository at this point in the history
  • Loading branch information
christophfroehlich committed Aug 23, 2024
1 parent cbdd3a3 commit 30bad12
Show file tree
Hide file tree
Showing 20 changed files with 282 additions and 180 deletions.
5 changes: 1 addition & 4 deletions gz_ros2_control_demos/config/ackermann_drive_controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@ controller_manager:
joint_state_broadcaster:
type: joint_state_broadcaster/JointStateBroadcaster


ackermann_steering_controller:
type: 'ackermann_steering_controller/AckermannSteeringController'

ackermann_steering_controller:
ros__parameters:
type: 'ackermann_steering_controller/AckermannSteeringController'
wheelbase: 1.7
front_wheel_track: 1.0
rear_wheel_track: 1.0
Expand Down
4 changes: 1 addition & 3 deletions gz_ros2_control_demos/config/cart_controller_effort.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ controller_manager:
ros__parameters:
update_rate: 1000 # Hz

effort_controller:
type: effort_controllers/JointGroupEffortController

joint_state_broadcaster:
type: joint_state_broadcaster/JointStateBroadcaster

effort_controller:
ros__parameters:
type: effort_controllers/JointGroupEffortController
joints:
- slider_to_cart
4 changes: 1 addition & 3 deletions gz_ros2_control_demos/config/cart_controller_position.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@ controller_manager:
ros__parameters:
update_rate: 1000 # Hz

joint_trajectory_controller:
type: joint_trajectory_controller/JointTrajectoryController

joint_state_broadcaster:
type: joint_state_broadcaster/JointStateBroadcaster

joint_trajectory_controller:
ros__parameters:
type: joint_trajectory_controller/JointTrajectoryController
joints:
- slider_to_cart
command_interfaces:
Expand Down
7 changes: 1 addition & 6 deletions gz_ros2_control_demos/config/cart_controller_velocity.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,16 @@ controller_manager:
ros__parameters:
update_rate: 1000 # Hz

velocity_controller:
type: velocity_controllers/JointGroupVelocityController

joint_state_broadcaster:
type: joint_state_broadcaster/JointStateBroadcaster

imu_sensor_broadcaster:
type: imu_sensor_broadcaster/IMUSensorBroadcaster

velocity_controller:
ros__parameters:
joints:
- slider_to_cart

imu_sensor_broadcaster:
ros__parameters:
type: imu_sensor_broadcaster/IMUSensorBroadcaster
sensor_name: cart_imu_sensor
frame_id: imu
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ controller_manager:
joint_state_broadcaster:
type: joint_state_broadcaster/JointStateBroadcaster

diff_drive_base_controller:
type: diff_drive_controller/DiffDriveController

diff_drive_base_controller:
ros__parameters:
type: diff_drive_controller/DiffDriveController
left_wheel_names: ["left_wheel_joint"]
right_wheel_names: ["right_wheel_joint"]

Expand Down
4 changes: 1 addition & 3 deletions gz_ros2_control_demos/config/gripper_controller_effort.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@ controller_manager:
ros__parameters:
update_rate: 100 # Hz

gripper_controller:
type: forward_command_controller/ForwardCommandController

joint_state_broadcaster:
type: joint_state_broadcaster/JointStateBroadcaster

gripper_controller:
ros__parameters:
type: forward_command_controller/ForwardCommandController
joints:
- right_finger_joint
interface_name: effort
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@ controller_manager:
ros__parameters:
update_rate: 100 # Hz

gripper_controller:
type: forward_command_controller/ForwardCommandController

joint_state_broadcaster:
type: joint_state_broadcaster/JointStateBroadcaster

gripper_controller:
ros__parameters:
type: forward_command_controller/ForwardCommandController
joints:
- right_finger_joint
interface_name: position
9 changes: 3 additions & 6 deletions gz_ros2_control_demos/config/tricycle_drive_controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,15 @@ controller_manager:
ros__parameters:
update_rate: 50 # Hz

tricycle_controller:
type: tricycle_controller/TricycleController

joint_state_broadcaster:
type: joint_state_broadcaster/JointStateBroadcaster

joint_state_broadcaster:
ros__parameters:
type: joint_state_broadcaster/JointStateBroadcaster
extra_joints: ["right_wheel_joint", "left_wheel_joint"]

tricycle_controller:
ros__parameters:
type: tricycle_controller/TricycleController

# Model
traction_joint_name: traction_joint # Name of traction joint in URDF
steering_joint_name: steering_joint # Name of steering joint in URDF
Expand Down
35 changes: 22 additions & 13 deletions gz_ros2_control_demos/launch/ackermann_drive_example.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument, ExecuteProcess, IncludeLaunchDescription
from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription
from launch.actions import RegisterEventHandler
from launch.event_handlers import OnProcessExit
from launch.launch_description_sources import PythonLaunchDescriptionSource
Expand All @@ -39,6 +39,13 @@ def generate_launch_description():
]
)
robot_description = {'robot_description': robot_description_content}
robot_controllers = PathJoinSubstitution(
[
FindPackageShare('gz_ros2_control_demos'),
'config',
'ackermann_drive_controller.yaml',
]
)

node_robot_state_publisher = Node(
package='robot_state_publisher',
Expand All @@ -55,16 +62,18 @@ def generate_launch_description():
'ackermann', '-allow_renaming', 'true'],
)

load_joint_state_broadcaster = ExecuteProcess(
cmd=['ros2', 'control', 'load_controller', '--set-state', 'active',
'joint_state_broadcaster'],
output='screen'
joint_state_broadcaster_spawner = Node(
package='controller_manager',
executable='spawner',
arguments=['joint_state_broadcaster'],
)

load_ackermann_controller = ExecuteProcess(
cmd=['ros2', 'control', 'load_controller', '--set-state', 'active',
'ackermann_steering_controller'],
output='screen'
ackermann_steering_controller_spawner = Node(
package='controller_manager',
executable='spawner',
arguments=['ackermann_steering_controller',
'--param-file',
robot_controllers,
],
)

# Bridge
Expand All @@ -87,13 +96,13 @@ def generate_launch_description():
RegisterEventHandler(
event_handler=OnProcessExit(
target_action=gz_spawn_entity,
on_exit=[load_joint_state_broadcaster],
on_exit=[joint_state_broadcaster_spawner],
)
),
RegisterEventHandler(
event_handler=OnProcessExit(
target_action=load_joint_state_broadcaster,
on_exit=[load_ackermann_controller],
target_action=joint_state_broadcaster_spawner,
on_exit=[ackermann_steering_controller_spawner],
)
),
node_robot_state_publisher,
Expand Down
36 changes: 23 additions & 13 deletions gz_ros2_control_demos/launch/cart_example_effort.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument, ExecuteProcess, IncludeLaunchDescription
from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription
from launch.actions import RegisterEventHandler
from launch.event_handlers import OnProcessExit
from launch.launch_description_sources import PythonLaunchDescriptionSource
Expand All @@ -39,6 +39,13 @@ def generate_launch_description():
]
)
robot_description = {'robot_description': robot_description_content}
robot_controllers = PathJoinSubstitution(
[
FindPackageShare('gz_ros2_control_demos'),
'config',
'cart_controller_effort.yaml',
]
)

node_robot_state_publisher = Node(
package='robot_state_publisher',
Expand All @@ -55,16 +62,19 @@ def generate_launch_description():
'-name', 'cart', '-allow_renaming', 'true'],
)

load_joint_state_broadcaster = ExecuteProcess(
cmd=['ros2', 'control', 'load_controller', '--set-state', 'active',
'joint_state_broadcaster'],
output='screen'
joint_state_broadcaster_spawner = Node(
package='controller_manager',
executable='spawner',
arguments=['joint_state_broadcaster'],
)

load_joint_effort_controller = ExecuteProcess(
cmd=['ros2', 'control', 'load_controller',
'--set-state', 'active', 'effort_controller'],
output='screen'
effort_controller_spawner = Node(
package='controller_manager',
executable='spawner',
arguments=[
'effort_controller',
'--param-file',
robot_controllers,
],
)

return LaunchDescription([
Expand All @@ -78,13 +88,13 @@ def generate_launch_description():
RegisterEventHandler(
event_handler=OnProcessExit(
target_action=gz_spawn_entity,
on_exit=[load_joint_state_broadcaster],
on_exit=[joint_state_broadcaster_spawner],
)
),
RegisterEventHandler(
event_handler=OnProcessExit(
target_action=load_joint_state_broadcaster,
on_exit=[load_joint_effort_controller],
target_action=joint_state_broadcaster_spawner,
on_exit=[effort_controller_spawner],
)
),
node_robot_state_publisher,
Expand Down
36 changes: 23 additions & 13 deletions gz_ros2_control_demos/launch/cart_example_position.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument, ExecuteProcess, IncludeLaunchDescription
from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription
from launch.actions import RegisterEventHandler
from launch.event_handlers import OnProcessExit
from launch.launch_description_sources import PythonLaunchDescriptionSource
Expand All @@ -39,6 +39,13 @@ def generate_launch_description():
]
)
robot_description = {'robot_description': robot_description_content}
robot_controllers = PathJoinSubstitution(
[
FindPackageShare('gz_ros2_control_demos'),
'config',
'cart_controller_position.yaml',
]
)

node_robot_state_publisher = Node(
package='robot_state_publisher',
Expand All @@ -55,16 +62,19 @@ def generate_launch_description():
'-name', 'cart', '-allow_renaming', 'true'],
)

load_joint_state_broadcaster = ExecuteProcess(
cmd=['ros2', 'control', 'load_controller', '--set-state', 'active',
'joint_state_broadcaster'],
output='screen'
joint_state_broadcaster_spawner = Node(
package='controller_manager',
executable='spawner',
arguments=['joint_state_broadcaster'],
)

load_joint_trajectory_controller = ExecuteProcess(
cmd=['ros2', 'control', 'load_controller', '--set-state', 'active',
'joint_trajectory_controller'],
output='screen'
joint_trajectory_controller_spawner = Node(
package='controller_manager',
executable='spawner',
arguments=[
'joint_trajectory_controller',
'--param-file',
robot_controllers,
],
)

return LaunchDescription([
Expand All @@ -78,13 +88,13 @@ def generate_launch_description():
RegisterEventHandler(
event_handler=OnProcessExit(
target_action=gz_spawn_entity,
on_exit=[load_joint_state_broadcaster],
on_exit=[joint_state_broadcaster_spawner],
)
),
RegisterEventHandler(
event_handler=OnProcessExit(
target_action=load_joint_state_broadcaster,
on_exit=[load_joint_trajectory_controller],
target_action=joint_state_broadcaster_spawner,
on_exit=[joint_trajectory_controller_spawner],
)
),
node_robot_state_publisher,
Expand Down
Loading

0 comments on commit 30bad12

Please sign in to comment.