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

launch control file arg #196

Merged
merged 3 commits into from
Oct 1, 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
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# @author Roni Kreinin ([email protected])


import os
from ament_index_python.packages import get_package_share_directory

from launch import LaunchDescription
Expand All @@ -37,6 +38,11 @@
description='Robot name'),
DeclareLaunchArgument('namespace', default_value=LaunchConfiguration('robot_name'),
description='Robot namespace'),
DeclareLaunchArgument(
'control_config',
default_value=os.path.join(get_package_share_directory("irobot_create_control"), 'config', 'control.yaml'),
description='Path to the control YAML file.'
)
]


Expand All @@ -46,6 +52,7 @@ def generate_launch_description():
'urdf',
'turtlebot4.urdf.xacro'])
namespace = LaunchConfiguration('namespace')
control_config = LaunchConfiguration('control_config')

robot_state_publisher = Node(
package='robot_state_publisher',
Expand All @@ -57,7 +64,8 @@ def generate_launch_description():
{'robot_description': ParameterValue(Command([
'xacro', ' ', xacro_file, ' ',
'gazebo:=ignition', ' ',
'namespace:=', namespace]), value_type=str)},
'namespace:=', namespace, ' ',
'control_config:=', control_config]), value_type=str)},
],
remappings=[
('/tf', 'tf'),
Expand Down
7 changes: 5 additions & 2 deletions simulation/gazebo/tb4_sim_scenario/urdf/create3.urdf.xacro
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ SPDX-License-Identifier: Apache-2.0 -->
<!-- Namespace -->
<xacro:arg name="namespace" default=""/>

<!-- Controller config -->
<xacro:arg name="control_config" default="package://irobot_create_control/config/control.yaml" />

<!-- Mechanical properties -->
<xacro:property name="body_z_offset" value="${-2.5*cm2m}" />
<xacro:property name="body_collision_z_offset" value="${1*cm2m}" />
Expand Down Expand Up @@ -137,7 +140,7 @@ SPDX-License-Identifier: Apache-2.0 -->
<xacro:if value="${'$(arg gazebo)' == 'classic'}">
<gazebo>
<plugin name="gazebo_ros2_control" filename="libgazebo_ros2_control.so">
<parameters>$(find irobot_create_control)/config/control.yaml</parameters>
<parameters>$(arg control_config)</parameters>
<ros>
<remapping>~/odom:=odom</remapping>
<remapping>/tf:=tf</remapping>
Expand All @@ -152,7 +155,7 @@ SPDX-License-Identifier: Apache-2.0 -->
<xacro:if value="${'$(arg gazebo)' == 'ignition'}">
<gazebo>
<plugin filename="libign_ros2_control-system.so" name="ign_ros2_control::IgnitionROS2ControlPlugin">
<parameters>$(find irobot_create_control)/config/control.yaml</parameters>
<parameters>$(arg control_config)</parameters>
<ros>
<remapping>~/odom:=odom</remapping>
<remapping>/tf:=tf</remapping>
Expand Down