m0_61578670 2025-02-12 10:05 采纳率: 50%
浏览 15

ros/gazebo

我用gazebo仿真小车运动,下面是我按照教程编写的urdf文件,但是我运行gazebo后,出现了很多debug,如下图所示,然后话题也没有cmd_vel,请问这是什么原因呢?


<?xml version="1.0" encoding="utf-8"?>
<!-- This URDF was automatically created by SolidWorks to URDF Exporter! Originally created by Stephen Brawner (brawner@gmail.com) 
     Commit Version: 1.6.0-4-g7f85cfe  Build Version: 1.6.7995.38578
     For more information, please see http://wiki.ros.org/sw_urdf_exporter -->
<robot
  name="mycar">
  <link
    name="base_link">
    <inertial>
      <origin
        xyz="1.04862678870082E-17 1.38777878078145E-17 -0.03"
        rpy="0 0 0" />
      <mass
        value="1.8" />
      <inertia
        ixx="0.003915"
        ixy="-1.0842021724855E-19"
        ixz="-1.80700362080917E-19"
        iyy="0.00654"
        iyz="6.37746501097161E-36"
        izz="0.009375" />
    </inertial>
    <visual>
      <origin
        xyz="0 0 0"
        rpy="0 0 0" />
      <geometry>
        <mesh
          filename="package://mycar/meshes/base_link.STL" />
      </geometry>
      <material
        name="">
        <color
          rgba="1 1 1 1" />
      </material>
    </visual>
    <collision>
      <origin
        xyz="0 0 0"
        rpy="0 0 0" />
      <geometry>
        <mesh
          filename="package://mycar/meshes/base_link.STL" />
      </geometry>
    </collision>
  </link>
  <link
    name="wheel1_link">
    <inertial>
      <origin
        xyz="1.3878E-17 0.011033 0"
        rpy="0 0 0" />
      <mass
        value="0.059627" />
      <inertia
        ixx="1.5917E-05"
        ixy="-2.2905E-23"
        ixz="-2.5935E-21"
        iyy="2.5522E-05"
        iyz="2.4238E-22"
        izz="1.5917E-05" />
    </inertial>
    <visual>
      <origin
        xyz="0 0 0"
        rpy="0 0 0" />
      <geometry>
        <mesh
          filename="package://mycar/meshes/wheel1_link.STL" />
      </geometry>
      <material
        name="">
        <color
          rgba="0.79216 0.81961 0.93333 1" />
      </material>
    </visual>
    <collision>
      <origin
        xyz="0 0 0"
        rpy="0 0 0" />
      <geometry>
        <mesh
          filename="package://mycar/meshes/wheel1_link.STL" />
      </geometry>
    </collision>
  </link>
  <joint
    name="wheel1_joint"
    type="continuous">
    <origin
      xyz="0.08 -0.115 -0.045"
      rpy="0 0 0" />
    <parent
      link="base_link" />
    <child
      link="wheel1_link" />
    <axis
      xyz="0 1 0" />
  </joint>
  <link
    name="wheel2_link">
    <inertial>
      <origin
        xyz="0 -0.011033 2.7756E-17"
        rpy="0 0 0" />
      <mass
        value="0.059627" />
      <inertia
        ixx="1.5917E-05"
        ixy="-5.0676E-22"
        ixz="-8.4832E-22"
        iyy="2.5522E-05"
        iyz="-1.3894E-22"
        izz="1.5917E-05" />
    </inertial>
    <visual>
      <origin
        xyz="0 0 0"
        rpy="0 0 0" />
      <geometry>
        <mesh
          filename="package://mycar/meshes/wheel2_link.STL" />
      </geometry>
      <material
        name="">
        <color
          rgba="0.79216 0.81961 0.93333 1" />
      </material>
    </visual>
    <collision>
      <origin
        xyz="0 0 0"
        rpy="0 0 0" />
      <geometry>
        <mesh
          filename="package://mycar/meshes/wheel2_link.STL" />
      </geometry>
    </collision>
  </link>
  <joint
    name="wheel2_joint"
    type="fixed">
    <origin
      xyz="0.08 0.115 -0.045"
      rpy="0 0 0" />
    <parent
      link="base_link" />
    <child
      link="wheel2_link" />
    <axis
      xyz="0 0 0" />
  </joint>
  <link
    name="wheel3_link">
    <inertial>
      <origin
        xyz="0 -0.011033 2.7756E-17"
        rpy="0 0 0" />
      <mass
        value="0.059627" />
      <inertia
        ixx="1.5917E-05"
        ixy="-5.0676E-22"
        ixz="-8.4832E-22"
        iyy="2.5522E-05"
        iyz="-1.3894E-22"
        izz="1.5917E-05" />
    </inertial>
    <visual>
      <origin
        xyz="0 0 0"
        rpy="0 0 0" />
      <geometry>
        <mesh
          filename="package://mycar/meshes/wheel3_link.STL" />
      </geometry>
      <material
        name="">
        <color
          rgba="0.79216 0.81961 0.93333 1" />
      </material>
    </visual>
    <collision>
      <origin
        xyz="0 0 0"
        rpy="0 0 0" />
      <geometry>
        <mesh
          filename="package://mycar/meshes/wheel3_link.STL" />
      </geometry>
    </collision>
  </link>
  <joint
    name="wheel3_joint"
    type="fixed">
    <origin
      xyz="-0.08 0.115 -0.045"
      rpy="0 0 0" />
    <parent
      link="base_link" />
    <child
      link="wheel3_link" />
    <axis
      xyz="0 0 0" />
  </joint>
  <link
    name="wheel4_link">
    <inertial>
      <origin
        xyz="0 0.011033 2.7756E-17"
        rpy="0 0 0" />
      <mass
        value="0.059627" />
      <inertia
        ixx="1.5917E-05"
        ixy="4.9885E-22"
        ixz="-7.893E-22"
        iyy="2.5522E-05"
        iyz="-3.1796E-22"
        izz="1.5917E-05" />
    </inertial>
    <visual>
      <origin
        xyz="0 0 0"
        rpy="0 0 0" />
      <geometry>
        <mesh
          filename="package://mycar/meshes/wheel4_link.STL" />
      </geometry>
      <material
        name="">
        <color
          rgba="0.79216 0.81961 0.93333 1" />
      </material>
    </visual>
    <collision>
      <origin
        xyz="0 0 0"
        rpy="0 0 0" />
      <geometry>
        <mesh
          filename="package://mycar/meshes/wheel4_link.STL" />
      </geometry>
    </collision>
  </link>
  <joint
    name="wheel4_joint"
    type="fixed">
    <origin
      xyz="-0.08 -0.115 -0.045"
      rpy="0 0 0" />
    <parent
      link="base_link" />
    <child
      link="wheel4_link" />
    <axis
      xyz="0 0 0" />
  </joint>
  <link
    name="camera_link">
    <inertial>
      <origin
        xyz="-0.0075 0 -2.7756E-17"
        rpy="0 0 0" />
      <mass
        value="0.03" />
      <inertia
        ixx="1.025E-05"
        ixy="1.1156E-36"
        ixz="1.5882E-22"
        iyy="6.8125E-06"
        iyz="-3.0268E-22"
        izz="4.5625E-06" />
    </inertial>
    <visual>
      <origin
        xyz="0 0 0"
        rpy="0 0 0" />
      <geometry>
        <mesh
          filename="package://mycar/meshes/camera_link.STL" />
      </geometry>
      <material
        name="">
        <color
          rgba="1 1 1 1" />
      </material>
    </visual>
    <collision>
      <origin
        xyz="0 0 0"
        rpy="0 0 0" />
      <geometry>
        <mesh
          filename="package://mycar/meshes/camera_link.STL" />
      </geometry>
    </collision>
  </link>
  <gazebo reference = "camera_link">
      <material>Gazebo/Red</material>
  </gazebo>
  <joint
    name="camera_joint"
    type="fixed">
    <origin
      xyz="0.08 0 0.025"
      rpy="0 0 0" />
    <parent
      link="base_link" />
    <child
      link="camera_link" />
    <axis
      xyz="0 0 0" />
  </joint>


  <transmission name="wheel3_joint_trans">
    <type> transmission_interface/SimpleTransmission</type>
    <joint name="wheel3_joint"/>
    <actuator name="wheel3_joint_motor">
      <hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface>
      <mechanicalReduction>1</mechanicalReduction>
    </actuator>
  </transmission>
    <transmission name="wheel4_joint_trans">
    <type> transmission_interface/SimpleTransmission</type>
    <joint name="wheel4_joint"/>
    <actuator name="wheel4_joint_motor">
      <hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface>
      <mechanicalReduction>1</mechanicalReduction>
    </actuator>
  </transmission>


    <gazebo>
        <plugin name="differential_drive_controller" filename="libgazebo_ros_diff_drive.so">
            <rosDebugLevel>Debug</rosDebugLevel>
            <robotNamespace>/</robotNamespace>
            <publishWheelTF>false</publishWheelTF>
            <publishWheelJointState>true</publishWheelJointState>
            <alwaysOn>true</alwaysOn>
            <leftJoint>wheel3_joint</leftJoint>
            <rightJoint>wheel4_joint</rightJoint>
            <wheelSeparation>0.3</wheelSeparation>
            <wheelDiameter>0.18</wheelDiameter>
            <wheelTorque>20</wheelTorque>
            <wheelAcceleration>1.8</wheelAcceleration>
            <commandTopic>cmd_vel</commandTopic>
            <odometryTopic>odom</odometryTopic>
            <odometryFrame>odom</odometryFrame>
            <odometrySource>world</odometrySource>
            
            <robotBaseFrame>base_link</robotBaseFrame>
        <updateRate>50</updateRate>
        </plugin>
    </gazebo>
