gazebo小车模型创建详见另一篇博客
博客地址:gazebo小车模型(附带仿真环境) - zylyehuo - 博客园
参考链接
<robot name="my_car_move" xmlns:xacro="http://wiki.ros.org/xacro">
<!-- Transmission implementation: used to connect the controller and joints -->
<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>
<!-- Each drive wheel needs to be equipped with a transmission device -->
<xacro:joint_trans joint_name="left_wheel2base_link" />
<xacro:joint_trans joint_name="right_wheel2base_link" />
<!-- controller -->
<gazebo>
<plugin name="differential_drive_controller" filename="libgazebo_ros_diff_drive.so">
<rosDebugLevel>Debug</rosDebugLevel>
<publishWheelTF>true</publishWheelTF>
<robotNamespace>/</robotNamespace>
<publishTf>1</publishTf>
<publishWheelJointState>true</publishWheelJointState>
<alwaysOn>true</alwaysOn>
<updateRate>100.0</updateRate>
<legacyMode>true</legacyMode>
<leftJoint>left_wheel2base_link</leftJoint> <!-- left wheel -->
<rightJoint>right_wheel2base_link</rightJoint> <!-- right wheel -->
<wheelSeparation>${base_radius * 2}</wheelSeparation> <!-- Wheel spacing -->
<wheelDiameter>${wheel_radius * 2}</wheelDiameter> <!-- Wheel diameter -->
<broadcastTF>1</broadcastTF>
<wheelTorque>30</wheelTorque>
<wheelAcceleration>1.8</wheelAcceleration>
<commandTopic>cmd_vel</commandTopic> <!-- Motion Control Topics -->
<odometryFrame>odom</odometryFrame>
<odometryTopic>odom</odometryTopic> <!-- Odometer topic -->
<robotBaseFrame>base_footprint</robotBaseFrame> <!-- Root coordinate system -->
</plugin>
</gazebo>
</robot>
<robot name="car" xmlns:xacro="http://wiki.ros.org/xacro">
<xacro:include filename="inertial_matrix.xacro" />
<xacro:include filename="car_base.urdf.xacro" />
<xacro:include filename="car_camera.urdf.xacro" />
<xacro:include filename="car_laser.urdf.xacro" />
<!-- 以下为新添加的部分 -->
<!-- move control -->
<xacro:include filename="../gazebo/move.xacro" />
</robot>
roscore
source ./devel/setup.bash
roslaunch mycar environment.launch
rosrun teleop_twist_keyboard teleop_twist_keyboard.py _speed:=0.3 _turn:=0.5
解决方法
解决方法
(1)检查 src/mycar/urdf/xacro/car.urdf.xacro 中路径是否正确
(2)检查 src/mycar/urdf/gazebo/move.xacro 中 joint_name 等结点名称是否与之前定义的一致