0

当我在 rviz 中生成模型时,链接部分看起来像是随机定位的。我们可以控制机器人模型移动,但是以一种非常奇怪的方式。下面的代码是我用来生成模型的 urdf 文件。rviz模型

<?xml version="1.0"?>
<robot name="fyp_new" xmlns:xacro="http://ros.org/wiki/xacro">

  <!-- Model Dimensions -->
  <xacro:property name="pi" value="3.1415" />
  <xacro:property name="body_length" value="0.55" />
  <xacro:property name="body_width" value="0.16" />
  <xacro:property name="body_height" value="0.08" />
  <xacro:property name="shoulder_length" value="0.07" />
  <xacro:property name="shoulder_width" value="0.09" />
  <xacro:property name="shoulder_height" value="0.03" />
  <xacro:property name="thigh_length" value="0.03" />
  <xacro:property name="thigh_width" value="0.07" />
  <xacro:property name="thigh_height" value="0.21" />
  <xacro:property name="shank_length" value="0.03" />
  <xacro:property name="shank_width" value="0.05" />
  <xacro:property name="shank_height" value="0.13" />
  <xacro:property name="damping_value" value="10" />
  <xacro:property name="friction_value" value="0.1" />


  <!-- Import Rviz colors -->
  <!--xacro:include filename="$(find fyp_new)/urdf/materials.xacro" /-->
  <xacro:include filename="$(find fyp_new)/urdf/materials.xacro" />

  <!-- Inertias -->
  <xacro:macro name="box_inertial" params="mass length width height">
    <inertial>
      <mass value="${mass}" />
       <inertia ixx="${mass*(height*height+length*length)/12.0}" ixy="0.0" ixz="0.0" iyy="${mass*(width*width+length*length)/12.0}" iyz="0.0" izz="${mass*(width*width+height*height)/12.0}" />
    </inertial>
  </xacro:macro>


  <!-- Main Body -->
 <!-- <link name="dummy_link">
    <visual>
      <geometry>
        <box size="0.01 0.01 0.01"/>
      </geometry>
    </visual>
    <collision>
      <geometry>
        <box size="0.01 0.01 0.01"/>
      </geometry>
    </collision>  
    <inertial>
      <mass value="0.01" />
      <inertia ixx="0.00001" ixy="0.0" ixz="0.0" iyy="0.00001" iyz="0.0" izz="0.00001" />
    </inertial>
  </link>-->
  <link name="base_inertia">
    <inertial>
       <mass value="3" />
      <inertia ixx="7.250" ixy="0.0" ixz="0.0" iyy="8.5" iyz="0.0" izz="3.25" />
    </inertial>
  </link>

  <link name="base_link">
    <visual>
      <origin xyz="0 0 0.2416"/>
      <geometry>
       <mesh filename="package://fyp_new/meshes/body/body.stl" scale="0.001 0.001 0.001"/>
      </geometry>
      <material name="black"/>
    </visual>
    <collision>
      <origin xyz="0 0 0.2416"/>
      <geometry>
        <box size="0.16 0.16 0.08"/>
      </geometry>
    </collision>  
  </link> 

  <joint name="base_link_to_base_inertia" type="fixed">
    <parent link="base_link"/>
    <child link="base_inertia"/>
    <origin xyz="0.0 0.0 0.2416" rpy="0 0 0"/>
  </joint>

  <gazebo reference="base_link">
    <mu1>100000.0</mu1>
    <mu2>100000.0</mu2>
    <material>Gazebo/Black</material>
  </gazebo>



  <!--Left Front Leg-->
  <link name="shoulder_link_lf">
    <visual>
      <origin xyz="0.38 0.1415 0.2616" rpy="0 0 0" />
      <geometry>
       <mesh filename="package://fyp_new/meshes/leg/shoulder.stl" scale="0.001 0.001 0.001"/>
      </geometry>
    </visual>
    <collision>
      <origin xyz="0.38 0.1415 0.2616" rpy="0 0 0" />
      <geometry>
        <box size="0.07 0.09 0.03"/>
      </geometry>
      <material name="black"/>
    </collision>
    <inertial>
      <mass value="0.0625" />
      <inertia ixx="0.00003020833" ixy="0.0" ixz="0.0" iyy="0.00006770833" iyz="0.0" izz="0.000046875" />
    </inertial>
    <!--<xacro:box_inertial mass="${0.0625}" length="0.07" width="0.09" height="0.03"/>-->
  </link>

  <joint name="shoulder_joint_lf" type="revolute">
    <limit effort="100.0" lower="-1.57075" upper="1.57075" velocity="0.5"/>
    <parent link="base_link"/>
    <child link="shoulder_link_lf"/>
    <origin xyz="0.38 0.1415 0.2616" rpy="0 0 0" />
    <axis xyz="1 0 0"/>
    <dynamics damping="10" friction="0.1"/>
  </joint>
  <gazebo reference="shoulder_link_lf">
    <mu1>100000.0</mu1>
    <mu2>100000.0</mu2>
    <material>Gazebo/Black</material>
  </gazebo>


  <link name="thigh_link_lf">
    <visual>
      <origin xyz="0.2565 0.16 0.1131" rpy="0.0 0.785 0.0"/>
      <geometry>
       <mesh filename="package://fyp_new/meshes/leg/thigh.stl" scale="0.001 0.001 0.001"/>
      </geometry>
      <material name="black"/>
    </visual>
    <collision>
      <origin xyz="0.2565 0.16 0.1131" rpy="0.0 0.785 0.0"/>
      <geometry>
        <box size="0.03 0.07 0.21"/>
      </geometry>
    </collision>
    <inertial>
      <mass value="0.125" />
      <inertia ixx="0.000046875" ixy="0.0" ixz="0.0" iyy="0.00006041666" iyz="0.0" izz="0.00051041666" />
    </inertial>
   <!-- <xacro:box_inertial mass="${0.125}" length="0.03" width="0.07" height="0.21"/>-->
  </link>

  <joint name="elbow_joint_lf" type="revolute">
    <limit effort="100.0" lower="-1.57075" upper="1.57075" velocity="0.5"/>
    <parent link="shoulder_link_lf"/>
    <child link="thigh_link_lf"/>
    <origin xyz="0.2565 0.16 0.1131" rpy="0.0 0.0 0.0"/>
    <axis xyz="0 1 0"/>
    <dynamics damping="10" friction="0.1"/>
  </joint>
  <gazebo reference="thigh_link_lf">
    <mu1>100000.0</mu1>
    <mu2>100000.0</mu2>
    <material>Gazebo/Black</material>
  </gazebo>


  <link name="shank_link_lf">
    <visual>
      <origin xyz="0.3696 0.17 0.0" rpy="0.0 5.5 0.0"/>
      <geometry>
       <mesh filename="package://fyp_new/meshes/leg/shank.stl" scale="0.001 0.001 0.001"/>
      </geometry>
      <material name="black"/>
    </visual>
    <collision>
      <origin xyz="0.3696 0.17 0.0" rpy="0.0 5.5 0.0"/>
      <geometry>
        <box size="0.03 0.05 0.13"/>
      </geometry>
    </collision>
     <inertial>
      <mass value="0.125" />
      <inertia ixx="0.00018541666" ixy="0.0" ixz="0.0" iyy="0.00003541666" iyz="0.0" izz="0.00020208333" />
    </inertial>
   <!--<xacro:box_inertial mass="${0.125}" length="0.03" width="0.05" height="0.13"/>-->
  </link>

  <joint name="knee_joint_lf" type="revolute">
    <limit effort="100.0" lower="-1.57075" upper="1.57075" velocity="0.5"/>
    <origin xyz="0.3696 0.17 0.0"/>
    <axis xyz="0 1 0"/>
    <parent link="thigh_link_lf"/>
    <child link="shank_link_lf"/>
    <dynamics damping="10" friction="0.1"/>
  </joint>
  <gazebo reference="shank_link_lf">
    <mu1>100000.0</mu1>
    <mu2>100000.0</mu2>
    <material>Gazebo/Black</material>
  </gazebo>




 <!--Right Front Leg-->
  <link name="shoulder_link_rf">
    <visual>
      <origin xyz="0.38 -0.064 0.2616"/>
      <geometry>
       <mesh filename="package://fyp_new/meshes/leg/shoulder.stl" scale="0.001 0.001 0.001"/>
      </geometry>
      <material name="black"/>
    </visual>
    <collision>
      <origin xyz="0.38 -0.064 0.2616"/>
      <geometry>
        <box size="0.07 0.09 0.03"/>
      </geometry>
    </collision>
    <inertial>
      <mass value="0.0625" />
      <inertia ixx="0.00003020833" ixy="0.0" ixz="0.0" iyy="0.00006770833" iyz="0.0" izz="0.000046875" />
    </inertial>
   <!-- <xacro:box_inertial mass="${0.0625}" length="0.07" width="0.09" height="0.03"/>-->
  </link>

  <joint name="shoulder_joint_rf" type="revolute">
    <limit effort="100.0" lower="-1.57075" upper="1.57075" velocity="0.5"/>
    <origin xyz="0.38 -0.064 0.2616"/>
    <axis xyz="1 0 0"/>
    <parent link="base_link"/>
    <child link="shoulder_link_rf"/>
    <dynamics damping="10" friction="0.1"/>
  </joint>
  <gazebo reference="shoulder_link_rf">
    <mu1>100000.0</mu1>
    <mu2>100000.0</mu2>
    <material>Gazebo/Black</material>
  </gazebo>

  <link name="thigh_link_rf">
    <visual>    
      <origin xyz="0.2565 -0.064 0.1131" rpy="0.0 0.785 0.0"/>
      <geometry>
       <mesh filename="package://fyp_new/meshes/leg/thigh.stl" scale="0.001 0.001 0.001"/>
      </geometry>
      <material name="black"/>
    </visual>
    <collision>
      <origin xyz="0.2565 -0.064 0.1131" rpy="0.0 0.785 0.0"/>
      <geometry>
        <box size="0.03 0.07 0.21"/>
      </geometry>
    </collision>
     <inertial>
      <mass value="0.125" />
      <inertia ixx="0.000046875" ixy="0.0" ixz="0.0" iyy="0.00006041666" iyz="0.0" izz="0.00051041666" />
    </inertial>
    <!--<xacro:box_inertial mass="${0.125}" length="0.03" width="0.07" height="0.21"/>-->
  </link>

  <joint name="elbow_joint_rf" type="revolute">
    <limit effort="100.0" lower="-1.57075" upper="1.57075" velocity="0.5"/>
    <parent link="shoulder_link_rf"/>
    <child link="thigh_link_rf"/>
    <origin xyz="0.2565 -0.064 0.1131" rpy="0.0 0.0 0.0"/>
    <axis xyz="0 1 0"/>
    <dynamics damping="10" friction="0.1"/>
  </joint>
  <gazebo reference="thigh_link_rf">
    <mu1>100000.0</mu1>
    <mu2>100000.0</mu2>
    <material>Gazebo/Black</material>
  </gazebo>

  <link name="shank_link_rf">
    <visual>
      <origin xyz="0.3696 -0.06 0.0" rpy="0.0 5.5 0.0"/>
      <geometry>
       <mesh filename="package://fyp_new/meshes/leg/shank.stl" scale="0.001 0.001 0.001"/>
      </geometry>
      <material name="black"/>
    </visual>
    <collision>
      <origin xyz="0.3696 -0.06 0.0" rpy="0.0 5.5 0.0"/>
      <geometry>
        <box size="0.03 0.05 0.13"/>
      </geometry>
    </collision>
    <inertial>
      <mass value="0.125" />
      <inertia ixx="0.00018541666" ixy="0.0" ixz="0.0" iyy="0.00003541666" iyz="0.0" izz="0.00020208333" />
    </inertial>
    <!--<xacro:box_inertial mass="${0.125}" length="0.03" width="0.05" height="0.13"/>-->
  </link>

  <joint name="knee_joint_rf" type="revolute">
    <limit effort="100.0" lower="-1.57075" upper="1.57075" velocity="0.5"/>
    <origin xyz="0.3696 -0.06 0.0"/>
    <axis xyz="0 1 0"/>
    <parent link="thigh_link_rf"/>
    <child link="shank_link_rf"/>
    <dynamics damping="10" friction="0.1"/>
  </joint>
  <gazebo reference="shank_link_rf">
    <mu1>100000.0</mu1>
    <mu2>100000.0</mu2>
    <material>Gazebo/Black</material>
  </gazebo>



  <!--Left Back Leg-->
  <link name="shoulder_link_lb">
    <visual>
      <origin xyz="0.06 0.1415 0.2616"/>
      <geometry>
       <mesh filename="package://fyp_new/meshes/leg/shoulder.stl" scale="0.001 0.001 0.001"/>
      </geometry>
    </visual>
    <collision>
      <origin xyz="0.06 0.1415 0.2616"/>
      <geometry>
        <box size="0.07 0.09 0.03"/>
      </geometry>
      <material name="black"/>
    </collision>
    <inertial>
      <mass value="0.0625" />
      <inertia ixx="0.00003020833" ixy="0.0" ixz="0.0" iyy="0.00006770833" iyz="0.0" izz="0.000046875" />
    </inertial>
   <!--<xacro:box_inertial mass="${0.0625}" length="0.07" width="0.09" height="0.03"/>-->
  </link>

  <joint name="shoulder_joint_lb" type="revolute">
    <limit effort="100.0" lower="-1.57075" upper="1.57075" velocity="0.5"/>
    <parent link="base_link"/>
    <child link="shoulder_link_lb"/>
    <origin xyz="0.38 0.1415 0.2616"/>
    <axis xyz="1 0 0"/>
    <dynamics damping="10" friction="0.1"/>
  </joint>
  <gazebo reference="shoulder_link_lb">
    <mu1>100000.0</mu1>
    <mu2>100000.0</mu2>
    <material>Gazebo/Black</material>
  </gazebo>


  <link name="thigh_link_lb">
    <visual>
      <origin xyz="0.2085 0.16 0.0919" rpy="0.0 5.5 0.0"/>
      <geometry>
       <mesh filename="package://fyp_new/meshes/leg/thigh.stl" scale="0.001 0.001 0.001"/>
      </geometry>
      <material name="black"/>
    </visual>
    <collision>
      <origin xyz="0.2085 0.16 0.0919" rpy="0.0 5.5 0.0"/>
      <geometry>
        <box size="0.03 0.07 0.21"/>
      </geometry>
    </collision>
     <inertial>
      <mass value="0.125" />
      <inertia ixx="0.000046875" ixy="0.0" ixz="0.0" iyy="0.00006041666" iyz="0.0" izz="0.00051041666" />
    </inertial>
    <!--<xacro:box_inertial mass="${0.125}" length="0.03" width="0.07" height="0.21"/>-->
  </link>

  <joint name="elbow_joint_lb" type="revolute">
    <limit effort="100.0" lower="-1.57075" upper="1.57075" velocity="0.5"/>
    <parent link="shoulder_link_lb"/>
    <child link="thigh_link_lb"/>
    <origin xyz="0.2085 0.16 0.0919" rpy="0.0 0.0 0.0"/>
    <axis xyz="0 1 0"/>
    <dynamics damping="10" friction="0.1"/>
  </joint>
  <gazebo reference="thigh_link_lb">
    <mu1>100000.0</mu1>
    <mu2>100000.0</mu2>
    <material>Gazebo/Black</material>
  </gazebo>


  <link name="shank_link_lb">
    <visual>
      <origin xyz="0.0954 0.17 0.0212" rpy="0.0 0.785 0.0"/>
      <geometry>
       <mesh filename="package://fyp_new/meshes/leg/shank.stl" scale="0.001 0.001 0.001"/>
      </geometry>
      <material name="black"/>
    </visual>
    <collision>
      <origin xyz="0.0954 0.17 0.0212" rpy="0.0 0.785 0.0"/>
      <geometry>
        <box size="0.03 0.05 0.13"/>
      </geometry>
    </collision>
    <inertial>
      <mass value="0.125" />
      <inertia ixx="0.00018541666" ixy="0.0" ixz="0.0" iyy="0.00003541666" iyz="0.0" izz="0.00020208333" />
    </inertial>
    <!--<xacro:box_inertial mass="${0.125}" length="0.03" width="0.05" height="0.13"/>-->
  </link>

  <joint name="knee_joint_lb" type="revolute">
    <limit effort="100.0" lower="-1.57075" upper="1.57075" velocity="0.5"/>
    <origin xyz="0.0954 0.17 0.0212"/>
    <axis xyz="0 1 0"/>
    <parent link="thigh_link_lb"/>
    <child link="shank_link_lb"/>
    <dynamics damping="10" friction="0.1"/>
  </joint>
  <gazebo reference="shank_link_lb">
    <mu1>100000.0</mu1>
    <mu2>100000.0</mu2>
    <material>Gazebo/Black</material>
  </gazebo>



 <!--Right Back Leg-->
  <link name="shoulder_link_rb">
    <visual>
      <origin xyz="0.06 -0.064 0.2616"/>
      <geometry>
       <mesh filename="package://fyp_new/meshes/leg/shoulder.stl" scale="0.001 0.001 0.001"/>
      </geometry>
      <material name="black"/>
    </visual>
    <collision>
      <geometry>
        <box size="0.07 0.09 0.03"/>
      </geometry>
    </collision>
    <inertial>
      <mass value="0.0625" />
      <inertia ixx="0.00003020833" ixy="0.0" ixz="0.0" iyy="0.00006770833" iyz="0.0" izz="0.000046875" />
    </inertial>
    <!--<xacro:box_inertial mass="${0.0625}" length="0.07" width="0.09" height="0.03"/>-->
  </link>

  <joint name="shoulder_joint_rb" type="revolute">
    <limit effort="100.0" lower="-1.57075" upper="1.57075" velocity="0.5"/>
    <origin xyz="0.06 -0.064 0.2616"/>
    <axis xyz="1 0 0"/>
    <parent link="base_link"/>
    <child link="shoulder_link_rb"/>
    <dynamics damping="10" friction="0.1"/>
  </joint>
  <gazebo reference="shoulder_link_rb">
    <mu1>100000.0</mu1>
    <mu2>100000.0</mu2>
    <material>Gazebo/Black</material>
  </gazebo>

  <link name="thigh_link_rb">
    <visual>    
      <origin xyz="0.2085 -0.064 0.0919" rpy="0.0 5.5 0.0"/>
      <geometry>
       <mesh filename="package://fyp_new/meshes/leg/thigh.stl" scale="0.001 0.001 0.001"/>
      </geometry>
      <material name="black"/>
    </visual>
    <collision>
      <origin xyz="0.2085 -0.064 0.0919" rpy="0.0 5.5 0.0"/>
      <geometry>
        <box size="0.03 0.07 0.21"/>
      </geometry>
    </collision>
     <inertial>
      <mass value="0.125" />
      <inertia ixx="0.000046875" ixy="0.0" ixz="0.0" iyy="0.00006041666" iyz="0.0" izz="0.00051041666" />
    </inertial>
    <!--<xacro:box_inertial mass="${0.125}" length="0.03" width="0.07" height="0.21"/>-->
  </link>

  <joint name="elbow_joint_rb" type="revolute">
    <limit effort="100.0" lower="-1.57075" upper="1.57075" velocity="0.5"/>
    <parent link="shoulder_link_rb"/>
    <child link="thigh_link_rb"/>
    <origin xyz="0.2085 -0.064 0.0919" rpy="0.0 0.0 0.0"/>
    <axis xyz="0 1 0"/>
    <dynamics damping="10" friction="0.1"/>
  </joint>
  <gazebo reference="thigh_link_rb">
    <mu1>100000.0</mu1>
    <mu2>100000.0</mu2>
    <material>Gazebo/Black</material>
  </gazebo>

  <link name="shank_link_rb">
    <visual>
      <origin xyz="0.0954 -0.06 0.0212" rpy="0.0 0.785 0.0"/>
      <geometry>
       <mesh filename="package://fyp_new/meshes/leg/shank.stl" scale="0.001 0.001 0.001"/>
      </geometry>
      <material name="black"/>
    </visual>
    <collision>
      <origin xyz="0.0954 -0.06 0.0212" rpy="0.0 0.785 0.0"/>
      <geometry>
        <box size="0.03 0.05 0.13"/>
      </geometry>
    </collision>
    <inertial>
      <mass value="0.125" />
      <inertia ixx="0.00018541666" ixy="0.0" ixz="0.0" iyy="0.00003541666" iyz="0.0" izz="0.00020208333" />
    </inertial>
  <!--  <xacro:box_inertial mass="${0.125}" length="0.03" width="0.03" height="0.13"/>-->
  </link>

  <joint name="knee_joint_rb" type="revolute">
    <limit effort="100.0" lower="-1.57075" upper="1.57075" velocity="0.5"/>
    <origin xyz="0.0954 -0.06 0.0212"/>
    <axis xyz="0 1 0"/>
    <parent link="thigh_link_rb"/>
    <child link="shank_link_rb"/>
    <dynamics damping="10" friction="0.1"/>
  </joint>
  <gazebo reference="shank_link_rb">
    <mu1>100000.0</mu1>
    <mu2>100000.0</mu2>
    <material>Gazebo/Black</material>
  </gazebo>

  <link name="feet_link_lf">
    <collision>
      <geometry>
        <sphere radius="0.025"/>
      </geometry>
    </collision>
    <visual>
      <geometry>
        <sphere radius="0.025"/>
      </geometry>
      <material name="white"/>
    </visual>
    <!--xacro:feet_inertial mass="0.05" radius="0.025"/!-->
    <inertial>
      <mass value="0.05" />
      <inertia ixx="0.0000125" ixy="0.0" ixz="0.0" iyy="0.0000125" iyz="0.0" izz="0.0000125" />
    </inertial>
  </link>

  <joint name="ankle_joint_lf" type="fixed">
    <origin xyz="0.3696 0.195 0.0"/>
    <axis xyz="0 1 0"/>1596724786.904973229,
    <parent link="shank_link_lf"/>
    <child link="feet_link_lf"/>
    <dynamics damping="10" friction="0.1"/>
  </joint>
  <gazebo reference="feet_link_lf">
    <mu1>100000.0</mu1>
    <mu2>100000.0</mu2>
    <material>Gazebo/White</material>
  </gazebo>

  <link name="feet_link_rf">
    <collision>
      <geometry>
        <sphere radius="0.025"/>
      </geometry>
    </collision>
    <visual>
      <geometry>
        <sphere radius="0.025"/>
      </geometry>
      <material name="white"/>
    </visual>
    <!--xacro:feet_inertial mass="0.05" radius="0.025"/!-->
    <inertial>
      <mass value="0.05" />
      <inertia ixx="0.0000125" ixy="0.0" ixz="0.0" iyy="0.0000125" iyz="0.0" izz="0.0000125" />
    </inertial>
  </link>

  <joint name="ankle_joint_rf" type="fixed">
    <origin xyz="0.3696 -0.035 0.0"/>
    <axis xyz="0 1 0"/>
    <parent link="shank_link_rf"/>
    <child link="feet_link_rf"/>
    <dynamics damping="10" friction="0.1"/>
  </joint>
  <gazebo reference="feet_link_rf">
    <mu1>100000.0</mu1>
    <mu2>100000.0</mu2>
    <material>Gazebo/White</material>
  </gazebo>

  <link name="feet_link_lb">
    <collision>
      <geometry>
        <sphere radius="0.025"/>
      </geometry>
    </collision>
    <visual>
      <geometry>
        <sphere radius="0.025"/>
      </geometry>
      <material name="white"/>
    </visual>
    <!--xacro:feet_inertial mass="0.05" radius="0.025"/!-->
    <inertial>
      <mass value="0.05" />
      <inertia ixx="0.0000125" ixy="0.0" ixz="0.0" iyy="0.0000125" iyz="0.0" izz="0.0000125" />
    </inertial>
  </link>

  <joint name="ankle_joint_lb" type="fixed">
    <origin xyz="0.1204 0.195 0.0"/>
    <axis xyz="0 1 0"/>
    <parent link="shank_link_lb"/>
    <child link="feet_link_lb"/>
    <dynamics damping="10" friction="0.1"/>
  </joint>
  <gazebo reference="feet_link_lb">
    <mu1>100000.0</mu1>
    <mu2>100000.0</mu2>
    <material>Gazebo/White</material>
  </gazebo>

  <link name="feet_link_rb">
    <collision>
      <geometry>
        <sphere radius="0.025"/>
      </geometry>
    </collision>
    <visual>
      <geometry>
        <sphere radius="0.025"/>
      </geometry>
      <material name="white"/>
    </visual>
    <!--xacro:feet_inertial mass="0.05" radius="0.025"/!-->
    <inertial>
      <mass value="0.05" />
      <inertia ixx="0.0000125" ixy="0.0" ixz="0.0" iyy="0.0000125" iyz="0.0" izz="0.0000125" />
    </inertial>
  </link>

  <joint name="ankle_joint_rb" type="fixed">
    <origin xyz="0.1204 -0.035 0.0"/>
    <axis xyz="0 1 0"/>
    <parent link="shank_link_rb"/>
    <child link="feet_link_rb"/>
    <dynamics damping="10" friction="0.1"/>
  </joint>
  <gazebo reference="feet_link_rb">
    <mu1>100000.0</mu1>
    <mu2>100000.0</mu2>
    <material>Gazebo/White</material>
  </gazebo>


  
