赞
踩
报错大概是这样的,当时我没截取屏幕,用了一下别人的报错,原主在这里:https://blog.csdn.net/m0_59796104/article/details/138900371#comments_33466284
实际上打开demo.launch.py文件会发现里面什么都没有
类似下面的情况:
- from moveit_configs_utils import MoveItConfigsBuilder
- from moveit_configs_utils.launches import generate_move_group_launch
-
-
- def generate_launch_description():
- moveit_config = MoveItConfigsBuilder("xxx", package_name="xxx_config").to_moveit_configs()
- return generate_move_group_launch(moveit_config)
把demo.launch.py里面东西替换成下面的内容:
- import os
- from launch import LaunchDescription
- from launch.actions import DeclareLaunchArgument
- from launch.substitutions import LaunchConfiguration
- from launch.conditions import IfCondition, UnlessCondition
- from launch_ros.actions import Node
- from launch.actions import ExecuteProcess
- from ament_index_python.packages import get_package_share_directory
- from moveit_configs_utils import MoveItConfigsBuilder
-
-
- def generate_launch_description():
-
- # Command-line arguments
- db_arg = DeclareLaunchArgument(
- "db", default_value="False", description="Database flag"
- )
-
- moveit_config = (
- MoveItConfigsBuilder("xxx")
- .robot_description(file_path="config/xxx.urdf.xacro")
- .robot_description_semantic(file_path="config/xxx.srdf")
- .trajectory_execution(file_path="config/moveit_controllers.yaml")
- .to_moveit_configs()
- )
-
- # Start the actual move_group node/action server
- run_move_group_node = Node(
- package="moveit_ros_move_group",
- executable="move_group",
- output="screen",
- parameters=[moveit_config.to_dict()],
- )
-
- # RViz
- rviz_base = os.path.join(
- get_package_share_directory("xxx_moveit_config"), "config"
- )
- rviz_full_config = os.path.join(rviz_base, "moveit.rviz")
-
- rviz_node = Node(
- package="rviz2",
- executable="rviz2",
- name="rviz2",
- output="log",
- arguments=["-d", rviz_full_config],
- parameters=[
- moveit_config.robot_description,
- moveit_config.robot_description_semantic,
- moveit_config.planning_pipelines,
- moveit_config.robot_description_kinematics,
- ],
- )
-
- # Static TF
- static_tf = Node(
- package="tf2_ros",
- executable="static_transform_publisher",
- name="static_transform_publisher",
- output="log",
- arguments=["0.0", "0.0", "0.0", "0.0", "0.0", "0.0", "world", "base_link"],
- )
-
- # Publish TF
- robot_state_publisher = Node(
- package="robot_state_publisher",
- executable="robot_state_publisher",
- name="robot_state_publisher",
- output="both",
- parameters=[moveit_config.robot_description],
- )
-
- # ros2_control using FakeSystem as hardware
- ros2_controllers_path = os.path.join(
- get_package_share_directory("xxx_moveit_config"),
- "config",
- "ros2_controllers.yaml",
- )
- ros2_control_node = Node(
- package="controller_manager",
- executable="ros2_control_node",
- parameters=[ros2_controllers_path],
- remappings=[
- ("/controller_manager/robot_description", "/robot_description"),
- ],
- output="both",
- )
-
- joint_state_broadcaster_spawner = Node(
- package="controller_manager",
- executable="spawner",
- arguments=[
- "joint_state_broadcaster",
- "--controller-manager",
- "/controller_manager",
- ],
- )
-
- xxx_xx_controller_spawner = Node(
- package="controller_manager",
- executable="spawner",
- arguments=[
- "xxx_xx_controller",
- "--controller-manager",
- "/controller_manager",
- ],
- )
-
- # Warehouse mongodb server
- db_config = LaunchConfiguration("db")
- mongodb_server_node = Node(
- package="warehouse_ros_mongo",
- executable="mongo_wrapper_ros.py",
- parameters=[
- {"warehouse_port": 33829},
- {"warehouse_host": "localhost"},
- {"warehouse_plugin": "warehouse_ros_mongo::MongoDatabaseConnection"},
- ],
- output="screen",
- condition=IfCondition(db_config),
- )
-
- return LaunchDescription(
- [
- db_arg,
- rviz_node,
- static_tf,
- robot_state_publisher,
- run_move_group_node,
- ros2_control_node,
- mongodb_server_node,
- joint_state_broadcaster_spawner,
- xxx_xx_controller_spawner,
- ]
- )
xxx的地方根据自己的文件名进行替换,.urdf.xacro、.srdf、_moveit_config的地方都替换自己的文件名。
xxx_xx的是在创建moveit_setup_assistant配置机械臂包的时候自己填写的Group Name。
一共有8个地方需要改。
改完以后,编译,再source一下,应该就可以运行demo.launch.py了。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。