<!-- 
    <gazebo>
      <plugin name="differential_drive_controller" filename="libgazebo_ros_diff_drive.so">
          <rosDebugLevel>Debug</rosDebugLevel>
          <alwaysOn>true</alwaysOn>
          <updateRate>40</updateRate>
          <robotNamespace>/mycar</robotNamespace>
          <legacyMode>false</legacyMode>
          <leftJoint> wheel3_joint</leftJoint>
          <rightJoint>wheel4_joint</rightJoint>
          <wheelSeparation>0.19</wheelSeparation>
          <wheelDiameter>0.06</wheelDiameter>
          <wheelTorque>30</wheelTorque>
          <commandTopic>cmd_vel</commandTopic>
          <odometryTopic>odom</odometryTopic>
          <odometryFrame>odom</odometryFrame>
          <robotBaseFrame>base_link</robotBaseFrame>
          <publishWheelTF>false</publishWheelTF>
          <publishWheelJointState>false</publishWheelJointState>
          <wheelAcceleration>1.8</wheelAcceleration>
          <odometrySource>world</odometrySource>
          <publishTf>1</publishTf>
          <publishOdomTF>false</publishOdomTF>
      </plugin>

  </gazebo>
 -->

</robot>
<launch>

  <include
    file="$(find gazebo_ros)/launch/empty_world.launch" />


  <node
    name="spawn_model"
    pkg="gazebo_ros"
    type="spawn_model"
    args="-file $(find mycar)/urdf/mycar.urdf -urdf -model mycar"
    output="screen" />

</launch>

img

  • 写回答

2条回答 默认 最新

  • 专家-赤兔[在线] 优质创作者: 编程框架技术领域 2025-02-12 10:05
    关注

    以下回复引自免费微信小程序:皆我百晓生。 如问题解决,还请采纳。如仍有疑问,请回复留言或私信博主,以便获得更精准的帮助。

    1. 确保你的URDF文件是有效的。
    2. 检查URDF中的关节参数是否正确。
    3. 确保你的URDF文件中包含的节点和姿态数据与你的模型相符。
    4. 如果你的URDF文件中有子模型或组件,确保它们在GAZEBO中也被正确配置。
    5. 在调试时尽量使用快捷键,例如CTRL + C可以暂停当前执行的命令行,CTRL + F可以查看所有已执行的命令。
    6. 仔细检查URDF文件中的碰撞检测和约束设置,确保没有错误。
    7. 如果问题依然存在,可能需要重新编写或者调整URDF文件以解决这些问题。
    评论

报告相同问题?

问题事件

  • 创建了问题 2月12日