I am having a problem trying to use Moveit2 in simulation, I created the Moveit config package for my robot arm using the setup assistant, but the generated move_group.launcy.py file looks like this:

from moveit_configs_utils import MoveItConfigsBuilder
from moveit_configs_utils.launches import generate_move_group_launch

def generate_launch_description():
    moveit_config = MoveItConfigsBuilder("ur", package_name="flower_catcher_moveit_config").to_moveit_configs()
    return generate_move_group_launch(moveit_config)

The problem with this format is that there is no way for me to set the use_sim_time parameter to true, and that causes the path execution to fail with this error:

[move_group-7] [INFO] [1696192877.744131744] [moveit_ros.current_state_monitor]: Didn't receive robot state (joint angles) with recent timestamp within 1.000000 seconds. Requested time 1696192876.744054, but latest received state has time 148.003000.

I kind of solved the problem by setting the parameter afterward with the command

ros2 param set /move_group use_sim_time true

However, I want to know if there is a way to set this parameter in the launch file.



1 Answer 1


Unfortunately, there is no clean way to pass it through launch file, while using moveit_configs_utils.launches. This was raised previously in an issue and use_sim_time technically supposed to be added here in the source code. That said, here is an engineered solution around this:

from moveit_configs_utils import MoveItConfigsBuilder
from moveit_configs_utils.launches import *
def generate_move_group_launch(moveit_config):
    ld = LaunchDescription()
    ld.add_action(DeclareBooleanLaunchArg("debug", default_value=False))
        DeclareBooleanLaunchArg("allow_trajectory_execution", default_value=True)
        DeclareBooleanLaunchArg("publish_monitored_planning_scene", default_value=True)
    # load non-default MoveGroup capabilities (space separated)
    ld.add_action(DeclareLaunchArgument("capabilities", default_value=""))
    # inhibit these default MoveGroup capabilities (space separated)
    ld.add_action(DeclareLaunchArgument("disable_capabilities", default_value=""))
    # do not copy dynamics information from /joint_states to internal robot monitoring
    # default to false, because almost nothing in move_group relies on this information
    ld.add_action(DeclareBooleanLaunchArg("monitor_dynamics", default_value=False))
    should_publish = LaunchConfiguration("publish_monitored_planning_scene")
    move_group_configuration = {
        "publish_robot_description_semantic": True,
        "allow_trajectory_execution": LaunchConfiguration("allow_trajectory_execution"),
        # Note: Wrapping the following values is necessary so that the parameter value can be the empty string
        "capabilities": ParameterValue(
            LaunchConfiguration("capabilities"), value_type=str
        "disable_capabilities": ParameterValue(
            LaunchConfiguration("disable_capabilities"), value_type=str
        # Publish the planning scene of the physical robot so that rviz plugin can know actual robot
        "publish_planning_scene": should_publish,
        "publish_geometry_updates": should_publish,
        "publish_state_updates": should_publish,
        "publish_transforms_updates": should_publish,
        "monitor_dynamics": False,
        "use_sim_time": True
    move_group_params = [
        commands_file=str(moveit_config.package_path / "launch" / "gdb_settings.gdb"),
        # Set the display variable, in case OpenGL code is used internally
        additional_env={"DISPLAY": ":0"},
    return ld
def generate_launch_description():
    moveit_config = MoveItConfigsBuilder("ur", package_name="ur_moveit").to_moveit_configs()
    return generate_move_group_launch(moveit_config)

You can observe how use_sim_time: True has been passed with the move_group_configuration dictionary.

  • $\begingroup$ Thank you so much, this worked!!! $\endgroup$ Oct 8 at 23:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.