鱼香ROS社区
    • 版块
    • 最新
    • 未解决
    • 已解决
    • 群组
    • 注册
    • 登录
    紧急通知:禁止一切关于政治&VPN翻墙等话题,发现相关帖子会立马删除封号
    提问前必看的发帖注意事项: 社区问答规则(小鱼个人)更新 | 高质量帖子发布指南

    使用ros2_control加阿克曼插件仿真gazebo无效

    已定时 已固定 已锁定 已移动 未解决
    综合问题
    gazebo 仿真 ros2control
    3
    9
    484
    正在加载更多帖子
    • 从旧到新
    • 从新到旧
    • 最多赞同
    回复
    • 在新帖中回复
    登录后回复
    此主题已被删除。只有拥有主题管理权限的用户可以查看。
    • 11321092421
      YoungRicky
      最后由 编辑

      启动后无法通过键盘节点来控制机器人的运动 没有反应
      这是ros2_control.xacro

      <?xml version="1.0"?>
      <robot xmlns:xacro="http://www.ros.org/wiki/xacro">
      
          <ros2_control name="hunterGazeboSystem" type="system">
              <hardware>
                  <plugin>gazebo_ros2_control/GazeboSystem</plugin>
              </hardware>
      
              <joint name="front_left_wheel_joint">
                  <command_interface name="velocity">
                      <param name="min">0.0</param>
                      <param name="max">20.0</param>
                  </command_interface>
                  <state_interface name="position" />
                  <state_interface name="velocity" />
              </joint>
      
              <joint name="front_right_wheel_joint">
                  <command_interface name="velocity">
                      <param name="min">0.0</param>
                      <param name="max">20.0</param>
                  </command_interface>
                  <state_interface name="position" />
                  <state_interface name="velocity" />
              </joint>
      
              <joint name="rear_left_wheel_joint">
                  <command_interface name="velocity">
                      <param name="min">0.0</param>
                      <param name="max">20.0</param>
                  </command_interface>
                  <state_interface name="position" />
                  <state_interface name="velocity" />
              </joint>
      
              <joint name="rear_right_wheel_joint">
                  <command_interface name="velocity">
                      <param name="min">0.0</param>
                      <param name="max">20.0</param>
                  </command_interface>
                  <state_interface name="position" />
                  <state_interface name="velocity" />
              </joint>
      
              <joint name="front_left_steering_joint">
                  <command_interface name="position">
                      <param name="min">-1.0</param>
                      <param name="max">1.0</param>
                  </command_interface>
                  <state_interface name="position" />
              </joint>
      
              <joint name="front_right_steering_joint">
                  <command_interface name="position">
                      <param name="min">-1.0</param>
                      <param name="max">1.0</param>
                  </command_interface>
                  <state_interface name="position" />
              </joint>
      
              <joint name="steering_joint">
                  <command_interface name="position">
                      <param name="min">-1.0</param>
                      <param name="max">1.0</param>
                  </command_interface>
                  <state_interface name="position" />
              </joint>
          </ros2_control>
      
          <gazebo>
              <plugin name="gazebo_ros2_control" filename="libgazebo_ros2_control.so">
                  <parameters>$(find ackermancar_description)/config/controller.yaml</parameters>
              </plugin>
          </gazebo>
      </robot>
      

      这是controller.yaml

      controller_manager:
        ros__parameters:
          update_rate: 50  # Hz
          use_sim_time: true
          hunter_joint_state_broadcaster:
            type: joint_state_broadcaster/JointStateBroadcaster
            use_sim_time: true
          hunter_ackermann_drive_controller:
            type: ackermann_steering_controller/AckermannSteeringController
      
      hunter_effort_controller:
        ros__parameters:
          joints:
            - front_left_wheel_joint
            - front_right_wheel_joint
            - rear_left_wheel_joint
            - rear_right_wheel_joint
            - front_left_steering_joint
            - front_right_steering_joint
            - steering_joint
          command_interfaces:
            - position
            - velocity
          state_interfaces:
            - position
            - velocity
      
      hunter_ackermann_drive_controller:
        ros__parameters:
          front_left_wheel_joint: front_left_wheel_joint
          front_right_wheel_joint: front_right_wheel_joint
          rear_left_wheel_joint: rear_left_wheel_joint
          rear_right_wheel_joint: rear_right_wheel_joint
          front_left_steering_joint: front_left_steering_joint
          front_right_steering_joint: front_right_steering_joint
          steering_wheel_joint: steering_joint
      
          max_steer: 0.6458
          max_steering_angle: 7.85
          max_speed: 20
      
          left_steering_pid_gain: [1000, 10, 1]
          left_steering_i_range: [0, 0]
          right_steering_pid_gain: [1000, 10, 1]
          right_steering_i_range: [0, 0]
          linear_velocity_pid_gain: [1000, 10, 1]
          linear_velocity_i_range: [0, 0]
      
          publish_odom: true
          publish_odom_tf: true
          publish_wheel_tf: false
          publish_distance: true
      
          odometry_frame: odom
          robot_base_frame: base_link
      

      这是gazebo启动时的信息

      [spawn_entity.py-5] [INFO] [1732942276.129969189] [spawn_entity]: Spawn status: SpawnEntity: Successfully spawned entity [orbbec_hunter2]
      [INFO] [spawn_entity.py-5]: process has finished cleanly [pid 74698]
      [gazebo-4] [INFO] [1732942276.295861284] [gazebo_ros2_control]: Loading gazebo_ros2_control plugin
      [gazebo-4] [INFO] [1732942276.297774399] [gazebo_ros2_control]: Starting gazebo_ros2_control plugin in namespace: /
      [gazebo-4] [INFO] [1732942276.297797885] [gazebo_ros2_control]: Starting gazebo_ros2_control plugin in ros 2 node: gazebo_ros2_control
      [gazebo-4] [INFO] [1732942276.299302238] [gazebo_ros2_control]: connected to service!! robot_state_publisher
      [gazebo-4] [INFO] [1732942276.299597077] [gazebo_ros2_control]: Received urdf from param server, parsing...
      [gazebo-4] [INFO] [1732942276.300242373] [gazebo_ros2_control]: Loading parameter files /home/youngricky/graduation_project_ws/install/ackermancar_description/share/ackermancar_description/config/controller.yaml
      [gazebo-4] [INFO] [1732942276.306206802] [gazebo_ros2_control]: Loading joint: front_left_wheel_joint
      [gazebo-4] [INFO] [1732942276.306221844] [gazebo_ros2_control]:         State:
      [gazebo-4] [INFO] [1732942276.306225818] [gazebo_ros2_control]:                  position
      [gazebo-4] [INFO] [1732942276.306229320] [gazebo_ros2_control]:                  velocity
      [gazebo-4] [INFO] [1732942276.306231778] [gazebo_ros2_control]:         Command:
      [gazebo-4] [INFO] [1732942276.306245519] [gazebo_ros2_control]:                  velocity
      [gazebo-4] [INFO] [1732942276.306343093] [gazebo_ros2_control]: Loading joint: front_right_wheel_joint
      [gazebo-4] [INFO] [1732942276.306347954] [gazebo_ros2_control]:         State:
      [gazebo-4] [INFO] [1732942276.306350312] [gazebo_ros2_control]:                  position
      [gazebo-4] [INFO] [1732942276.306352671] [gazebo_ros2_control]:                  velocity
      [gazebo-4] [INFO] [1732942276.306354822] [gazebo_ros2_control]:         Command:
      [gazebo-4] [INFO] [1732942276.306359325] [gazebo_ros2_control]:                  velocity
      [gazebo-4] [INFO] [1732942276.306418386] [gazebo_ros2_control]: Loading joint: rear_left_wheel_joint
      [gazebo-4] [INFO] [1732942276.306423555] [gazebo_ros2_control]:         State:
      [gazebo-4] [INFO] [1732942276.306426446] [gazebo_ros2_control]:                  position
      [gazebo-4] [INFO] [1732942276.306430171] [gazebo_ros2_control]:                  velocity
      [gazebo-4] [INFO] [1732942276.306432543] [gazebo_ros2_control]:         Command:
      [gazebo-4] [INFO] [1732942276.306436231] [gazebo_ros2_control]:                  velocity
      [gazebo-4] [INFO] [1732942276.306608743] [gazebo_ros2_control]: Loading joint: rear_right_wheel_joint
      [gazebo-4] [INFO] [1732942276.306628578] [gazebo_ros2_control]:         State:
      [gazebo-4] [INFO] [1732942276.306638252] [gazebo_ros2_control]:                  position
      [gazebo-4] [INFO] [1732942276.306646477] [gazebo_ros2_control]:                  velocity
      [gazebo-4] [INFO] [1732942276.306654058] [gazebo_ros2_control]:         Command:
      [gazebo-4] [INFO] [1732942276.306668289] [gazebo_ros2_control]:                  velocity
      [gazebo-4] [INFO] [1732942276.306826081] [gazebo_ros2_control]: Loading joint: front_left_steering_joint
      [gazebo-4] [INFO] [1732942276.306847201] [gazebo_ros2_control]:         State:
      [gazebo-4] [INFO] [1732942276.306856541] [gazebo_ros2_control]:                  position
      [gazebo-4] [INFO] [1732942276.306871575] [gazebo_ros2_control]:         Command:
      [gazebo-4] [INFO] [1732942276.306879493] [gazebo_ros2_control]:                  position
      [gazebo-4] [INFO] [1732942276.307006350] [gazebo_ros2_control]: Loading joint: front_right_steering_joint
      [gazebo-4] [INFO] [1732942276.307011916] [gazebo_ros2_control]:         State:
      [gazebo-4] [INFO] [1732942276.307015456] [gazebo_ros2_control]:                  position
      [gazebo-4] [INFO] [1732942276.307017970] [gazebo_ros2_control]:         Command:
      [gazebo-4] [INFO] [1732942276.307020922] [gazebo_ros2_control]:                  position
      [gazebo-4] [WARN] [1732942276.307103978] [gazebo_ros2_control]: Skipping joint in the URDF named 'steering_joint' which is not in the gazebo model.
      [gazebo-4] [INFO] [1732942276.307136546] [resource_manager]: Initialize hardware 'hunterGazeboSystem' 
      [gazebo-4] [INFO] [1732942276.307227533] [resource_manager]: Successful initialization of hardware 'hunterGazeboSystem'
      [gazebo-4] [INFO] [1732942276.307267768] [resource_manager]: 'configure' hardware 'hunterGazeboSystem' 
      [gazebo-4] [INFO] [1732942276.307271664] [resource_manager]: Successful 'configure' of hardware 'hunterGazeboSystem'
      [gazebo-4] [INFO] [1732942276.307274915] [resource_manager]: 'activate' hardware 'hunterGazeboSystem' 
      [gazebo-4] [INFO] [1732942276.307277208] [resource_manager]: Successful 'activate' of hardware 'hunterGazeboSystem'
      [gazebo-4] [INFO] [1732942276.307315865] [gazebo_ros2_control]: Loading controller_manager
      [gazebo-4] [WARN] [1732942276.317574735] [gazebo_ros2_control]:  Desired controller update period (0.02 s) is slower than the gazebo simulation period (0.001 s).
      [gazebo-4] [INFO] [1732942276.317694972] [gazebo_ros2_control]: Loaded gazebo_ros2_control.
      [gazebo-4] 
      [gazebo-4] libcurl: (56) OpenSSL SSL_read: error:0A000126:SSL routines::unexpected eof while reading, errno 0
      

      这是话题信息

      youngricky@youngricky-Hasee:~$ ros2 topic list 
      /clicked_point
      /clock
      /front_color_camera/camera_info
      /front_color_camera/image_raw
      /front_color_camera/image_raw/compressed
      /front_color_camera/image_raw/compressedDepth
      /front_color_camera/image_raw/theora
      /front_depth_camera/camera_info
      /front_depth_camera/depth/camera_info
      /front_depth_camera/depth/image_raw
      /front_depth_camera/depth/image_raw/compressed
      /front_depth_camera/depth/image_raw/compressedDepth
      /front_depth_camera/depth/image_raw/theora
      /front_depth_camera/image_raw
      /front_depth_camera/image_raw/compressed
      /front_depth_camera/image_raw/compressedDepth
      /front_depth_camera/image_raw/theora
      /front_depth_camera/points
      /front_ultrasonic
      /goal_pose
      /imu
      /initialpose
      /joint_states
      /left_color_camera/camera_info
      /left_color_camera/image_raw
      /left_color_camera/image_raw/compressed
      /left_color_camera/image_raw/compressedDepth
      /left_color_camera/image_raw/theora
      /orbbec_hunter2/cmd_vel
      /parameter_events
      /rear_color_camera/camera_info
      /rear_color_camera/image_raw
      /rear_color_camera/image_raw/compressed
      /rear_color_camera/image_raw/compressedDepth
      /rear_color_camera/image_raw/theora
      /rear_ultrasonic
      /right_color_camera/camera_info
      /right_color_camera/image_raw
      /right_color_camera/image_raw/compressed
      /right_color_camera/image_raw/compressedDepth
      /right_color_camera/image_raw/theora
      /robot_description
      /rosout
      /scan
      /tf
      /tf_static
      
      小鱼小 1 条回复 最后回复 回复 引用 0
      • 小鱼小
        小鱼 技术大佬 @1132109242
        最后由 编辑

        @1132109242 没看到激活这个hunter_ackermann_drive_controller控制器

        新书配套视频:https://www.bilibili.com/video/BV1GW42197Ck/

        11321092421 1 条回复 最后回复 回复 引用 0
        • 11321092421
          YoungRicky @小鱼
          最后由 编辑

          @小鱼 在 使用ros2_control加阿克曼插件仿真gazebo无效 中说:

          没看到激活这个hunter_ackermann_drive_controller控制器

          hunter_ackermann_drive_controller:
          type: ackermann_steering_controller/AckermannSteeringController请问小鱼大大这一行不是的吗 或者还需要在其他地方添加什么东西吗

          小鱼小 1 条回复 最后回复 回复 引用 0
          • 小鱼小
            小鱼 技术大佬 @1132109242
            最后由 编辑

            @1132109242 这个只是添加,还要激活,你看看我B站视频介绍

            新书配套视频:https://www.bilibili.com/video/BV1GW42197Ck/

            11321092421 1 条回复 最后回复 回复 引用 0
            • 11321092421
              YoungRicky @小鱼
              最后由 编辑

              @小鱼 我激活了 gazebo里也加载成功了 但是gazebo里面机器人前轮岔着跑不知道是什么原因截图 2024-12-10 16-16-18.png

              11321092421 27616077292 2 条回复 最后回复 回复 引用 0
              • 11321092421
                YoungRicky @1132109242
                最后由 1132109242 编辑

                @小鱼 最新的launch文件

                from launch import LaunchDescription
                from launch_ros.actions import Node
                
                # terminator command class
                from launch.actions import ExecuteProcess
                from launch.substitutions import FindExecutable
                
                # parameters' declare and obtain in a node
                from launch.actions import DeclareLaunchArgument
                from launch.substitutions import LaunchConfiguration
                
                # file, use launch to launch muitiple launch files
                from launch.actions import IncludeLaunchDescription
                from launch.launch_description_sources import PythonLaunchDescriptionSource
                
                # group
                from launch_ros.actions import PushRosNamespace
                from launch.actions import GroupAction
                
                # event
                from launch.event_handlers import OnProcessStart, OnProcessExit
                from launch.actions import ExecuteProcess, RegisterEventHandler, LogInfo
                
                # obtain the "share" path of the package
                from ament_index_python.packages import get_package_share_directory
                from launch_ros.substitutions import FindPackageShare
                import os
                
                # parameters load
                from launch_ros.parameter_descriptions import ParameterValue
                from launch.substitutions import Command
                
                from launch.conditions import IfCondition, UnlessCondition
                
                
                def generate_launch_description():
                    robot_name = "hunter2"  # hunter hunter2
                    file_prefix = "urdf/" + robot_name + "/"
                    package_name = "ackermancar_description"
                    world_file_path = "worlds/simple_world.world"
                
                    pkg_path = os.path.join(get_package_share_directory(package_name))
                    world_path = os.path.join(pkg_path, world_file_path)
                    print(world_path)
                    xacro_name = "hunter2.urdf.xacro"
                    xacro_model_path = os.path.join(pkg_path, f"{file_prefix+xacro_name}")
                
                    rviz_path = os.path.join(pkg_path, "rviz/gazebo.rviz")
                
                    rvizconfig = DeclareLaunchArgument(
                        name="rvizconfig",
                        default_value=str(rviz_path),
                        description="Absolute path to rviz config file",
                    )
                
                    use_sim_time = DeclareLaunchArgument(
                        "use_sim_time",
                        default_value="true",
                        description="Use simulation (Gazebo) clock if true",
                    )
                
                    remap_odom_tf = DeclareLaunchArgument(
                        "remap_odometry_tf",
                        default_value="true",
                        description="Remap odometry TF from the steering controller to the TF tree.",
                    )
                
                    remap_odometry_tf = LaunchConfiguration("remap_odometry_tf")
                
                    robot_description = ParameterValue(
                        Command(["xacro" + " ", xacro_model_path]), value_type=str
                    )
                
                    robot_state_publisher_node = Node(
                        package="robot_state_publisher",
                        executable="robot_state_publisher",
                        parameters=[
                            {
                                "robot_description": robot_description,
                                "use_sim_time": LaunchConfiguration("use_sim_time"),
                            }
                        ],
                    )
                
                    spawn_x_val = "-3.0"
                    spawn_y_val = "-8.0"
                    spawn_z_val = "0.4"
                    spawn_yaw_val = "0.0"
                
                    launch_gazebo = IncludeLaunchDescription(
                        PythonLaunchDescriptionSource(
                            [get_package_share_directory("gazebo_ros"), "/launch", "/gazebo.launch.py"]
                        ),
                        launch_arguments=[("world", world_path), ("verbose", "true")],
                    )
                
                    spawn_entity = Node(
                        package="gazebo_ros",
                        executable="spawn_entity.py",
                        arguments=[
                            "-topic",
                            "robot_description",
                            "-entity",
                            robot_name,
                            "-x",
                            spawn_x_val,
                            "-y",
                            spawn_y_val,
                            "-z",
                            spawn_z_val,
                            "-Y",
                            spawn_yaw_val,
                        ],
                        output="screen",
                    )
                
                    robot_controllers = os.path.join(pkg_path, "params", robot_name, "controller.yaml")
                
                    control_node_remapped = Node(
                        package="controller_manager",
                        executable="ros2_control_node",
                        parameters=[robot_controllers],
                        output="both",
                        remappings=[
                            ("~/robot_description", "/robot_description"),
                            ("/bicycle_steering_controller/tf_odometry", "/tf"),
                        ],
                        condition=IfCondition(remap_odometry_tf),
                    )
                    control_node = Node(
                        package="controller_manager",
                        executable="ros2_control_node",
                        parameters=[robot_controllers],
                        output="both",
                        remappings=[
                            ("~/robot_description", "/robot_description"),
                        ],
                        condition=UnlessCondition(remap_odometry_tf),
                    )
                
                    joint_state_broadcaster_spawner = Node(
                        package="controller_manager",
                        executable="spawner",
                        arguments=[
                            "joint_state_broadcaster",
                            "--controller-manager",
                            "/controller_manager",
                        ],
                    )
                
                    ackermann_steering_controller_spawner = Node(
                        package="controller_manager",
                        executable="spawner",
                        arguments=[
                            "ackermann_steering_controller",
                            "--controller-manager",
                            "/controller_manager",
                        ],
                    )
                
                    return LaunchDescription(
                        [
                            use_sim_time,
                            remap_odom_tf,
                            launch_gazebo,
                            spawn_entity,
                            control_node_remapped,
                            robot_state_publisher_node,
                            control_node,
                            joint_state_broadcaster_spawner,
                            ackermann_steering_controller_spawner,
                            rvizconfig,
                        ]
                    )
                
                

                和controller.yaml

                controller_manager:
                  ros__parameters:
                    update_rate: 10 # Hz
                    use_sim_time: true
                    joint_state_broadcaster:
                      type: joint_state_broadcaster/JointStateBroadcaster
                    ackermann_steering_controller: 
                      type: 'ackermann_steering_controller/AckermannSteeringController'
                ackermann_steering_controller:
                  ros__parameters:
                    wheelbase: 0.65
                    front_wheel_track: 0.605
                    rear_wheel_track: 0.605
                    front_wheels_radius: 0.165
                    rear_wheels_radius: 0.165
                    front_steering: true
                    reference_timeout: 2.0
                    rear_wheels_names: ['rear_left_wheel_joint', 'rear_right_wheel_joint']
                    front_wheels_names: ['front_left_wheel_joint', 'front_right_wheel_joint']
                    open_loop: false
                    velocity_rolling_window_size: 10
                    base_frame_id: base_link
                    odom_frame_id: odom
                    enable_odom_tf: true
                    twist_covariance_diagonal: [0.0, 7.0, 14.0, 21.0, 28.0, 35.0]
                    pose_covariance_diagonal: [0.0, 7.0, 14.0, 21.0, 28.0, 35.0]
                    position_feedback: false
                
                1 条回复 最后回复 回复 引用 0
                • 27616077292
                  赤诚 @1132109242
                  最后由 编辑

                  @1132109242 兄弟,我也碰见了类似的阿克曼问题,right_steering_joint和left_steering_joint一加上,模型就寄了

                  11321092421 1 条回复 最后回复 回复 引用 0
                  • 11321092421
                    YoungRicky @2761607729
                    最后由 编辑

                    @2761607729 我放弃用ros_control里 直接用gazebo插件里

                    27616077292 1 条回复 最后回复 回复 引用 0
                    • 27616077292
                      赤诚 @1132109242
                      最后由 编辑

                      @1132109242 我就是用的gazebo插件,兄弟,你的搞好了吗

                      1 条回复 最后回复 回复 引用 0
                      • 第一个帖子
                        最后一个帖子
                      皖ICP备16016415号-7
                      Powered by NodeBB | 鱼香ROS