ROS Components for hexapod_robot
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

96 Zeilen
3.3KB

  1. from launch import LaunchDescription
  2. from launch.actions import RegisterEventHandler
  3. from launch.substitutions import Command, FindExecutable, LaunchConfiguration, PathJoinSubstitution
  4. from launch.event_handlers import OnProcessExit
  5. from launch_ros.actions import Node
  6. from launch_ros.substitutions import FindPackageShare
  7. from moveit_configs_utils import MoveItConfigsBuilder
  8. def generate_launch_description():
  9. moveit_config = (
  10. MoveItConfigsBuilder("hexapod_robot", package_name = "hexapod_robot")
  11. .planning_scene_monitor(
  12. publish_robot_description=True, publish_robot_description_semantic=True
  13. )
  14. .planning_pipelines(pipelines = ["ompl"])
  15. .to_moveit_configs()
  16. )
  17. move_group_node = Node(
  18. package = "moveit_ros_move_group",
  19. executable = "move_group",
  20. output = "screen",
  21. parameters = [moveit_config.to_dict()]
  22. )
  23. ros2_controllers = PathJoinSubstitution([FindPackageShare("hexapod_robot"), "config", "ros2_controllers.yaml"])
  24. robot_state_publisher_node = Node(
  25. package = "robot_state_publisher",
  26. executable = "robot_state_publisher",
  27. parameters = [moveit_config.robot_description],
  28. output = "both"
  29. )
  30. ros2_control_node = Node(
  31. package = "controller_manager",
  32. executable = "ros2_control_node",
  33. parameters = [moveit_config.robot_description, ros2_controllers],
  34. output="both"
  35. )
  36. rviz_node = Node(
  37. package = "rviz2",
  38. executable = "rviz2",
  39. arguments = ['-d', PathJoinSubstitution([FindPackageShare("hexapod_robot"), "config", "hexapod_robot.rviz"])],
  40. name = "rviz2",
  41. output = "screen",
  42. parameters = [moveit_config.planning_pipelines, moveit_config.robot_description_kinematics]
  43. )
  44. joint_state_broadcaster_spawner = Node (
  45. package = "controller_manager",
  46. executable = "spawner",
  47. arguments = ["joint_state_broadcaster", "--controller-manager", "/controller_manager"]
  48. )
  49. joint_trajectory_controller_spawner = Node(
  50. package = "controller_manager",
  51. executable = "spawner",
  52. arguments = ["e1_group_controller", "e2_group_controller", "e3_group_controller", "e4_group_controller", "e5_group_controller", "e6_group_controller", "--controller-manager", "/controller_manager"]
  53. )
  54. delay_rviz_after_joint_state_broadcaster_spawner = RegisterEventHandler(
  55. event_handler = OnProcessExit(
  56. target_action = joint_state_broadcaster_spawner,
  57. on_exit = [rviz_node]
  58. )
  59. )
  60. delay_joint_trajectory_controller_spawner_after_joint_state_broadcaster_spawner = RegisterEventHandler(
  61. event_handler = OnProcessExit(
  62. target_action = joint_state_broadcaster_spawner,
  63. on_exit = [joint_trajectory_controller_spawner]
  64. )
  65. )
  66. nodes = [
  67. robot_state_publisher_node,
  68. move_group_node,
  69. ros2_control_node,
  70. joint_state_broadcaster_spawner,
  71. delay_rviz_after_joint_state_broadcaster_spawner,
  72. # delay_forward_position_controller_spawner_after_joint_state_broadcaster_spawner,
  73. delay_joint_trajectory_controller_spawner_after_joint_state_broadcaster_spawner
  74. ]
  75. return LaunchDescription(nodes)