Unified hexapod repository, containing all modules
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

85 рядки
2.6KB

  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. def generate_launch_description():
  8. robot_description_content = Command([
  9. PathJoinSubstitution([FindExecutable(name="xacro")]),
  10. " ",
  11. PathJoinSubstitution(
  12. [
  13. FindPackageShare("hexapod_robot"),
  14. "config",
  15. "urdf",
  16. "hexapod_robot.urdf.xacro"
  17. ]
  18. )
  19. ]
  20. )
  21. robot_description = {"robot_description": robot_description_content}
  22. robot_controllers = PathJoinSubstitution([FindPackageShare("hexapod_robot"), "config", "ros2_controllers.yaml"])
  23. robot_state_publisher_node = Node(
  24. package = "robot_state_publisher",
  25. executable = "robot_state_publisher",
  26. parameters = [robot_description],
  27. output = "both"
  28. )
  29. control_node = Node(
  30. package = "controller_manager",
  31. executable = "ros2_control_node",
  32. parameters = [robot_description, robot_controllers],
  33. output = "both"
  34. )
  35. taranis_node = Node(
  36. package = "taranis",
  37. executable = "taranis_node",
  38. output = "both"
  39. )
  40. ik_node = Node(
  41. package = "hexapod_python",
  42. executable = "taranis_test",
  43. output = "both"
  44. )
  45. joint_state_broadcaster_spawner = Node (
  46. package = "controller_manager",
  47. executable = "spawner",
  48. arguments = ["joint_state_broadcaster", "--controller-manager", "/controller_manager"]
  49. )
  50. joint_trajectory_controller_spawner = Node(
  51. package = "controller_manager",
  52. executable = "spawner",
  53. arguments = ["joint_group_controller", "--controller-manager", "/controller_manager"]
  54. )
  55. delay_joint_trajectory_controller_spawner_after_joint_state_broadcaster_spawner = RegisterEventHandler(
  56. event_handler = OnProcessExit(
  57. target_action = joint_state_broadcaster_spawner,
  58. on_exit = [joint_trajectory_controller_spawner]
  59. )
  60. )
  61. nodes = [
  62. control_node,
  63. taranis_node,
  64. ik_node,
  65. robot_state_publisher_node,
  66. joint_state_broadcaster_spawner,
  67. delay_joint_trajectory_controller_spawner_after_joint_state_broadcaster_spawner
  68. ]
  69. return LaunchDescription(nodes)