-
Notifications
You must be signed in to change notification settings - Fork 99
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
Add remap option to controller manager #442
Add remap option to controller manager #442
Conversation
Any updates on this PR? |
@Amronos can you please test it and leave a review here? I don't have a working example of setting this up, maybe someone can provide one for gz_ros2_control_demos if this makes sense? |
@Mergifyio backport rolling |
✅ Backports have been created
|
This PR makes @christophfroehlich I will try making a PR in a few days to modify the demos to use composable nodes, till then the below launch file can be used for testing: from launch import LaunchDescription
from launch.actions import (
DeclareLaunchArgument,
ExecuteProcess,
OpaqueFunction,
RegisterEventHandler,
)
from launch.event_handlers import OnProcessExit
from launch.substitutions import (
Command,
FindExecutable,
LaunchConfiguration,
PathJoinSubstitution,
)
from launch_ros.actions import Node
from launch_ros.substitutions import FindPackageShare
from ros_gz_sim.actions import GzServer
def generate_launch_description():
# Launch Arguments
use_sim_time = LaunchConfiguration("use_sim_time", default=True)
def robot_state_publisher(context):
performed_description_format = LaunchConfiguration(
"description_format"
).perform(context)
# Get URDF or SDF via xacro
robot_description_content = Command(
[
PathJoinSubstitution([FindExecutable(name="xacro")]),
" ",
PathJoinSubstitution(
[
FindPackageShare("gz_ros2_control_demos"),
performed_description_format,
f"test_diff_drive.xacro.{performed_description_format}",
]
),
]
)
robot_description = {"robot_description": robot_description_content}
node_robot_state_publisher = Node(
package="robot_state_publisher",
executable="robot_state_publisher",
output="screen",
parameters=[robot_description],
)
return [node_robot_state_publisher]
robot_controllers = PathJoinSubstitution(
[
FindPackageShare("gz_ros2_control_demos"),
"config",
"diff_drive_controller.yaml",
]
)
gz_spawn_entity = Node(
package="ros_gz_sim",
executable="create",
output="screen",
arguments=[
"-topic",
"robot_description",
"-name",
"diff_drive",
"-allow_renaming",
"true",
],
)
joint_state_broadcaster_spawner = Node(
package="controller_manager",
executable="spawner",
arguments=["joint_state_broadcaster"],
)
diff_drive_base_controller_spawner = Node(
package="controller_manager",
executable="spawner",
arguments=[
"diff_drive_base_controller",
"--param-file",
robot_controllers,
],
)
# Bridge
bridge = Node(
package="ros_gz_bridge",
executable="parameter_bridge",
arguments=["/clock@rosgraph_msgs/msg/Clock[gz.msgs.Clock"],
output="screen",
)
ld = LaunchDescription(
[
# Launch gazebo environment
GzServer(
world_sdf_file="empty.sdf",
use_composition="True",
create_own_container="True",
container_name="ros_gz_container",
),
ExecuteProcess(cmd=["gz", "sim", "-g"]),
RegisterEventHandler(
event_handler=OnProcessExit(
target_action=gz_spawn_entity,
on_exit=[joint_state_broadcaster_spawner],
)
),
RegisterEventHandler(
event_handler=OnProcessExit(
target_action=joint_state_broadcaster_spawner,
on_exit=[diff_drive_base_controller_spawner],
)
),
bridge,
gz_spawn_entity,
# Launch Arguments
DeclareLaunchArgument(
"use_sim_time",
default_value=use_sim_time,
description="If true, use simulated clock",
),
DeclareLaunchArgument(
"description_format",
default_value="urdf",
description="Robot description format to use, urdf or sdf",
),
]
)
ld.add_action(OpaqueFunction(function=robot_state_publisher))
return ld |
Thank you for testing. |
do we need to forward port this to |
Co-authored-by: Christoph Fröhlich <[email protected]> (cherry picked from commit 0a44a08)
Co-authored-by: Christoph Fröhlich <[email protected]> (cherry picked from commit 0a44a08) Co-authored-by: Tatsuro Sakaguchi <[email protected]>
I made it possible to correctly set the node name of the
controller_manager
when launchinggz_ros2_control
as a composable node.