Skip to content

Commit

Permalink
Update cart demos to use joint_trajectory_controller (#486) (#489)
Browse files Browse the repository at this point in the history
Co-authored-by: Alejandro Hernández Cordero <[email protected]>
(cherry picked from commit 11fc5dd)

Co-authored-by: Christoph Fröhlich <[email protected]>
  • Loading branch information
mergify[bot] and christophfroehlich authored Jan 30, 2025
1 parent 14dab80 commit 98bdcbb
Show file tree
Hide file tree
Showing 20 changed files with 64 additions and 141 deletions.
12 changes: 8 additions & 4 deletions gz_ros2_control_demos/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,20 @@ ament_target_dependencies(example_position
control_msgs
)

add_executable(example_velocity examples/example_velocity.cpp)
# use the same example_position.cpp for example_velocity
add_executable(example_velocity examples/example_position.cpp)
ament_target_dependencies(example_velocity
rclcpp
std_msgs
rclcpp_action
control_msgs
)

add_executable(example_effort examples/example_effort.cpp)
# use the same example_position.cpp for example_effort
add_executable(example_effort examples/example_position.cpp)
ament_target_dependencies(example_effort
rclcpp
std_msgs
rclcpp_action
control_msgs
)

add_executable(example_diff_drive examples/example_diff_drive.cpp)
Expand Down
16 changes: 14 additions & 2 deletions gz_ros2_control_demos/config/cart_controller_effort.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,20 @@ controller_manager:
joint_state_broadcaster:
type: joint_state_broadcaster/JointStateBroadcaster

effort_controller:
joint_trajectory_controller:
ros__parameters:
type: effort_controllers/JointGroupEffortController
type: joint_trajectory_controller/JointTrajectoryController
joints:
- slider_to_cart
command_interfaces:
- effort
state_interfaces:
- position
- velocity
gains:
slider_to_cart:
p: 100.0
i: 0.0
d: 10.0
i_clamp: 0.0
antiwindup: false
16 changes: 14 additions & 2 deletions gz_ros2_control_demos/config/cart_controller_velocity.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,23 @@ controller_manager:
joint_state_broadcaster:
type: joint_state_broadcaster/JointStateBroadcaster

velocity_controller:
joint_trajectory_controller:
ros__parameters:
type: velocity_controllers/JointGroupVelocityController
type: joint_trajectory_controller/JointTrajectoryController
joints:
- slider_to_cart
command_interfaces:
- velocity
state_interfaces:
- position
- velocity
gains:
slider_to_cart:
p: 100.0
i: 0.0
d: 0.0
i_clamp: 0.0
antiwindup: false

imu_sensor_broadcaster:
ros__parameters:
Expand Down
55 changes: 0 additions & 55 deletions gz_ros2_control_demos/examples/example_effort.cpp

This file was deleted.

54 changes: 0 additions & 54 deletions gz_ros2_control_demos/examples/example_velocity.cpp

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def robot_state_publisher(context):
[PathJoinSubstitution([FindPackageShare('ros_gz_sim'),
'launch',
'gz_sim.launch.py'])]),
launch_arguments=[('gz_args', [' -r -v 4 empty.sdf'])]),
launch_arguments=[('gz_args', [' -r -v 1 empty.sdf'])]),
RegisterEventHandler(
event_handler=OnProcessExit(
target_action=gz_spawn_entity,
Expand Down
8 changes: 4 additions & 4 deletions gz_ros2_control_demos/launch/cart_example_effort.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ def generate_launch_description():
executable='spawner',
arguments=['joint_state_broadcaster'],
)
effort_controller_spawner = Node(
joint_trajectory_controller_spawner = Node(
package='controller_manager',
executable='spawner',
arguments=[
'effort_controller',
'joint_trajectory_controller',
'--param-file',
robot_controllers,
],
Expand All @@ -93,7 +93,7 @@ def generate_launch_description():
[PathJoinSubstitution([FindPackageShare('ros_gz_sim'),
'launch',
'gz_sim.launch.py'])]),
launch_arguments=[('gz_args', [gz_args, ' -r -v 3 empty.sdf'])]),
launch_arguments=[('gz_args', [gz_args, ' -r -v 1 empty.sdf'])]),
RegisterEventHandler(
event_handler=OnProcessExit(
target_action=gz_spawn_entity,
Expand All @@ -103,7 +103,7 @@ def generate_launch_description():
RegisterEventHandler(
event_handler=OnProcessExit(
target_action=joint_state_broadcaster_spawner,
on_exit=[effort_controller_spawner],
on_exit=[joint_trajectory_controller_spawner],
)
),
bridge,
Expand Down
8 changes: 4 additions & 4 deletions gz_ros2_control_demos/launch/cart_example_velocity.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ def generate_launch_description():
executable='spawner',
arguments=['joint_state_broadcaster'],
)
velocity_controller_spawner = Node(
joint_trajectory_controller_spawner = Node(
package='controller_manager',
executable='spawner',
arguments=[
'velocity_controller',
'joint_trajectory_controller',
'--param-file',
robot_controllers,
],
Expand Down Expand Up @@ -102,7 +102,7 @@ def generate_launch_description():
[PathJoinSubstitution([FindPackageShare('ros_gz_sim'),
'launch',
'gz_sim.launch.py'])]),
launch_arguments=[('gz_args', [gz_args, ' -r -v 3 empty.sdf'])]),
launch_arguments=[('gz_args', [gz_args, ' -r -v 1 empty.sdf'])]),
RegisterEventHandler(
event_handler=OnProcessExit(
target_action=gz_spawn_entity,
Expand All @@ -112,7 +112,7 @@ def generate_launch_description():
RegisterEventHandler(
event_handler=OnProcessExit(
target_action=joint_state_broadcaster_spawner,
on_exit=[velocity_controller_spawner,
on_exit=[joint_trajectory_controller_spawner,
imu_sensor_broadcaster_spawner],
)
),
Expand Down
2 changes: 1 addition & 1 deletion gz_ros2_control_demos/launch/diff_drive_example.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def robot_state_publisher(context):
[PathJoinSubstitution([FindPackageShare('ros_gz_sim'),
'launch',
'gz_sim.launch.py'])]),
launch_arguments=[('gz_args', [' -r -v 4 empty.sdf'])]),
launch_arguments=[('gz_args', [' -r -v 1 empty.sdf'])]),
RegisterEventHandler(
event_handler=OnProcessExit(
target_action=gz_spawn_entity,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def generate_launch_description():
[PathJoinSubstitution([FindPackageShare('ros_gz_sim'),
'launch',
'gz_sim.launch.py'])]),
launch_arguments=[('gz_args', [' -r -v 4 empty.sdf'])]),
launch_arguments=[('gz_args', [' -r -v 1 empty.sdf'])]),
RegisterEventHandler(
event_handler=OnProcessExit(
target_action=gz_spawn_entity,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def generate_launch_description():
[PathJoinSubstitution([FindPackageShare('ros_gz_sim'),
'launch',
'gz_sim.launch.py'])]),
launch_arguments=[('gz_args', [' -r -v 4 empty.sdf'])]),
launch_arguments=[('gz_args', [' -r -v 1 empty.sdf'])]),
RegisterEventHandler(
event_handler=OnProcessExit(
target_action=gz_spawn_entity,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Author: Dr. Denis

<!-- Start Gazebo -->
<include file="$(find-pkg-share ros_gz_sim)/launch/gz_sim.launch.py" >
<arg name="gz_args" value=" -r -v 4 empty.sdf"/>
<arg name="gz_args" value=" -r -v 1 empty.sdf"/>
</include>

<node pkg="ros_gz_bridge" exec="parameter_bridge" args="
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def generate_launch_description():
[PathJoinSubstitution([FindPackageShare('ros_gz_sim'),
'launch',
'gz_sim.launch.py'])]),
launch_arguments=[('gz_args', [' -r -v 4 empty.sdf'])]),
launch_arguments=[('gz_args', [' -r -v 1 empty.sdf'])]),
RegisterEventHandler(
event_handler=OnProcessExit(
target_action=gz_spawn_entity,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Author: Dr. Denis

<!-- Start Gazebo -->
<include file="$(find-pkg-share ros_gz_sim)/launch/gz_sim.launch.py" >
<arg name="gz_args" value=" -r -v 4 empty.sdf"/>
<arg name="gz_args" value=" -r -v 1 empty.sdf"/>
</include>

<node pkg="ros_gz_bridge" exec="parameter_bridge" args="
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def generate_launch_description():
[PathJoinSubstitution([FindPackageShare('ros_gz_sim'),
'launch',
'gz_sim.launch.py'])]),
launch_arguments=[('gz_args', [' -r -v 4 empty.sdf'])]),
launch_arguments=[('gz_args', [' -r -v 1 empty.sdf'])]),
RegisterEventHandler(
event_handler=OnProcessExit(
target_action=gz_spawn_entity,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ def generate_launch_description():
executable='spawner',
arguments=['joint_state_broadcaster'],
)
effort_controller_spawner = Node(
joint_trajectory_controller_spawner = Node(
package='controller_manager',
executable='spawner',
arguments=[
'effort_controller',
'joint_trajectory_controller',
'--param-file',
robot_controllers,
],
Expand All @@ -92,7 +92,7 @@ def generate_launch_description():
[PathJoinSubstitution([FindPackageShare('ros_gz_sim'),
'launch',
'gz_sim.launch.py'])]),
launch_arguments=[('gz_args', [' -r -v 3 empty.sdf'])]),
launch_arguments=[('gz_args', [' -r -v 1 empty.sdf'])]),
RegisterEventHandler(
event_handler=OnProcessExit(
target_action=gz_spawn_entity,
Expand All @@ -102,7 +102,7 @@ def generate_launch_description():
RegisterEventHandler(
event_handler=OnProcessExit(
target_action=joint_state_broadcaster_spawner,
on_exit=[effort_controller_spawner],
on_exit=[joint_trajectory_controller_spawner],
)
),
bridge,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def generate_launch_description():
[PathJoinSubstitution([FindPackageShare('ros_gz_sim'),
'launch',
'gz_sim.launch.py'])]),
launch_arguments=[('gz_args', [' -r -v 4 empty.sdf'])]),
launch_arguments=[('gz_args', [' -r -v 1 empty.sdf'])]),
RegisterEventHandler(
event_handler=OnProcessExit(
target_action=gz_spawn_entity,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def generate_launch_description():
[PathJoinSubstitution([FindPackageShare('ros_gz_sim'),
'launch',
'gz_sim.launch.py'])]),
launch_arguments=[('gz_args', [' -r -v 4 empty.sdf'])]),
launch_arguments=[('gz_args', [' -r -v 1 empty.sdf'])]),
RegisterEventHandler(
event_handler=OnProcessExit(
target_action=gz_spawn_entity,
Expand Down
2 changes: 1 addition & 1 deletion gz_ros2_control_tests/tests/effort_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def test_clock(self):

def test_controller_running(self, proc_output):

cnames = ['effort_controller', 'joint_state_broadcaster']
cnames = ['joint_trajectory_controller', 'joint_state_broadcaster']

check_controllers_running(self.node, cnames)

Expand Down
6 changes: 5 additions & 1 deletion gz_ros2_control_tests/tests/velocity_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@ def test_clock(self):

def test_controller_running(self, proc_output):

cnames = ['velocity_controller', 'joint_state_broadcaster', 'imu_sensor_broadcaster']
cnames = [
'joint_trajectory_controller',
'joint_state_broadcaster',
'imu_sensor_broadcaster'
]

check_controllers_running(self.node, cnames)

Expand Down

0 comments on commit 98bdcbb

Please sign in to comment.