手动建一个ros四轮差速模型

 mkdir -p ~/catkin_ws/src

cd ~/catkin_ws/src

catkin_init_workspace

cd ~/catkin_ws

catkin_make

echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc

source ~/.bashrc

cd ~/catkin_ws/src

catkin_create_pkg diff_drive_bot gazebo_ros roscpp

<?xml version="1.0"?>

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

  <link name="chassis">

    <inertial>

      <mass value="10"/>

      <origin xyz="0 0 0" rpy="0 0 0"/>

      <inertia ixx="0.1" ixy="0" ixz="0" iyy="0.1" iyz="0" izz="0.1"/>

    </inertial>

    <visual>

      <geometry>

        <box size="0.5 0.3 0.2"/>

      </geometry>

      <material name="blue">

        <color rgba="0.2 0.2 1 1"/>

      </material>

    </visual>

    <collision>

      <geometry>

        <box size="0.5 0.3 0.2"/>

      </geometry>

    </collision>

  </link>

  <joint name="front_left_wheel_joint" type="revolute">

    <parent link="chassis"/>

    <child link="front_left_wheel"/>

    <origin xyz="0.1 0.15 0" rpy="0 0 0"/>

    <axis xyz="0 0 1"/>

    <limit lower="-1.57" upper="1.57" effort="10.0" velocity="10.0"/>

    <dynamics damping="1.0" friction="0.5"/>

  </joint>

  <joint name="front_right_wheel_joint" type="revolute">

    <parent link="chassis"/>

    <child link="front_right_wheel"/>

    <origin xyz="0.1 -0.15 0" rpy="0 0 0"/>

    <axis xyz="0 0 1"/>

    <limit lower="-1.57" upper="1.57" effort="10.0" velocity="10.0"/>

    <dynamics damping="1.0" friction="0.5"/>

  </joint>

  <joint name="rear_left_wheel_joint" type="revolute">

    <parent link="chassis"/>

    <child link="rear_left_wheel"/>

    <origin xyz="-0.1 0.15 0" rpy="0 0 0"/>

    <axis xyz="0 0 1"/>

    <limit lower="-1.57" upper="1.57" effort="10.0" velocity="10.0"/>

    <dynamics damping="1.0" friction="0.5"/>

  </joint>

  <joint name="rear_right_wheel_joint" type="revolute">

    <parent link="chassis"/>

    <child link="rear_right_wheel"/>

    <origin xyz="-0.1 -0.15 0" rpy="0 0 0"/>

    <axis xyz="0 0 1"/>

    <limit lower="-1.57" upper="1.57" effort="10.0" velocity="10.0"/>

<dynamics damping="1.0" friction="0.5"/>

</joint>

  <link name="front_left_wheel">

    <inertial>

      <mass value="2"/>

      <origin xyz="0 0 0" rpy="0 0 0"/>

      <inertia ixx="0.01" ixy="0" ixz="0" iyy="0.01" iyz="0" izz="0.01"/>

    </inertial>

<visual>

  <geometry>

    <cylinder length="0.05" radius="0.05"/>

  </geometry>

  <material name="blue">

    <color rgba="0.2 0.2 1 1"/>

  </material>

</visual>

<collision>

  <geometry>

    <cylinder length="0.05" radius="0.05"/>

  </geometry>

</collision>

</link>

  <link name="front_right_wheel">

    <inertial>

      <mass value="2"/>

      <origin xyz="0 0 0" rpy="0 0 0"/>

      <inertia ixx="0.01" ixy="0" ixz="0" iyy="0.01" iyz="0" izz="0.01"/>

    </inertial>

<visual>

  <geometry>

    <cylinder length="0.05" radius="0.05"/>

  </geometry>

  <material name="blue">

    <color rgba="0.2 0.2 1 1"/>

  </material>

</visual>

<collision>

  <geometry>

    <cylinder length="0.05" radius="0.05"/>

  </geometry>

</collision>

</link>

  <link name="rear_left_wheel">

    <inertial>

      <mass value="2"/>

      <origin xyz="0 0 0" rpy="0 0 0"/>

      <inertia ixx="0.01" ixy="0" ixz="0" iyy="0.01" iyz="0" izz="0.01"/>

    </inertial>

<visual>

  <geometry>

    <cylinder length="0.05" radius="0.05"/>

  </geometry>

  <material name="blue">

    <color rgba="0.2 0.2 1 1"/>

  </material>

</visual>

<collision>

  <geometry>

    <cylinder length="0.05" radius="0.05"/>

  </geometry>

