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



运行时出现的警告
[ 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>