<!--<gazebo>
  <plugin name="gazebo_ros_control" filename="libgazebo_ros_control.so">
    <robotNamespace>/model_with_actuators</robotNamespace>
  </plugin>
</gazebo>-->
 <gazebo>
    <plugin filename="libgazebo_ros_p3d.so" name="p3d_base_controller">
      <alwaysOn>true</alwaysOn>
      <updateRate>10.0</updateRate>
      <bodyName>base_link</bodyName>
      <topicName>odom/ground_truth</topicName>
      <gaussianNoise>0.01</gaussianNoise>
      <frameName>world</frameName>
      <xyzOffsets>0 0 0</xyzOffsets>
      <rpyOffsets>0 0 0</rpyOffsets>
    </plugin>
  </gazebo>
  <gazebo>
    <plugin filename="libgazebo_ros_control.so" name="gazebo_ros_control">
      <legacyModeNS>true</legacyModeNS>
    </plugin>
  </gazebo>

</robot>

下面的代码用于启动 rviz 查看器。提前感谢那些试图解决问题的人。

<launch>
    <arg name="robot_name"       default="/" />
    <arg name="joints_map_file"  default="$(find fyp_new)/config/joints/joints.yaml"/>
    <arg name="links_map_file"   default="$(find fyp_new)/config/links/links.yaml"/>
    <arg name="gait_config_file" default="$(find fyp_new)/config/gait/gait.yaml"/>
    <arg name="description_file" default="$(find fyp_new)/urdf/fyp_new.urdf"/>
    <arg name="gazebo"           default="false" />
    <arg name="rviz"             default="false" />
    <arg name="rviz_ref_frame"   default="odom"/>
    <arg name="has_imu"          default="true" />
    <arg name="lite"             default="false" />
    <arg name="laser"            default="sim" />

    <group ns="$(arg robot_name)">
        <param name="tf_prefix" value="$(arg robot_name)"/>
        <param if="$(arg gazebo)" name="use_sim_time" value="true"/>

        <include file="$(find fyp_new)/description/launch/description.launch">
            <arg name="description_file" value="$(arg description_file)"/>
        </include>

        <node if="$(arg lite)" pkg="rosserial_python" name="rosserial_champ" type="serial_node.py" output="screen">
            <param name="port" value="/dev/ttyACM0" />
            <param name="baud" value="500000" />
        </node>

        <node if="$(arg lite)" pkg="champ_base" name="message_relay" type="message_relay_node" output="screen">
            <param                        name="gazebo"  value="$(arg gazebo)" />
            <param if="$(arg gazebo)"     name="has_imu" value="false"/>       
            <param unless="$(arg gazebo)" name="has_imu" value="$(arg has_imu)"/>       
        </node>

        <node unless="$(arg lite)" pkg="champ_base" name="champ_controller" type="quadruped_controller_node" output="screen">
            <param name="gazebo" value="$(arg gazebo)" />
        </node>

        <rosparam command="load" ns="gait"       file="$(arg gait_config_file)" />
        <rosparam command="load" ns="links_map"  file="$(arg links_map_file)" />
        <rosparam command="load" ns="joints_map" file="$(arg joints_map_file)" />

        <include file="$(find fyp_new)/fyp_new_bringup/launch/include/velocity_smoother.launch" />
            
        <node pkg="robot_localization" type="ekf_localization_node" name="ekf_localization"> 
            <remap from="odometry/filtered" to="odom" />
            <rosparam command="load" file="$(find champ_base)/config/ekf/ekf.yaml" />
        </node>
        
        <include file="$(find fyp_new)/fyp_new_bringup/launch/include/laser/$(arg laser).launch" />

        <node if="$(arg rviz)" name="rviz" pkg="rviz" type="rviz"
            args="-d $(find fyp_new)description/rviz/urdf_viewer.rviz -f $(arg rviz_ref_frame)"
            output="screen"/>
    </group>
</launch>
4

0 回答 0