2401_85628299 2024-11-06 15:02 采纳率: 0%
浏览 120
已结题

gazebo-rviz仿真问题

ros中gazebo仿真四轮小车,通过控制gazebo的小车可以移动,但rviz显示的小车不能动。

img

img

img


运行时出现的警告

[ INFO] [1730874047.841134099, 0.247000000]: Camera Plugin: Using the 'robotNamespace' param: '/'
[ INFO] [1730874047.861977505, 0.247000000]: Camera Plugin (ns = /)  <tf_prefix_>, set to ""
[ WARN] [1730874052.862843260, 0.247000000]: GazeboRosSkidSteerDrive Plugin (ns = //) missing <wheelSeparation>, defaults to value from robot_description: 0.400000
[ WARN] [1730874052.863369185, 0.247000000]: GazeboRosSkidSteerDrive Plugin (ns = //) missing <commandTopic>, defaults to "cmd_vel"
[ WARN] [1730874052.863446889, 0.247000000]: GazeboRosSkidSteerDrive Plugin (ns = //) missing <updateRate>, defaults to 100.000000
[ WARN] [1730874052.863614396, 0.247000000]: GazeboRosSkidSteerDrive Plugin (ns = //) missing <covariance_x>, defaults to 0.000100
[ WARN] [1730874052.864551390, 0.247000000]: GazeboRosSkidSteerDrive Plugin (ns = //) missing <covariance_y>, defaults to 0.000100
[ WARN] [1730874052.864848589, 0.247000000]: GazeboRosSkidSteerDrive Plugin (ns = //) missing <covariance_yaw>, defaults to 0.010000
[ INFO] [1730874052.866775918, 0.247000000]: Starting GazeboRosSkidSteerDrive Plugin (ns = //)
context mismatch in svga_surface_destroy
context mismatch in svga_surface_destroy
^[


launch文件

  <!-- move_xc.launch -->
<launch>
  <param name="robot_description" command="$(find xacro)/xacro $(find xc)/urdf/xacro/zh_xc.urdf.xacro" />
  <include file="$(find gazebo_ros)/launch/empty_world.launch" />
  <!-- <arg name="world_name" value="$(find xc)/worlds/npg_world.world" />
  </include> -->
  <node
    name="tf_footprint_base"
    pkg="tf"
    type="static_transform_publisher"
    args="0 0 0 0 0 0 base_link base_footprint 10000" />
  <!-- <node pkg="tf" type="static_transform_publisher" name="odom_to_base_footprint" args="0.0 0.0 0.0 0.0 0.0 0.0 base_footprint odom 40" /> -->
  <node
    name="spawn_model"
    pkg="gazebo_ros"
    type="spawn_model"
    args="-urdf -model cc -param robot_description"
    output="screen" />
  <node
    name="fake_joint_calibration"
    pkg="rostopic"
    type="rostopic"
    args="pub /calibrated std_msgs/Bool true" />
  <include file="$(find xc)/launch/rviz_xacro.launch" />
</launch>

<!-- rviz_xacro.launch -->
<launch>
    <param name="robot_description" command="$(find xacro)/xacro $(find xc)/urdf/xacro/zh_xc.urdf.xacro" />
    <node pkg="tf2_ros" type="static_transform_publisher" name="static_transform_publisher" args="0 0 0 -1.57 0 -1.57 /zld_link /zld_depth" />
    <!-- <node pkg="tf" type="static_transform_publisher" name="odom_to_base_footprint" args="0.0 0.0 0.0 0.0 0.0 0.0 odom base_footprint 10000" /> -->
    <node pkg="rviz" type="rviz" name="rviz" args="-d $(find xc)/config/xacro_xc.rviz" />
    <node pkg="joint_state_publisher" type="joint_state_publisher" name="joint_state_publisher" output="screen" >
        <!-- <param name="rate" value="10000" /> -->
    </node>
    <node pkg="robot_state_publisher" type="robot_state_publisher" name="robot_state_publisher" output="screen" />
        <!-- <param name="rate" value="40" /> -->
    <!-- <node pkg="joint_state_publisher_gui" type="joint_state_publisher_gui" name="joint_state_publisher_gui" output="screen" /> -->
</launch>

zh_xc.urdf.xacro文件

<robot name="cc" xmlns:xacro="http://wiki.ros.org/xacro">

    <xacro:include filename="head.urdf.xacro" />
    <xacro:include filename="xc.urdf.xacro" />
    <xacro:include filename="drive.urdf.xacro" />
    <xacro:include filename="laser.urdf.xacro" />
    <!-- <xacro:include filename="camera.urdf.xacro" /> -->
    <xacro:include filename="kinect.urdf.xacro" />

</robot>

drive.xacro四轮驱动文件


```xml

<robot name="cc" xmlns:xacro="http://wiki.ros.org/xacro">
  
  <xacro:macro name="joint_trans" params="joint_name">
        <!-- Transmission is important to link the joints and the controller -->
        <transmission name="${joint_name}_trans">
            <type>transmission_interface/SimpleTransmission</type>
            <joint name="${joint_name}">
                <hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface>
            </joint>
            <actuator name="${joint_name}_motor">
                <hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface>
                <mechanicalReduction>1</mechanicalReduction>
            </actuator>
        </transmission>
  </xacro:macro>
 
  <xacro:joint_trans joint_name="left_joint1" />
  <xacro:joint_trans joint_name="right_joint1" />
  <xacro:joint_trans joint_name="left_joint2" />
  <xacro:joint_trans joint_name="right_joint2" />

  <gazebo>
    <plugin name="skid_steer_drive_controller" filename="libgazebo_ros_skid_steer_drive.so">
      <rosDebugLevel>Debug</rosDebugLevel>
      <publishWheelTF>true</publishWheelTF>
      <publishTF>1</publishTF>
      <publishWheelJointState>true</publishWheelJointState>
      <alwaysOn>true</alwaysOn>
      <legacyMode>true</legacyMode>
      <updateRate>100</updateRate>
      <robotNamespace>/</robotNamespace>

      <leftFrontJoint>left_joint1</leftFrontJoint>
      <rightFrontJoint>right_joint1</rightFrontJoint>
      <leftRearJoint>left_joint2</leftRearJoint>
      <rightRearJoint>right_joint2</rightRearJoint>
 
      <wheelseparation>0.4</wheelseparation>
   
      <wheelDiameter>0.076248659 * 2</wheelDiameter>
 
      <robotBaseFrame>base_footprint</robotBaseFrame>

      <wheelTorque>30</wheelTorque>
      <wheelAcceleration>1.8</wheelAcceleration>
      <odometryFrame>odom</odometryFrame>
      <odometryTopic>odom</odometryTopic>
      <torque>20</torque>
      <topicName>cmd_vel</topicName>
      <broadcastTF>1</broadcastTF>
    </plugin>
  </gazebo>
</robot>

xc.urdf.xacro小车模型文件




```xml
<robot name="cc" xmlns:xacro="http://wiki.ros.org/xacro">

  <xacro:property name="PI" value="3.1415927" />
  
  <link name="base_footprint">
    <visual>
      <origin
        xyz="0 0 0"
        rpy="0 0 0" />
      <geometry>
        <sphere radius="0.0001" /> 
      </geometry>
      <material
        name="">
        <color
          rgba="1 1 1 1" />
      </material>
    </visual>
    <!-- <collision>
      <origin
        xyz="0 0 0"
        rpy="0 0 0" />
      <geometry>
        <sphere radius="0.0001" /> 
      </geometry>
    </collision>
    <xacro:sphere_inertial_matrix m="0.1" r="0.0001" /> -->
  </link>
  
  <link
    name="base_link">
    <inertial>
      <origin
        xyz="0.0107038304108331 -9.21878910686191E-06 0.0113664946916399"
        rpy="0 0 0" />
      <mass
        value="0.803221963178587" />
      <inertia
        ixx="0.000921919607521183"
        ixy="3.04842793729526E-07"
        ixz="-1.78869535658467E-19"
        iyy="0.00198838380320808"
        iyz="4.59879333354981E-20"
        izz="0.00268045345835692" />
    </inertial>
    <visual>
      <origin
        xyz="0 0 0"
        rpy="0 0 0" />
      <geometry>
        <mesh
          filename="package://xc/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://xc/meshes/base_link.STL" />
      </geometry>
    </collision>
  </link>

  <joint
    name="footprint_joint"
    type="fixed">
    <origin
      xyz="0 0 0.07624851583"
      rpy="0 0 0" />
    <parent
      link="base_footprint" />
    <child
      link="base_link" />
  </joint>

  <link
    name="left_link1">
    <inertial>
      <origin
        xyz="-2.18222221404218E-08 -0.000122396014999582 -5.13928899371213E-06"
        rpy="0 0 0" />
      <mass
        value="0.219116584132791" />
      <inertia
        ixx="0.000104469948261244"
        ixy="1.03227547098209E-07"
        ixz="-2.49612383770168E-09"
        iyy="0.00018514070274364"
        iyz="-4.41184162701321E-10"
        izz="0.000103886645938544" />
    </inertial>
    <visual>
      <origin
        xyz="0 0 0"
        rpy="0 0 0" />
      <geometry>
        <mesh
          filename="package://xc/meshes/left_link1.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://xc/meshes/left_link1.STL" />
      </geometry>
    </collision>
  </link>
  <joint
    name="left_joint1"
    type="continuous">
    <origin
      xyz="0.159499999999995 0.2311002 0"
      rpy="0 0 0" />
    <parent
      link="base_link" />
    <child
      link="left_link1" />
    <axis
      xyz="0 1 0" />
  </joint>

  <link
    name="left_link2">
    <inertial>
      <origin
        xyz="-1.08117837531452E-05 -9.77409818574138E-05 5.64019781035541E-05"
        rpy="0 0 0" />
      <mass
        value="0.219116583211867" />
      <inertia
        ixx="0.000103892304241539"
        ixy="1.00311856391118E-08"
        ixz="5.68877137364784E-08"
        iyy="0.000185140830477195"
        iyz="-9.92306110072044E-10"
        izz="0.000104464424804438" />
    </inertial>
    <visual>
      <origin
        xyz="0 0 0"
        rpy="0 0 0" />
      <geometry>
        <mesh
          filename="package://xc/meshes/left_link2.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://xc/meshes/left_link2.STL" />
      </geometry>
    </collision>
  </link>
  <joint
    name="left_joint2"
    type="continuous">
    <origin
      xyz="-0.159500000000005 0.2311002 0"
      rpy="0 0 0" />
    <parent
      link="base_link" />
    <child
      link="left_link2" />
    <axis
      xyz="0 1 0" />
  </joint>
  <link
    name="right_link1">
    <inertial>
      <origin
        xyz="-1.08119174052623E-05 -9.77410244195343E-05 5.64017910382464E-05"
        rpy="0 0 0" />
      <mass
        value="0.21911658257716" />
      <inertia
        ixx="0.000103892303501767"
        ixy="1.00314673056423E-08"
        ixz="5.68873618044407E-08"
        iyy="0.000185140829418823"
        iyz="-9.92719717175133E-10"
        izz="0.000104464424466105" />
    </inertial>
    <visual>
      <origin
        xyz="0 0 0"
        rpy="0 0 0" />
      <geometry>
        <mesh
          filename="package://xc/meshes/right_link1.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://xc/meshes/right_link1.STL" />
      </geometry>
    </collision>
  </link>
  <joint
    name="right_joint1"
    type="continuous">
    <origin
      xyz="0.159500000000005 -0.2311002 0"
      rpy="0 0 0" />
    <parent
      link="base_link" />
    <child
      link="right_link1" />
    <axis
      xyz="0 1 0" />
  </joint>
  <link
    name="right_link2">
    <inertial>
      <origin
        xyz="2.56390686681832E-06 -0.000122395883453835 4.45368086584436E-06"
        rpy="0 0 0" />
      <mass
        value="0.219116584605283" />
      <inertia
        ixx="0.000104325014944979"
        ixy="-8.94702350850396E-08"
        ixz="-2.52180091869572E-07"
        iyy="0.000185141011390518"
        iyz="5.15041678062223E-08"
        izz="0.000104031910984046" />
    </inertial>
    <visual>
      <origin
        xyz="0 0 0"
        rpy="0 0 0" />
      <geometry>
        <mesh
          filename="package://xc/meshes/right_link2.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://xc/meshes/right_link2.STL" />
      </geometry>
    </collision>
  </link>
  <joint
    name="right_joint2"
    type="continuous">
    <origin
      xyz="-0.159499999999995 -0.2311002 0"
      rpy="0 0 0" />
    <parent
      link="base_link" />
    <child
      link="right_link2" />
    <axis
      xyz="0 1 0" />
  </joint>


  <link
    name="ld_link">
    <inertial>
      <origin
        xyz="0 0 -3.46944695195361E-18"
        rpy="0 0 0" />
      <mass
        value="0.502654824574367" />
      <inertia
        ixx="0.000305781684949407"
        ixy="0"
        ixz="6.26762360421437E-37"
        iyy="0.000305781684949407"
        iyz="-9.71364416034432E-37"
        izz="0.000402123859659494" />
    </inertial>
    <visual>
      <origin
        xyz="0 0 0"
        rpy="0 0 0" />
      <geometry>
        <mesh
          filename="package://xc/meshes/ld_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://xc/meshes/ld_link.STL" />
      </geometry>
    </collision>
  </link>
  <joint
    name="ld_joint"
    type="fixed">
    <origin
      xyz="0.2055 0 0.0750000000000046"
      rpy="0 0 0" />
    <parent
      link="base_link" />
    <child
      link="ld_link" />
    <axis
      xyz="0 0 0" />
  </joint>

  <link
    name="zld_link">
    <visual>
      <origin
        xyz="0 0 0"
        rpy="0 0 0" />
      <geometry>
        <sphere radius="0.02" />
      </geometry>
      <material
        name="">
        <color
          rgba="0.2 0.5 0.8 0.2" />
      </material>
    </visual>
    <collision>
      <origin
        xyz="0 0 0"
        rpy="0 0 0" />
      <geometry>
        <sphere radius="0.02" />
      </geometry>
    </collision>
    <xacro:sphere_inertial_matrix m="0.1" r="0.02" />
  </link>
  <joint
    name="zld_joint"
    type="fixed">
    <origin
      xyz="0 0 0.2"
      rpy="0 0 0" />
    <parent
      link="base_link" />
    <child
      link="zld_link" />
  </joint>
</robot>

  • 写回答

23条回答 默认 最新

  • 专家-皆知 2024-11-06 15:14
    关注
    获得0.30元问题酬金

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

    您在UBUNTU系统上尝试使用GAZEBO RVIZ进行四轮小车的仿真,并且发现当控制器按下并松开按钮后,模拟车辆无法正常移动到目标位置。这可能是由于RVIZ中的控制功能未正确实现或程序设置问题导致的。

    首先,确保您的ROS环境已经安装了所需的库和包,包括GAZEBO、RVIZ和OPENCV等。如果上述步骤都已完成,那么可能是因为RVIZ中没有正确处理您的请求或者配置文件错误。以下是一些可能的问题解决方法:

    方法一:检查RVIZ设置

    1. 检查ROS

      • 确保ROS版本与您的操作系统匹配。
      • 检查RVIZ是否已启用(ROSRUN RVIZ RVIZ)。
      • 检查ROS是否连接到正确的服务端点(ROSCOREROSCPP命令行工具)。
    2. 查看ROS启动脚本

      • 如果ROS没有启动,请执行以下命令来启动它:
        ROS START
        
    3. 检查ROS环境变量

      • 检查ROS环境变量是否正确设置为-D选项:
        ROS_INFO("ROS VERSION: %S" % ROSPY.GET_PARAM("~VERSION"));
        ROS_INFO("ROS NODE NAME: %S" % ROSPY.GET_NODE_NAME());
        
    4. 查看ROS资源管理器

      • 打开ROS资源管理器(通常位于 /OPT/ROS/KINETIC/LIBEXEC/ROS-REPOSITORY/USR/SHARE/ROS/REPOSITORIES),然后查找~/.ROSENV文件夹。
    5. 重启ROS

      • 使用SUDO键打开终端,并输入ROS RESET以重置ROS。

    方法二:尝试重新加载视图引擎

    1. 关闭所有视图引擎

      • ROSCORE命令行工具会列出所有的视图引擎,确认是否有一个正在运行的视图引擎。
      • 在每个视图引擎下,运行以下命令以停止它:
        ROSLAUNCH --LAUNCH <VIEW_ENGINE> --NO-START --NO-STOP
        
    2. 手动运行视图引擎

      • 确保所有的视图引擎都在运行状态,例如ROSREMAP命令将视图引擎切换到当前视图。
      • 在指定视图引擎的~/.ROSENV文件夹中,找到名为RVIZ的文件,并将其替换为一个不包含RVIZ前缀的新文件名。
    3. 尝试重新编译视图引擎

      • 使用MAKE CLEAN命令清除编译过程中产生的残留文件,然后再次编译视图引擎。
    4. 重新启动ROS

      • 重启ROS,确保所有视图引擎都被重新激活。
    5. 检查ROS库

      • 如果ROS库仍然有问题,比如缺少必要的依赖项,尝试从官方网站下载并更新ROS库。
    6. 检查ROS环境变量

      • 如果需要更改ROS环境变量,确保它们已经被正确地添加到~/.BASHRC或其他类似的地方。

    注意事项:

    • 在尝试任何重启操作之前,确保已经完全断开了ROS网络连接,否则可能会引入新的安全风险。
    • 如果以上方法都无法解决问题,可能需要考虑更换ROS发行版或者使用不同的ROS发行版。

    希望这些建议能帮助您解决这个问题!

    评论

报告相同问题?

问题事件

  • 系统已结题 11月14日
  • 修改了问题 11月8日
  • 创建了问题 11月6日