-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
acf4b1c
commit 02329c8
Showing
4 changed files
with
87 additions
and
37 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,63 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import os | ||
import xacro | ||
|
||
from ament_index_python.packages import get_package_share_directory | ||
from launch import LaunchDescription | ||
from launch.substitutions import LaunchConfiguration | ||
|
||
from launch_ros.actions import Node | ||
from launch.actions import DeclareLaunchArgument | ||
from launch.actions import DeclareLaunchArgument, GroupAction | ||
from launch.conditions import IfCondition, UnlessCondition | ||
|
||
def get_xacro_to_doc(xacro_file_path, mappings): | ||
doc = xacro.parse(open(xacro_file_path)) | ||
xacro.process_doc(doc, mappings=mappings) | ||
return doc | ||
doc = xacro.parse(open(xacro_file_path)) | ||
xacro.process_doc(doc, mappings=mappings) | ||
return doc | ||
|
||
def generate_launch_description(): | ||
|
||
use_sim_time = LaunchConfiguration('use_sim_time', default='false') | ||
|
||
xacro_path = os.path.join(get_package_share_directory('bcr_bot'), 'urdf', 'bcr_bot.xacro') | ||
doc = get_xacro_to_doc(xacro_path, {"wheel_odom_topic": "odom"}) | ||
|
||
robot_state_publisher = Node( | ||
package='robot_state_publisher', | ||
executable='robot_state_publisher', | ||
name='robot_state_publisher', | ||
output='screen', | ||
parameters=[{'use_sim_time': use_sim_time}, {'robot_description': doc.toxml()}] | ||
) | ||
|
||
rviz = Node( | ||
package='rviz2', | ||
executable='rviz2', | ||
name='rviz2', | ||
output='screen', | ||
arguments=['-d', os.path.join(get_package_share_directory('bcr_bot'), 'rviz', 'entire_setup.rviz')] | ||
) | ||
|
||
return LaunchDescription([ | ||
DeclareLaunchArgument('use_sim_time', default_value='false'), | ||
DeclareLaunchArgument('robot_description', default_value=doc.toxml()), | ||
robot_state_publisher, rviz | ||
# Launch configurations | ||
use_sim_time = LaunchConfiguration('use_sim_time', default='false') | ||
isaac_sim = LaunchConfiguration('isaac_sim') | ||
|
||
# Process XACRO | ||
xacro_path = os.path.join(get_package_share_directory('bcr_bot'), 'urdf', 'bcr_bot.xacro') | ||
doc = get_xacro_to_doc(xacro_path, {"wheel_odom_topic": "odom"}) | ||
|
||
# Nodes | ||
robot_state_publisher = Node( | ||
package='robot_state_publisher', | ||
executable='robot_state_publisher', | ||
name='robot_state_publisher', | ||
output='screen', | ||
parameters=[{'use_sim_time': use_sim_time}, {'robot_description': doc.toxml()}], | ||
condition=UnlessCondition(isaac_sim) # Only start if isaac_sim is false | ||
) | ||
|
||
rviz = Node( | ||
package='rviz2', | ||
executable='rviz2', | ||
name='rviz2', | ||
output='screen', | ||
arguments=['-d', os.path.join(get_package_share_directory('bcr_bot'), 'rviz', 'entire_setup.rviz')] | ||
) | ||
|
||
return LaunchDescription([ | ||
# Declare arguments | ||
DeclareLaunchArgument( | ||
'use_sim_time', | ||
default_value='false', | ||
description='Use simulation time if true' | ||
), | ||
DeclareLaunchArgument( | ||
'isaac_sim', | ||
default_value='false', | ||
description='Set to true when using Isaac Sim' | ||
), | ||
DeclareLaunchArgument( | ||
'robot_description', | ||
default_value=doc.toxml(), | ||
description='Robot description in URDF/XACRO format' | ||
), | ||
# Nodes | ||
robot_state_publisher, | ||
rviz | ||
]) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.