Nathan85001 / AMR-Graduation-project

0 stars 0 forks source link

problem at gazebo.launch.py #1

Open Nathan85001 opened 7 months ago

Nathan85001 commented 7 months ago

nathan@nathan-G5-5500:~/amr_path_planning_ws$ ros2 launch amr_description gazebo.launch.py [INFO] [launch]: All log files can be found below /home/nathan/.ros/log/2024-02-10-02-24-45-436255-nathan-G5-5500-25952 [INFO] [launch]: Default logging verbosity is set to INFO [INFO] [gzserver-1]: process started with pid [25954] [INFO] [gzclient-2]: process started with pid [25956] [INFO] [robot_state_publisher-3]: process started with pid [25958] [INFO] [spawn_entity.py-4]: process started with pid [25960] [robot_state_publisher-3] [INFO] [1707524686.609737431] [robot_state_publisher]: got segment base [robot_state_publisher-3] [INFO] [1707524686.609841681] [robot_state_publisher]: got segment base_footprint [robot_state_publisher-3] [INFO] [1707524686.609849816] [robot_state_publisher]: got segment bot_top [robot_state_publisher-3] [INFO] [1707524686.609868213] [robot_state_publisher]: got segment bot_top_plate [robot_state_publisher-3] [INFO] [1707524686.609871558] [robot_state_publisher]: got segment inner_left_back [robot_state_publisher-3] [INFO] [1707524686.609874710] [robot_state_publisher]: got segment inner_left_front [robot_state_publisher-3] [INFO] [1707524686.609877943] [robot_state_publisher]: got segment inner_right_back [robot_state_publisher-3] [INFO] [1707524686.609881446] [robot_state_publisher]: got segment inner_right_front [robot_state_publisher-3] [INFO] [1707524686.609884553] [robot_state_publisher]: got segment kinect_camera [robot_state_publisher-3] [INFO] [1707524686.609887762] [robot_state_publisher]: got segment lidar [robot_state_publisher-3] [INFO] [1707524686.609890889] [robot_state_publisher]: got segment outer_left_back [robot_state_publisher-3] [INFO] [1707524686.609894056] [robot_state_publisher]: got segment outer_left_front [robot_state_publisher-3] [INFO] [1707524686.609897240] [robot_state_publisher]: got segment outer_right_back [robot_state_publisher-3] [INFO] [1707524686.609900355] [robot_state_publisher]: got segment outer_right_front [robot_state_publisher-3] [INFO] [1707524686.609903455] [robot_state_publisher]: got segment shaft_left_back [robot_state_publisher-3] [INFO] [1707524686.609906639] [robot_state_publisher]: got segment shaft_left_front [robot_state_publisher-3] [INFO] [1707524686.609909770] [robot_state_publisher]: got segment shaft_right_back [robot_state_publisher-3] [INFO] [1707524686.609912822] [robot_state_publisher]: got segment shaft_right_front [spawn_entity.py-4] [INFO] [1707524686.911389553] [spawn_entity]: Spawn Entity started [spawn_entity.py-4] [INFO] [1707524686.911640238] [spawn_entity]: Loading entity published on topic robot_description [spawn_entity.py-4] /opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/qos.py:307: UserWarning: DurabilityPolicy.RMW_QOS_POLICY_DURABILITY_TRANSIENT_LOCAL is deprecated. Use DurabilityPolicy.TRANSIENT_LOCAL instead. [spawn_entity.py-4] warnings.warn( [spawn_entity.py-4] [INFO] [1707524686.912841796] [spawn_entity]: Waiting for entity xml on robot_description [spawn_entity.py-4] [INFO] [1707524686.924178294] [spawn_entity]: Waiting for service /spawn_entity, timeout = 30 [spawn_entity.py-4] [INFO] [1707524686.924444652] [spawn_entity]: Waiting for service /spawn_entity [spawn_entity.py-4] [ERROR] [1707524716.970322852] [spawn_entity]: Service %s/spawn_entity unavailable. Was Gazebo started with GazeboRosFactory? [spawn_entity.py-4] [ERROR] [1707524716.970744448] [spawn_entity]: Spawn service failed. Exiting. [ERROR] [spawn_entity.py-4]: process has died [pid 25960, exit code 1, cmd '/opt/ros/humble/lib/gazebo_ros/spawn_entity.py -entity amr -topic robot_description --ros-args']. ^C[WARNING] [launch]: user interrupted with ctrl-c (SIGINT)

[ERROR] [gzclient-2]: process has died [pid 25956, exit code -2, cmd 'gzclient']. [INFO] [robot_state_publisher-3]: process has finished cleanly [pid 25958] [ERROR] [gzserver-1]: process[gzserver-1] failed to terminate '5' seconds after receiving 'SIGINT', escalating to 'SIGTERM' [INFO] [gzserver-1]: sending signal 'SIGTERM' to process[gzserver-1]

[ERROR] [gzserver-1]: process[gzserver-1] failed to terminate '10.0' seconds after receiving 'SIGTERM', escalating to 'SIGKILL' [INFO] [gzserver-1]: sending signal 'SIGKILL' to process[gzserver-1] [ERROR] [gzserver-1]: process has died [pid 25954, exit code -9, cmd 'gzserver -slibgazebo_ros_init.so -slibgazebo_ros_factory.so -slibgazebo_ros_force_system.so'].

Nathan85001 commented 7 months ago

`import os from os import pathsep from ament_index_python.packages import get_package_share_directory, get_package_prefix

from launch import LaunchDescription from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription, SetEnvironmentVariable from launch.substitutions import Command, LaunchConfiguration from launch.launch_description_sources import PythonLaunchDescriptionSource

from launch_ros.actions import Node from launch_ros.parameter_descriptions import ParameterValue

def generate_launch_description(): amr_description = get_package_share_directory("amr_description") amr_description_prefix= os.path.join(get_package_prefix("amr_description"), "share") gazebo_ros_dir = get_package_share_directory("gazebo_ros")

model_arg = DeclareLaunchArgument(name="model", default_value=os.path.join(
                                    amr_description, "urdf", "amr.urdf.xacro"
                                    ),
                                    description="Absolute path to robot urdf file"
)

model_path = os.path.join(amr_description, "models")
model_path += pathsep + os.path.join(amr_description_prefix, "share")

env_var = SetEnvironmentVariable("GAZEBO_MODEL_PATH", model_path)

robot_description = ParameterValue(Command(["xacro ", LaunchConfiguration("model")]),
                                    value_type=str)

robot_state_publisher_node = Node(
    package="robot_state_publisher",
    executable="robot_state_publisher",
    # parameters=[{'robot_description': launch_ros.descriptions.ParameterValue( launch.substitutions.Command(['xacro ',os.path.join(amr_description, "urdf", "amr.urdf.xacro")]), value_type=str)  }]
    parameters=[{"robot_description": robot_description}]
)

start_gazebo_server = IncludeLaunchDescription(
    PythonLaunchDescriptionSource(
        os.path.join(gazebo_ros_dir, "launch", "gzserver.launch.py")
    )
)

start_gazebo_client = IncludeLaunchDescription(
    PythonLaunchDescriptionSource(
        os.path.join(gazebo_ros_dir, "launch", "gzclient.launch.py")
    )
)

spawn_robot = Node(package="gazebo_ros", executable="spawn_entity.py",
                    arguments=["-entity", "amr",
                                "-topic", "robot_description",
                                ],
                    output="screen"
)

return LaunchDescription([
    env_var,
    model_arg,
    start_gazebo_server,
    start_gazebo_client,
    robot_state_publisher_node,
    spawn_robot
])`