</collision>

</link>

  <link name="rear_right_wheel">

    <inertial>

      <mass value="2"/>

      <origin xyz="0 0 0" rpy="0 0 0"/>

      <inertia ixx="0.01" ixy="0" ixz="0" iyy="0.01" iyz="0" izz="0.01"/>

    </inertial>

<visual>

  <geometry>

    <cylinder length="0.05" radius="0.05"/>

  </geometry>

  <material name="blue">

    <color rgba="0.2 0.2 1 1"/>

  </material>

</visual>

<collision>

  <geometry>

    <cylinder length="0.05" radius="0.05"/>

  </geometry>

</collision>

</link>

  <transmission name="front_left_wheel_transmission">

    <type>transmission_interface/SimpleTransmission</type>

<actuator name="front_left_motor">

<mechanicalReduction>1</mechanicalReduction>

</actuator>

<joint name="front_left_wheel_joint">

<hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>

</joint>

<motorTransmission>

<type>transmission_interface/SimpleMotorTransmission</type>

<timeConstant>0.01</timeConstant>

</motorTransmission>

<gearboxTransmission>

<type>transmission_interface/SimpleGearboxTransmission</type>

<gearRatio>1.0</gearRatio>

</gearboxTransmission>

<jointTransmission>

<type>transmission_interface/SimpleJointTransmission</type>

<jointRatio>1.0</jointRatio>

<zeroOffset>0.0</zeroOffset>

</jointTransmission>

</transmission>

  <transmission name="front_right_wheel_transmission">

    <type>transmission_interface/SimpleTransmission</type>

    <actuator name="front_right_motor">

      <mechanicalReduction>1</mechanicalReduction>

    </actuator>

    <joint name="front_right_wheel_joint">

      <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>

    </joint>

    <motorTransmission>

      <type>transmission_interface/SimpleMotorTransmission</type>

      <timeConstant>0.01</timeConstant>

    </motorTransmission>

    <gearboxTransmission>

      <type>transmission_interface/SimpleGearboxTransmission</type>

      <gearRatio>1.0</gearRatio>

    </gearboxTransmission>

    <jointTransmission>

      <type>transmission_interface/SimpleJointTransmission</type>

      <jointRatio>1.0</jointRatio>

      <zeroOffset>0.0</zeroOffset>

    </jointTransmission>

  </transmission>

  <transmission name="rear_left_wheel_transmission">

    <type>transmission_interface/SimpleTransmission</type>

    <actuator name="rear_left_motor">

      <mechanicalReduction>1</mechanicalReduction>

    </actuator>

    <joint name="rear_left_wheel_joint">

      <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>

    </joint>

    <motorTransmission>

      <type>transmission_interface/SimpleMotorTransmission</type>

      <timeConstant>0.01</timeConstant>

    </motorTransmission>

    <gearboxTransmission>

      <type>transmission_interface/SimpleGearboxTransmission</type>

      <gearRatio>1.0</gearRatio>

    </gearboxTransmission>

    <jointTransmission>

      <type>transmission_interface/SimpleJointTransmission</type>

      <jointRatio>1.0</jointRatio>

      <zeroOffset>0.0</zeroOffset>

    </jointTransmission>

  </transmission>

  <transmission name="rear_right_wheel_transmission">

    <type>transmission_interface/SimpleTransmission</type>

    <actuator name="rear_right_motor">

      <mechanicalReduction>1</mechanicalReduction>

    </actuator>

    <joint name="rear_right_wheel_joint">

      <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>

    </joint>

    <motorTransmission>

      <type>transmission_interface/SimpleMotorTransmission</type>

      <timeConstant>0.01</timeConstant>

    </motorTransmission>

    <gearboxTransmission>

      <type>transmission_interface/SimpleGearboxTransmission</type>

<gearRatio>1.0</gearRatio>

</gearboxTransmission>

<jointTransmission>

<type>transmission_interface/SimpleJointTransmission</type>

<jointRatio>1.0</jointRatio>

<zeroOffset>0.0</zeroOffset>

</jointTransmission>

</transmission>

</transmission>

</robot>

```

rosrun xacro xacro -o diff_drive.urdf diff_drive.urdf.xacro

<?xml version="1.0" ?>

<sdf version="1.5">

  <world name="default">

    <include>

      <uri>model://ground_plane</uri>

    </include>

    <include>

      <uri>model://diff_drive</uri>

      <pose>0 0 0.2 0 0 0</pose>

    </include>

  </world>

</sdf>

gazebo diff_drive.world

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值