Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikhil-Singhal-06 committed Sep 30, 2024
1 parent 59e99e1 commit 154d55d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from ament_index_python.packages import get_package_share_directory

from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument, OpaqueFunction
from launch.actions import DeclareLaunchArgument
from launch.substitutions import Command, PathJoinSubstitution
from launch.substitutions.launch_configuration import LaunchConfiguration

Expand All @@ -40,31 +40,20 @@
description='Robot namespace'),
DeclareLaunchArgument(
'control_config',
default_value='irobot_create_control/config/control.yaml',
description='Path to the control YAML file <package_name>/path/to/control.yaml)'
default_value=os.path.join(get_package_share_directory("irobot_create_control"), 'config', 'control.yaml'),
description='Path to the control YAML file.'
)
]


def resolve_control_config_path(context):
control_config_str = LaunchConfiguration('control_config').perform(context)
try:
package_name, relative_path = control_config_str.split('/', 1)
package_share_path = get_package_share_directory(package_name)
resolved_path = os.path.join(package_share_path, relative_path)
return resolved_path
except ValueError:
raise RuntimeError(f"Invalid control_config file path format: '{control_config_str}'. "
f"Expected '<package_name>/path/to/control.yaml)'.") from ValueError


def create_robot_state_publisher_node(context):
control_config = resolve_control_config_path(context)
def generate_launch_description():
pkg_tb4_sim_scenario = get_package_share_directory('tb4_sim_scenario')
xacro_file = PathJoinSubstitution([pkg_tb4_sim_scenario,
'urdf',
'turtlebot4.urdf.xacro'])
namespace = LaunchConfiguration('namespace')
control_config = LaunchConfiguration('control_config')

robot_state_publisher = Node(
package='robot_state_publisher',
executable='robot_state_publisher',
Expand All @@ -83,12 +72,6 @@ def create_robot_state_publisher_node(context):
('/tf_static', 'tf_static')
]
)
return [robot_state_publisher]


def generate_launch_description():

robot_state_publisher = OpaqueFunction(function=create_robot_state_publisher_node)

joint_state_publisher = Node(
package='joint_state_publisher',
Expand Down
2 changes: 1 addition & 1 deletion simulation/gazebo/tb4_sim_scenario/urdf/create3.urdf.xacro
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ SPDX-License-Identifier: Apache-2.0 -->
<xacro:arg name="namespace" default=""/>

<!-- Controller config -->
<xacro:arg name="control_config" default="package://irobot_create_control/config/control.yaml" />
<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}" />
Expand Down

0 comments on commit 154d55d

Please sign in to comment.