Created
September 10, 2021 22:16
-
-
Save joshnewans/d0e7992dba50923a7628110d740050ea to your computer and use it in GitHub Desktop.
Simple Robot State Publisher Launch File
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from ament_index_python.packages import get_package_share_directory | |
from launch import LaunchDescription | |
from launch_ros.actions import Node | |
import xacro | |
def generate_launch_description(): | |
# Specify the name of the package and path to xacro file within the package | |
pkg_name = 'my_package' | |
file_subpath = 'description/example_robot.urdf.xacro' | |
# Use xacro to process the file | |
xacro_file = os.path.join(get_package_share_directory(pkg_name),file_subpath) | |
robot_description_raw = xacro.process_file(xacro_file).toxml() | |
# Configure the node | |
node_robot_state_publisher = Node( | |
package='robot_state_publisher', | |
executable='robot_state_publisher', | |
output='screen', | |
parameters=[{'robot_description': robot_description_raw}] # add other parameters here if required | |
) | |
# Run the node | |
return LaunchDescription([ | |
node_robot_state_publisher | |
]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment