鱼香ROS社区
    • 版块
    • 最新
    • 未解决
    • 已解决
    • 群组
    • 注册
    • 登录
    紧急通知:禁止一切关于政治&VPN翻墙等话题,发现相关帖子会立马删除封号
    提问前必看的发帖注意事项: 社区问答规则(小鱼个人)更新 | 高质量帖子发布指南

    第九章机器人仿真出现错误

    已定时 已固定 已锁定 已移动
    ROS 2相关问题
    ros2 教材文档第九章
    5
    13
    2.3k
    正在加载更多帖子
    • 从旧到新
    • 从新到旧
    • 最多赞同
    回复
    • 在新帖中回复
    登录后回复
    此主题已被删除。只有拥有主题管理权限的用户可以查看。
    • 4417555354
      头怎么还不秃啊
      最后由 编辑

      urdf文件是直接复制的,应该不会错
      <?xml version="1.0"?>
      <robot name="fishbot">

      <!-- Robot Footprint -->
      <link name="base_footprint"/>

      <joint name="base_joint" type="fixed">
      <parent link="base_footprint"/>
      <child link="base_link"/>
      <origin xyz="0.0 0.0 0.076" rpy="0 0 0"/>
      </joint>

      <!-- base link -->
      <link name="base_link">
      <visual>
      <origin xyz="0 0 0.0" rpy="0 0 0"/>
      <geometry>
      <cylinder length="0.12" radius="0.10"/>
      </geometry>
      <material name="blue">
      <color rgba="0.1 0.1 1.0 0.5" />
      </material>
      </visual>
      <collision>
      <origin xyz="0 0 0.0" rpy="0 0 0"/>
      <geometry>
      <cylinder length="0.12" radius="0.10"/>
      </geometry>
      <material name="blue">
      <color rgba="0.1 0.1 1.0 0.5" />
      </material>
      </collision>
      <inertial>
      <mass value="0.2"/>
      <inertia ixx="0.0122666" ixy="0" ixz="0" iyy="0.0122666" iyz="0" izz="0.02"/>
      </inertial>
      </link>

      <!-- laser link -->
      <link name="laser_link">
      <visual>
      <origin xyz="0 0 0" rpy="0 0 0"/>
      <geometry>
      <cylinder length="0.02" radius="0.02"/>
      </geometry>
      <material name="black">
      <color rgba="0.0 0.0 0.0 0.5" />
      </material>
      </visual>
      <collision>
      <origin xyz="0 0 0" rpy="0 0 0"/>
      <geometry>
      <cylinder length="0.02" radius="0.02"/>
      </geometry>
      <material name="black">
      <color rgba="0.0 0.0 0.0 0.5" />
      </material>
      </collision>
      <inertial>
      <mass value="0.1"/>
      <inertia ixx="0.000190416666667" ixy="0" ixz="0" iyy="0.0001904" iyz="0" izz="0.00036"/>
      </inertial>
      </link>

      <!-- laser joint -->
      <joint name="laser_joint" type="fixed">
      <parent link="base_link" />
      <child link="laser_link" />
      <origin xyz="0 0 0.075" />
      </joint>

      <link name="imu_link">
      <visual>
      <origin xyz="0 0 0.0" rpy="0 0 0"/>
      <geometry>
      <box size="0.02 0.02 0.02"/>
      </geometry>
      </visual>
      <collision>
      <origin xyz="0 0 0.0" rpy="0 0 0"/>
      <geometry>
      <box size="0.02 0.02 0.02"/>
      </geometry>
      </collision>
      <inertial>
      <mass value="0.1"/>
      <inertia ixx="0.000190416666667" ixy="0" ixz="0" iyy="0.0001904" iyz="0" izz="0.00036"/>
      </inertial>
      </link>

      <!-- imu joint -->
      <joint name="imu_joint" type="fixed">
      <parent link="base_link" />
      <child link="imu_link" />
      <origin xyz="0 0 0.02" />
      </joint>

      <link name="left_wheel_link">
      <visual>
      <origin xyz="0 0 0" rpy="1.57079 0 0"/>
      <geometry>
      <cylinder length="0.04" radius="0.032"/>
      </geometry>
      <material name="black">
      <color rgba="0.0 0.0 0.0 0.5" />
      </material>
      </visual>
      <collision>
      <origin xyz="0 0 0" rpy="1.57079 0 0"/>
      <geometry>
      <cylinder length="0.04" radius="0.032"/>
      </geometry>
      <material name="black">
      <color rgba="0.0 0.0 0.0 0.5" />
      </material>
      </collision>
      <inertial>
      <mass value="0.2"/>
      <inertia ixx="0.000190416666667" ixy="0" ixz="0" iyy="0.0001904" iyz="0" izz="0.00036"/>
      </inertial>
      </link>

      <link name="right_wheel_link">
      <visual>
      <origin xyz="0 0 0" rpy="1.57079 0 0"/>
      <geometry>
      <cylinder length="0.04" radius="0.032"/>
      </geometry>
      <material name="black">
      <color rgba="0.0 0.0 0.0 0.5" />
      </material>
      </visual>
      <collision>
      <origin xyz="0 0 0" rpy="1.57079 0 0"/>
      <geometry>
      <cylinder length="0.04" radius="0.032"/>
      </geometry>
      <material name="black">
      <color rgba="0.0 0.0 0.0 0.5" />
      </material>
      </collision>
      <inertial>
      <mass value="0.2"/>
      <inertia ixx="0.000190416666667" ixy="0" ixz="0" iyy="0.0001904" iyz="0" izz="0.00036"/>
      </inertial>
      </link>

      <joint name="left_wheel_joint" type="continuous">
      <parent link="base_link" />
      <child link="left_wheel_link" />
      <origin xyz="-0.02 0.10 -0.06" />
      <axis xyz="0 1 0" />
      </joint>

      <joint name="right_wheel_joint" type="continuous">
      <parent link="base_link" />
      <child link="right_wheel_link" />
      <origin xyz="-0.02 -0.10 -0.06" />
      <axis xyz="0 1 0" />
      </joint>

      <link name="caster_link">
      <visual>
      <origin xyz="0 0 0" rpy="1.57079 0 0"/>
      <geometry>
      <sphere radius="0.016"/>
      </geometry>
      <material name="black">
      <color rgba="0.0 0.0 0.0 0.5" />
      </material>
      </visual>
      <collision>
      <origin xyz="0 0 0" rpy="1.57079 0 0"/>
      <geometry>
      <sphere radius="0.016"/>
      </geometry>
      <material name="black">
      <color rgba="0.0 0.0 0.0 0.5" />
      </material>
      </collision>
      <inertial>
      <mass value="0.02"/>
      <inertia ixx="0.000190416666667" ixy="0" ixz="0" iyy="0.0001904" iyz="0" izz="0.00036"/>
      </inertial>
      </link>

      <joint name="caster_joint" type="fixed">
      <parent link="base_link" />
      <child link="caster_link" />
      <origin xyz="0.06 0.0 -0.076" />
      <axis xyz="0 1 0" />
      </joint>

      <gazebo reference="caster_link">
      <material>Gazebo/Black</material>
      </gazebo>

      <gazebo reference="caster_link">
      <mu1 value="0.0"/>
      <mu2 value="0.0"/>
      <kp value="1000000.0" />
      <kd value="10.0" />
      <!-- <fdir1 value="0 0 1"/> -->
      </gazebo>

      <gazebo>
      <plugin name='diff_drive' filename='libgazebo_ros_diff_drive.so'>
      <ros>
      <namespace>/</namespace>
      <remapping>cmd_vel:=cmd_vel</remapping>
      <remapping>odom:=odom</remapping>
      </ros>
      <update_rate>30</update_rate>
      <!-- wheels -->
      <!-- <left_joint>left_wheel_joint</left_joint> -->
      <!-- <right_joint>right_wheel_joint</right_joint> -->
      <left_joint>left_wheel_joint</left_joint>
      <right_joint>right_wheel_joint</right_joint>
      <!-- kinematics -->
      <wheel_separation>0.2</wheel_separation>
      <wheel_diameter>0.065</wheel_diameter>
      <!-- limits -->
      <max_wheel_torque>20</max_wheel_torque>
      <max_wheel_acceleration>1.0</max_wheel_acceleration>
      <!-- output -->
      <publish_odom>true</publish_odom>
      <publish_odom_tf>true</publish_odom_tf>
      <publish_wheel_tf>false</publish_wheel_tf>
      <odometry_frame>odom</odometry_frame>
      <robot_base_frame>base_footprint</robot_base_frame>
      </plugin>

        <plugin name="fishbot_joint_state" filename="libgazebo_ros_joint_state_publisher.so">
          <ros>
            <remapping>~/out:=joint_states</remapping>
          </ros>
          <update_rate>30</update_rate>
          <joint_name>right_wheel_joint</joint_name>
          <joint_name>left_wheel_joint</joint_name>
        </plugin>    
        </gazebo> 
      
        <gazebo reference="laser_link">
          <material>Gazebo/Black</material>
        </gazebo>
      
      <gazebo reference="imu_link">
        <sensor name="imu_sensor" type="imu">
        <plugin filename="libgazebo_ros_imu_sensor.so" name="imu_plugin">
            <ros>
              <namespace>/</namespace>
              <remapping>~/out:=imu</remapping>
            </ros>
            <initial_orientation_as_reference>false</initial_orientation_as_reference>
          </plugin>
          <always_on>true</always_on>
          <update_rate>100</update_rate>
          <visualize>true</visualize>
          <imu>
            <angular_velocity>
              <x>
                <noise type="gaussian">
                  <mean>0.0</mean>
                  <stddev>2e-4</stddev>
                  <bias_mean>0.0000075</bias_mean>
                  <bias_stddev>0.0000008</bias_stddev>
                </noise>
              </x>
              <y>
                <noise type="gaussian">
                  <mean>0.0</mean>
                  <stddev>2e-4</stddev>
                  <bias_mean>0.0000075</bias_mean>
                  <bias_stddev>0.0000008</bias_stddev>
                </noise>
              </y>
              <z>
                <noise type="gaussian">
                  <mean>0.0</mean>
                  <stddev>2e-4</stddev>
                  <bias_mean>0.0000075</bias_mean>
                  <bias_stddev>0.0000008</bias_stddev>
                </noise>
              </z>
            </angular_velocity>
            <linear_acceleration>
              <x>
                <noise type="gaussian">
                  <mean>0.0</mean>
                  <stddev>1.7e-2</stddev>
                  <bias_mean>0.1</bias_mean>
                  <bias_stddev>0.001</bias_stddev>
                </noise>
              </x>
              <y>
                <noise type="gaussian">
                  <mean>0.0</mean>
                  <stddev>1.7e-2</stddev>
                  <bias_mean>0.1</bias_mean>
                  <bias_stddev>0.001</bias_stddev>
                </noise>
              </y>
              <z>
                <noise type="gaussian">
                  <mean>0.0</mean>
                  <stddev>1.7e-2</stddev>
                  <bias_mean>0.1</bias_mean>
                  <bias_stddev>0.001</bias_stddev>
                </noise>
              </z>
            </linear_acceleration>
          </imu>
        </sensor>
      </gazebo>
      
      <gazebo reference="laser_link">
        <sensor name="laser_sensor" type="ray">
        <always_on>true</always_on>
        <visualize>true</visualize>
        <update_rate>5</update_rate>
        <pose>0 0 0.075 0 0 0</pose>
        <ray>
            <scan>
              <horizontal>
                <samples>360</samples>
                <resolution>1.000000</resolution>
                <min_angle>0.000000</min_angle>
                <max_angle>6.280000</max_angle>
              </horizontal>
            </scan>
            <range>
              <min>0.120000</min>
              <max>3.5</max>
              <resolution>0.015000</resolution>
            </range>
            <noise>
              <type>gaussian</type>
              <mean>0.0</mean>
              <stddev>0.01</stddev>
            </noise>
        </ray>
      
        <plugin name="laserscan" filename="libgazebo_ros_ray_sensor.so">
          <ros>
            <!-- <namespace>/tb3</namespace> -->
            <remapping>~/out:=scan</remapping>
          </ros>
          <output_type>sensor_msgs/LaserScan</output_type>
          <frame_name>laser_link</frame_name>
        </plugin>
        </sensor>
      </gazebo>
      

      </robot>

      1 条回复 最后回复 回复 引用 0
      • 小鱼小
        小鱼 技术大佬 @441755535
        最后由 编辑

        @441755535 前面的依赖没安装

        新书配套视频:https://www.bilibili.com/video/BV1GW42197Ck/

        4417555354 2 条回复 最后回复 回复 引用 0
        • 4417555354
          头怎么还不秃啊 @小鱼
          最后由 编辑

          @小鱼 可是文档里面要安装的东西我都安装了啊

          1 条回复 最后回复 回复 引用 0
          • 4417555354
            头怎么还不秃啊 @小鱼
            最后由 编辑

            @小鱼 (base) hdm@hdm-virtual-machine:~$ sudo apt install ros-humble-gazebo-ros
            正在读取软件包列表... 完成
            正在分析软件包的依赖关系树... 完成
            正在读取状态信息... 完成
            ros-humble-gazebo-ros 已经是最新版 (3.7.0-1jammy.20230302.204832)。
            升级了 0 个软件包,新安装了 0 个软件包,要卸载 0 个软件包,有 33 个软件包未被升级。

            小鱼小 1 条回复 最后回复 回复 引用 0
            • 小鱼小
              小鱼 技术大佬 @441755535
              最后由 编辑

              @441755535 是plugins,建模仿真篇里的

              新书配套视频:https://www.bilibili.com/video/BV1GW42197Ck/

              4417555354 2 条回复 最后回复 回复 引用 0
              • 4417555354
                头怎么还不秃啊 @小鱼
                最后由 编辑

                @小鱼 ok,已解决

                25527284782 1 条回复 最后回复 回复 引用 0
                • 4417555354
                  头怎么还不秃啊 @小鱼
                  最后由 编辑

                  @小鱼 谢谢鱼总

                  25527284782 1 条回复 最后回复 回复 引用 0
                  • 25527284782
                    BR @441755535
                    最后由 编辑

                    @441755535 请问怎么解决的啊,怎么安装plugins

                    25527284782 1 条回复 最后回复 回复 引用 0
                    • 25527284782
                      BR @441755535
                      最后由 编辑

                      @441755535 大佬求教

                      1 条回复 最后回复 回复 引用 0
                      • 25527284782
                        BR @2552728478
                        最后由 编辑

                        @2552728478 网上查了下,已经解决啦👌

                        27521765252 1 条回复 最后回复 回复 引用 0
                        • 27521765252
                          勿扰清梦 @2552728478
                          最后由 编辑

                          @2552728478 你好,请问是咋么解决的?我也卡到这一步了。

                          D 1 条回复 最后回复 回复 引用 0
                          • D
                            dylanin1999 @2752176525
                            最后由 编辑

                            @2752176525 sudo apt install ros-humble-gazebo-ros-pkgs

                            1 条回复 最后回复 回复 引用 0
                            • 第一个帖子
                              最后一个帖子
                            皖ICP备16016415号-7
                            Powered by NodeBB | 鱼香ROS