-
Notifications
You must be signed in to change notification settings - Fork 545
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New Launch Files using moveit_configs_utils (#1113)
* Add Package Path * Launch Utils * Some Basic Launch Files * Remove circular dependencies
- Loading branch information
Showing
4 changed files
with
196 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
from launch.actions import DeclareLaunchArgument | ||
from launch.conditions import IfCondition, UnlessCondition | ||
from launch.substitutions import LaunchConfiguration | ||
|
||
from launch_ros.actions import Node | ||
|
||
|
||
class DeclareBooleanLaunchArg(DeclareLaunchArgument): | ||
"""This launch action declares a launch argument with true and false as the only valid values""" | ||
|
||
def __init__(self, name, *, default_value=False, description=None, **kwargs): | ||
super().__init__( | ||
name, | ||
default_value=str(default_value), | ||
description=description, | ||
choices=["true", "false", "True", "False"], | ||
**kwargs, | ||
) | ||
|
||
|
||
def add_debuggable_node( | ||
ld, package, executable, condition_name="debug", commands_file=None, **kwargs | ||
): | ||
"""Adds two versions of a Node to the launch description, one with gdb debugging, controlled by a launch config""" | ||
standard_node = Node( | ||
package=package, | ||
executable=executable, | ||
condition=UnlessCondition(LaunchConfiguration(condition_name)), | ||
**kwargs, | ||
) | ||
ld.add_action(standard_node) | ||
|
||
if commands_file: | ||
dash_x_arg = f"-x {commands_file} " | ||
else: | ||
dash_x_arg = "" | ||
prefix = [f"gdb {dash_x_arg}--ex run --args"] | ||
|
||
debug_node = Node( | ||
package=package, | ||
executable=executable, | ||
condition=IfCondition(LaunchConfiguration(condition_name)), | ||
prefix=prefix, | ||
**kwargs, | ||
) | ||
ld.add_action(debug_node) |
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 |
---|---|---|
@@ -0,0 +1,134 @@ | ||
from launch import LaunchDescription | ||
from launch.actions import DeclareLaunchArgument | ||
from launch.conditions import IfCondition | ||
from launch.substitutions import LaunchConfiguration | ||
|
||
from launch_ros.actions import Node | ||
|
||
from moveit_configs_utils.launch_utils import ( | ||
add_debuggable_node, | ||
DeclareBooleanLaunchArg, | ||
) | ||
|
||
|
||
def generate_rsp_launch(moveit_config): | ||
"""Launch file for robot state publisher (rsp)""" | ||
|
||
ld = LaunchDescription() | ||
ld.add_action(DeclareLaunchArgument("publish_frequency", default_value="15.0")) | ||
|
||
# Given the published joint states, publish tf for the robot links and the robot description | ||
rsp_node = Node( | ||
package="robot_state_publisher", | ||
executable="robot_state_publisher", | ||
respawn=True, | ||
output="screen", | ||
parameters=[ | ||
moveit_config.robot_description, | ||
{ | ||
"publish_frequency": LaunchConfiguration("publish_frequency"), | ||
}, | ||
], | ||
) | ||
ld.add_action(rsp_node) | ||
|
||
return ld | ||
|
||
|
||
def generate_rviz_launch(moveit_config): | ||
"""Launch file for rviz""" | ||
ld = LaunchDescription() | ||
|
||
ld.add_action(DeclareBooleanLaunchArg("debug", default_value=False)) | ||
ld.add_action( | ||
DeclareLaunchArgument( | ||
"rviz_config", | ||
default_value=str(moveit_config.package_path / "launch/moveit.rviz"), | ||
) | ||
) | ||
|
||
rviz_parameters = [ | ||
moveit_config.planning_pipelines, | ||
moveit_config.robot_description_kinematics, | ||
] | ||
|
||
add_debuggable_node( | ||
ld, | ||
package="rviz2", | ||
executable="rviz2", | ||
output="log", | ||
respawn=True, | ||
arguments=["-d", LaunchConfiguration("rviz_config")], | ||
parameters=rviz_parameters, | ||
) | ||
|
||
return ld | ||
|
||
|
||
def generate_assistant_launch(moveit_config): | ||
"""Launch file for MoveIt Setup Assistant""" | ||
ld = LaunchDescription() | ||
|
||
ld.add_action(DeclareBooleanLaunchArg("debug", default_value=False)) | ||
add_debuggable_node( | ||
ld, | ||
package="moveit_setup_assistant", | ||
executable="moveit_setup_assistant", | ||
arguments=[["--config_pkg=", str(moveit_config.package_path)]], | ||
) | ||
|
||
return ld | ||
|
||
|
||
def generate_warehouse_launch(moveit_config): | ||
"""Launch file for warehouse database""" | ||
ld = LaunchDescription() | ||
ld.add_action( | ||
DeclareLaunchArgument( | ||
"moveit_warehouse_database_path", | ||
default_value=str( | ||
moveit_config.package_path / "default_warehouse_mongo_db" | ||
), | ||
) | ||
) | ||
ld.add_action(DeclareBooleanLaunchArg("reset", default_value=False)) | ||
|
||
# The default DB port for moveit (not default MongoDB port to avoid potential conflicts) | ||
ld.add_action(DeclareLaunchArgument("moveit_warehouse_port", default_value="33829")) | ||
|
||
# The default DB host for moveit | ||
ld.add_action( | ||
DeclareLaunchArgument("moveit_warehouse_host", default_value="localhost") | ||
) | ||
|
||
# Load warehouse parameters | ||
db_parameters = [ | ||
{ | ||
"overwrite": False, | ||
"database_path": LaunchConfiguration("moveit_warehouse_database_path"), | ||
"warehouse_port": LaunchConfiguration("moveit_warehouse_port"), | ||
"warehouse_host": LaunchConfiguration("moveit_warehouse_host"), | ||
"warehouse_exec": "mongod", | ||
"warehouse_plugin": "warehouse_ros_mongo::MongoDatabaseConnection", | ||
}, | ||
] | ||
# Run the DB server | ||
db_node = Node( | ||
package="warehouse_ros_mongo", | ||
executable="mongo_wrapper_ros.py", | ||
# TODO(dlu): Figure out if this needs to be run in a specific directory | ||
# (ROS 1 version set cwd="ROS_HOME") | ||
parameters=db_parameters, | ||
) | ||
ld.add_action(db_node) | ||
|
||
# If we want to reset the database, run this node | ||
reset_node = Node( | ||
package="moveit_ros_warehouse", | ||
executable="moveit_init_demo_warehouse", | ||
output="screen", | ||
condition=IfCondition(LaunchConfiguration("reset")), | ||
) | ||
ld.add_action(reset_node) | ||
|
||
return ld |
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