Gazebo——仿真平台搭建(基于Ubuntu20.04) 1.gazebo--SpawnModel: Failure - model name mrobot already exists.

这篇具有很好参考价值的文章主要介绍了Gazebo——仿真平台搭建(基于Ubuntu20.04) 1.gazebo--SpawnModel: Failure - model name mrobot already exists.。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

目录

Gazebo安装配置

创建仿真环境 

仿真使用

Rviz查看摄像头采集的信息

Kinect仿真

问题解决:

1.gazebo--SpawnModel: Failure - model name mrobot already exists.


Gazebo安装配置

1.设置你的电脑来接收软件

sudo sh -c 'echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable `lsb_release -cs` main" > /etc/apt/sources.list.d/gazebo-stable.list'

2.设置秘钥

wget https://packages.osrfoundation.org/gazebo.key -O - | sudo apt-key add -

3.安装Gazebo

sudo apt-get update
sudo apt-get install gazebo11
sudo apt-get install libgazebo11-dev

4.检查你的安装是否有效果=

gazebo

5.打开 /.gazebo文件夹 下载模型

cd ~/.gazebo
git clone https://github.com/osrf/gazebo_models

如果出现fatal连接GitHub失败请使用以下代码

git clone https://gitclone.com/github.com/osrf/gazebo_models

下载时间可能偏久,读者可以选择和我一样另起终端进行其他操作,等到需要使用场景模型的时候大概也已经下载完成。 

6.其他关联安装包(不定时更新)

sudo apt-get install ros-noetic-rviz

sudo apt-get install ros-noetic-robot-state-publisher

sudo apt-get install ros-noetic-gazebo-ros-pkgs ros-noetic-gazebo-ros-control

sudo apt install ros-noetic-moveit

然后运行安装包索引

sudo apt-get update

接下来进行机器人模型的搭建

机器人模型配置

首先进入到mbot_description/urdf/xacro下

cd ~/catkin_ws/src/mbot_description/urdf/xacro
mkdir gazebo 
cd gazebo
sudo gedit mbot_base_gazebo.xacro

编辑模型文件

<?xml version="1.0"?>
<robot name="mbot" xmlns:xacro="http://www.ros.org/wiki/xacro">
<!--存放下面相关定义内容-->
</robot>
    <!-- PROPERTY LIST -->
    <xacro:property name="M_PI" value="3.1415926"/>
    <xacro:property name="base_mass"   value="20" /> 
    <xacro:property name="base_radius" value="0.20"/>
    <xacro:property name="base_length" value="0.16"/>

    <xacro:property name="wheel_mass"   value="2" />
    <xacro:property name="wheel_radius" value="0.06"/>
    <xacro:property name="wheel_length" value="0.025"/>
    <xacro:property name="wheel_joint_y" value="0.19"/>
    <xacro:property name="wheel_joint_z" value="0.05"/>

    <xacro:property name="caster_mass"    value="0.5" /> 
    <xacro:property name="caster_radius"  value="0.015"/> <!-- wheel_radius - ( base_length/2 - wheel_joint_z) -->
    <xacro:property name="caster_joint_x" value="0.18"/>
    <!-- Defining the colors used in this robot -->
    <material name="yellow">
        <color rgba="1 0.4 0 1"/>
    </material>
    <material name="black">
        <color rgba="0 0 0 0.95"/>
    </material>
    <material name="gray">
        <color rgba="0.75 0.75 0.75 1"/>
    </material>
<!-- Macro for inertia matrix -->
    <xacro:macro name="sphere_inertial_matrix" params="m r">
        <inertial>
            <mass value="${m}" />
            <inertia ixx="${2*m*r*r/5}" ixy="0" ixz="0"
                iyy="${2*m*r*r/5}" iyz="0" 
                izz="${2*m*r*r/5}" />
        </inertial>
    </xacro:macro>
    <xacro:macro name="cylinder_inertial_matrix" params="m r h">
        <inertial>
            <mass value="${m}" />
            <inertia ixx="${m*(3*r*r+h*h)/12}" ixy = "0" ixz = "0"
                iyy="${m*(3*r*r+h*h)/12}" iyz = "0"
                izz="${m*r*r/2}" /> 
        </inertial>
    </xacro:macro>
 <!-- Macro for robot wheel -->
    <xacro:macro name="wheel" params="prefix reflect">
        <joint name="${prefix}_wheel_joint" type="continuous">
            <origin xyz="0 ${reflect*wheel_joint_y} ${-wheel_joint_z}" rpy="0 0 0"/>
            <parent link="base_link"/>
            <child link="${prefix}_wheel_link"/>
            <axis xyz="0 1 0"/>
        </joint>

        <link name="${prefix}_wheel_link">
            <visual>
                <origin xyz="0 0 0" rpy="${M_PI/2} 0 0" />
                <geometry>
                    <cylinder radius="${wheel_radius}" length = "${wheel_length}"/>
                </geometry>
                <material name="gray" />
            </visual>
              <!-- collision -->
              <!-- the same with visual -->
              <!--增加惯性属性和碰撞属性-->
            <collision>
                <origin xyz="0 0 0" rpy="${M_PI/2} 0 0" />  
                <geometry>
                    <cylinder radius="${wheel_radius}" length = "${wheel_length}"/>
                </geometry>
            </collision>
              <!-- inertial -->
            <cylinder_inertial_matrix  m="${wheel_mass}" r="${wheel_radius}" h="${wheel_length}" />             
        </link>
        <!--添加gazebo标签为各link配颜色 ,gazebo与rivz颜色设置不兼容-->
                     <!-- Add gazebo tag to link -->
        <gazebo reference="${prefix}_wheel_link">
            <material>Gazebo/Gray</material>          
        </gazebo>
        <!--joint添加传动装置,用得 transmission 标签,小车轮子用速度控制接口-->
                <!-- Transmission is important to link the joints and the controller -->
        <transmission name="${prefix}_wheel_joint_trans">
            <type>transmission_interface/SimpleTransmission</type>
            <joint name="${prefix}_wheel_joint" >
                <hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface>
            </joint>
            <actuator name="${prefix}_wheel_joint_motor">
                <hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface>
                <mechanicalReduction>1</mechanicalReduction>
            </actuator>
        </transmission>
    </xacro:macro>
  <!-- Macro for robot caster -->
    <xacro:macro name="caster" params="prefix reflect">
        <joint name="${prefix}_caster_joint" type="continuous">
            <origin xyz="${reflect*caster_joint_x} 0 ${-(base_length/2 + caster_radius)}" rpy="0 0 0"/>
            <parent link="base_link"/>
            <child link="${prefix}_caster_link"/>
            <axis xyz="0 1 0"/>
        </joint>

        <link name="${prefix}_caster_link">
            <visual>
                <origin xyz="0 0 0" rpy="0 0 0"/>
                <geometry>
                    <sphere radius="${caster_radius}" />
                </geometry>
                <material name="black" />
            </visual>
                 <!-- 碰撞属性 -->
            <collision>
                <origin xyz="0 0 0" rpy="0 0 0"/>
                <geometry>
                    <sphere radius="${caster_radius}" />
                </geometry>
            </collision>  
                 <!-- 惯性属性 -->
            <sphere_inertial_matrix  m="${caster_mass}" r="${caster_radius}" />
        </link>
        <!--添加gazebo标签,为各link配颜色-->
        <gazebo reference="${prefix}_caster_link">
            <material>Gazebo/Black</material>
        </gazebo>
    </xacro:macro>
    <xacro:macro name="mbot_base_gazebo">
        <link name="base_footprint">
            <visual>
                <origin xyz="0 0 0" rpy="0 0 0" />
                <geometry>
                    <box size="0.001 0.001 0.001" />
                </geometry>
            </visual>
        </link>
           <!-- 给 base_footprint 添加标签 -->
        <gazebo reference="base_footprint">
            <turnGravityOff>false</turnGravityOff>
        </gazebo>

        <joint name="base_footprint_joint" type="fixed">
            <origin xyz="0 0 ${base_length/2 + caster_radius*2}" rpy="0 0 0" />        
            <parent link="base_footprint"/>
            <child link="base_link" />
        </joint>
        <!--base_link添加碰撞属性和惯性属性-->
                <link name="base_link">
            <visual>
                <origin xyz=" 0 0 0" rpy="0 0 0" />
                <geometry>
                    <cylinder length="${base_length}" radius="${base_radius}"/>
                </geometry>
                <material name="yellow" />
            </visual>
            <collision>
                <origin xyz=" 0 0 0" rpy="0 0 0" />
                <geometry>
                    <cylinder length="${base_length}" radius="${base_radius}"/>
                </geometry>
            </collision>   
            <cylinder_inertial_matrix  m="${base_mass}" r="${base_radius}" h="${base_length}" />
        </link>
        <!--base_link添加gazebo标签-->
        <gazebo reference="base_link">
            <material>Gazebo/Blue</material>
        </gazebo>
        <wheel prefix="left" reflect="-1"/> <!-- 调用驱动轮子宏定义 -->
        <wheel prefix="right" reflect="1"/> <!-- 调用驱动轮子宏定义 -->
        <caster prefix="front" reflect="-1"/> <!--调用支撑轮子宏定义-->
        <caster prefix="back" reflect="1"/> <!-- 调用支撑轮子宏定义 -->
    </xacro:macro>
        <!-- controller -->
        <gazebo>
            <plugin name="differential_drive_controller" 
                    filename="libgazebo_ros_diff_drive.so"> <!-- gazebo提供得差速控制器插件 -->
                    <!-- 控制器所需参数 -->
                <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_wheel_joint</leftJoint> <!-- 控制得joint在哪里,必须和上面得joint名称一致 -->
                <rightJoint>right_wheel_joint</rightJoint><!-- 控制得joint在哪里,必须和上面得joint名称一致 -->
                <wheelSeparation>${wheel_joint_y*2}</wheelSeparation><!-- 两个轮子得间距 -->
                <wheelDiameter>${2*wheel_radius}</wheelDiameter>
                <broadcastTF>1</broadcastTF>
                <wheelTorque>30</wheelTorque>
                <wheelAcceleration>1.8</wheelAcceleration>
                <commandTopic>cmd_vel</commandTopic> <!-- 订阅得话题:速度控制指令 -->
                <odometryFrame>odom</odometryFrame> 
                <odometryTopic>odom</odometryTopic> <!-- 发布里程计信息 -->
                <robotBaseFrame>base_footprint</robotBaseFrame><!-- 设置controler所控制的机器人的坐标系是哪个坐标系 -->
            </plugin>
        </gazebo> 

再编辑mbot_gazebo.xacro

<?xml version="1.0"?>
<robot name="arm" xmlns:xacro="http://www.ros.org/wiki/xacro">
    <xacro:include filename="$(find mbot_description)/urdf/xacro/gazebo/mbot_base_gazebo.xacro" /> <!-- 包含文件 -->
    <mbot_base_gazebo/>    <!-- 调用宏定义 -->
</robot>

编辑launch文件

cd ~/catkin_ws/src/mbot_description/launch/xacro
mkdir gazebo
cd gazebo
sudo gedit mbot_base_gazebo.launch
<launch>

    <!-- 设置launch文件的参数 -->
    <arg name="paused" default="false"/>
    <arg name="use_sim_time" default="true"/>
    <arg name="gui" default="true"/>
    <arg name="headless" default="false"/>
    <arg name="debug" default="false"/>

    <!-- 运行gazebo仿真环境 -->
    <include file="$(find gazebo_ros)/launch/empty_world.launch">
        <arg name="debug" value="$(arg debug)" />
        <arg name="gui" value="$(arg gui)" />
        <arg name="paused" value="$(arg paused)"/>
        <arg name="use_sim_time" value="$(arg use_sim_time)"/>
        <arg name="headless" value="$(arg headless)"/>
    </include>

    <!-- 加载机器人模型描述参数 -->
    <param name="robot_description" command="$(find xacro)/xacro --inorder '$(find mbot_description)/urdf/xacro/gazebo/mbot_gazebo.xacro'" /> 

    <!-- 运行joint_state_publisher节点,发布机器人的关节状态  -->
    <node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher" ></node> 

    <!-- 运行robot_state_publisher节点,发布tf  -->
    <node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher"  output="screen" >
        <param name="publish_frequency" type="double" value="50.0" />
    </node>

    <!-- 在gazebo中加载机器人模型-->
    <node name="urdf_spawner" pkg="gazebo_ros" type="spawn_model" respawn="false" output="screen"
          args="-urdf -model mrobot -param robot_description"/> 
</launch>

配置完成后运行显示模型

roslaunch mbot_description mbot_base_gazebo.launch

注意

由于Ubuntu20.04对应的ros版本为noetic,所以xacro模型文件的宏定义和宏调用方式都需要更改

Ubuntu20.04的mbot_base_gazebo.xacro文件对应的内容如下

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

    <!-- PROPERTY LIST -->
    <xacro:property name="M_PI" value="3.1415926"/>
    <xacro:property name="base_mass"   value="20" /> 
    <xacro:property name="base_radius" value="0.20"/>
    <xacro:property name="base_length" value="0.16"/>

    <xacro:property name="wheel_mass"   value="2" />
    <xacro:property name="wheel_radius" value="0.06"/>
    <xacro:property name="wheel_length" value="0.025"/>
    <xacro:property name="wheel_joint_y" value="0.19"/>
    <xacro:property name="wheel_joint_z" value="0.05"/>

    <xacro:property name="caster_mass"    value="0.5" /> 
    <xacro:property name="caster_radius"  value="0.015"/> <!-- wheel_radius - ( base_length/2 - wheel_joint_z) -->
    <xacro:property name="caster_joint_x" value="0.18"/>

    <!-- Defining the colors used in this robot -->
    <material name="yellow">
        <color rgba="1 0.4 0 1"/>
    </material>
    <material name="black">
        <color rgba="0 0 0 0.95"/>
    </material>
    <material name="gray">
        <color rgba="0.75 0.75 0.75 1"/>
    </material>
    
    <!-- Macro for inertia matrix -->
    <xacro:macro name="sphere_inertial_matrix" params="m r">
        <inertial>
            <mass value="${m}" />
            <inertia ixx="${2*m*r*r/5}" ixy="0" ixz="0"
                iyy="${2*m*r*r/5}" iyz="0" 
                izz="${2*m*r*r/5}" />
        </inertial>
    </xacro:macro>

    <xacro:macro name="cylinder_inertial_matrix" params="m r h">
        <inertial>
            <mass value="${m}" />
            <inertia ixx="${m*(3*r*r+h*h)/12}" ixy = "0" ixz = "0"
                iyy="${m*(3*r*r+h*h)/12}" iyz = "0"
                izz="${m*r*r/2}" /> 
        </inertial>
    </xacro:macro>

    <!-- Macro for robot wheel -->
    <xacro:macro name="wheel" params="prefix reflect">
        <joint name="${prefix}_wheel_joint" type="continuous">
            <origin xyz="0 ${reflect*wheel_joint_y} ${-wheel_joint_z}" rpy="0 0 0"/>
            <parent link="base_link"/>
            <child link="${prefix}_wheel_link"/>
            <axis xyz="0 1 0"/>
        </joint>

        <link name="${prefix}_wheel_link">
            <visual>
                <origin xyz="0 0 0" rpy="${M_PI/2} 0 0" />
                <geometry>
                    <cylinder radius="${wheel_radius}" length = "${wheel_length}"/>
                </geometry>
                <material name="gray" />
            </visual>
            <collision>
                <origin xyz="0 0 0" rpy="${M_PI/2} 0 0" />
                <geometry>
                    <cylinder radius="${wheel_radius}" length = "${wheel_length}"/>
                </geometry>
            </collision>
            <xacro:cylinder_inertial_matrix  m="${wheel_mass}" r="${wheel_radius}" h="${wheel_length}" />
        </link>

        <gazebo reference="${prefix}_wheel_link">
            <material>Gazebo/Gray</material>
        </gazebo>

        <!-- Transmission is important to link the joints and the controller -->
        <transmission name="${prefix}_wheel_joint_trans">
            <type>transmission_interface/SimpleTransmission</type>
            <joint name="${prefix}_wheel_joint" >
                <hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface>
            </joint>
            <actuator name="${prefix}_wheel_joint_motor">
                <hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface>
                <mechanicalReduction>1</mechanicalReduction>
            </actuator>
        </transmission>
    </xacro:macro>

    <!-- Macro for robot caster -->
    <xacro:macro name="caster" params="prefix reflect">
        <joint name="${prefix}_caster_joint" type="continuous">
            <origin xyz="${reflect*caster_joint_x} 0 ${-(base_length/2 + caster_radius)}" rpy="0 0 0"/>
            <parent link="base_link"/>
            <child link="${prefix}_caster_link"/>
            <axis xyz="0 1 0"/>
        </joint>

        <link name="${prefix}_caster_link">
            <visual>
                <origin xyz="0 0 0" rpy="0 0 0"/>
                <geometry>
                    <sphere radius="${caster_radius}" />
                </geometry>
                <material name="black" />
            </visual>
            <collision>
                <origin xyz="0 0 0" rpy="0 0 0"/>
                <geometry>
                    <sphere radius="${caster_radius}" />
                </geometry>
            </collision>      
            <xacro:sphere_inertial_matrix  m="${caster_mass}" r="${caster_radius}" />
        </link>

        <gazebo reference="${prefix}_caster_link">
            <material>Gazebo/Black</material>
        </gazebo>
    </xacro:macro>

    <xacro:macro name="mbot_base_gazebo">
        <link name="base_footprint">
            <visual>
                <origin xyz="0 0 0" rpy="0 0 0" />
                <geometry>
                    <box size="0.001 0.001 0.001" />
                </geometry>
            </visual>
        </link>
        <gazebo reference="base_footprint">
            <turnGravityOff>false</turnGravityOff>
        </gazebo>

        <joint name="base_footprint_joint" type="fixed">
            <origin xyz="0 0 ${base_length/2 + caster_radius*2}" rpy="0 0 0" />        
            <parent link="base_footprint"/>
            <child link="base_link" />
        </joint>

        <link name="base_link">
            <visual>
                <origin xyz=" 0 0 0" rpy="0 0 0" />
                <geometry>
                    <cylinder length="${base_length}" radius="${base_radius}"/>
                </geometry>
                <material name="yellow" />
            </visual>
            <collision>
                <origin xyz=" 0 0 0" rpy="0 0 0" />
                <geometry>
                    <cylinder length="${base_length}" radius="${base_radius}"/>
                </geometry>
            </collision>   
            <xacro:cylinder_inertial_matrix  m="${base_mass}" r="${base_radius}" h="${base_length}" />
        </link>

        <gazebo reference="base_link">
            <material>Gazebo/Blue</material>
        </gazebo>

        <xacro:wheel prefix="left"  reflect="-1"/>
        <xacro:wheel prefix="right" reflect="1"/>

        <xacro:caster prefix="front" reflect="-1"/>
        <xacro:caster prefix="back"  reflect="1"/>

        <!-- 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_wheel_joint</leftJoint>
                <rightJoint>right_wheel_joint</rightJoint>
                <wheelSeparation>${wheel_joint_y*2}</wheelSeparation>
                <wheelDiameter>${2*wheel_radius}</wheelDiameter>
                <broadcastTF>1</broadcastTF>
                <wheelTorque>30</wheelTorque>
                <wheelAcceleration>1.8</wheelAcceleration>
                <commandTopic>cmd_vel</commandTopic>
                <odometryFrame>odom</odometryFrame> 
                <odometryTopic>odom</odometryTopic> 
                <robotBaseFrame>base_footprint</robotBaseFrame>
            </plugin>
        </gazebo> 
    </xacro:macro>

</robot>

需要更改的地方为

Gazebo——仿真平台搭建(基于Ubuntu20.04)
                    
            
1.gazebo--SpawnModel: Failure - model name mrobot already exists.

 在轮子的宏定义语法以及支撑轮的宏定义语法前添加xacro引用

cylinder_inertial_matrix,

sphere_inertial_matrix

两个个标签引用的时候也需要加上xacro引用

 Gazebo——仿真平台搭建(基于Ubuntu20.04)
                    
            
1.gazebo--SpawnModel: Failure - model name mrobot already exists.

 Gazebo——仿真平台搭建(基于Ubuntu20.04)
                    
            
1.gazebo--SpawnModel: Failure - model name mrobot already exists.

以及mbot_gazebo.xacro文件也需要更改宏定义 

<?xml version="1.0"?>
<robot name="arm" xmlns:xacro="http://www.ros.org/wiki/xacro">
    <xacro:include filename="$(find mbot_description)/urdf/xacro/gazebo/mbot_base_gazebo.xacro" /> <!-- 包含文件 -->
    <xacro:mbot_base_gazebo/>    <!-- 调用宏定义 -->
</robot>

launch文件同样需要更改,这里有三个更改方法,一般情况下将

 <!-- 加载机器人模型描述参数 -->
    <param name="robot_description" command="$(find xacro)/xacro --inorder '$(find mbot_description)/urdf/xacro/gazebo/mbot_gazebo.xacro'" /> 

改为xacro 即可

也有其他的解决方法例如将其改为

xacro --i

还有

xacro.py

<launch>

    <!-- 设置launch文件的参数 -->
    <arg name="paused" default="false"/>
    <arg name="use_sim_time" default="true"/>
    <arg name="gui" default="true"/>
    <arg name="headless" default="false"/>
    <arg name="debug" default="false"/>

    <!-- 运行gazebo仿真环境 -->
    <include file="$(find gazebo_ros)/launch/empty_world.launch">
        <arg name="debug" value="$(arg debug)" />
        <arg name="gui" value="$(arg gui)" />
        <arg name="paused" value="$(arg paused)"/>
        <arg name="use_sim_time" value="$(arg use_sim_time)"/>
        <arg name="headless" value="$(arg headless)"/>
    </include>

    <!-- 加载机器人模型描述参数 -->
    <param name="robot_description" command="$(find xacro)/xacro '$(find mbot_description)/urdf/xacro/gazebo/mbot_gazebo.xacro'" /> 

    <!-- 运行joint_state_publisher节点,发布机器人的关节状态  -->
    <node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher" ></node> 

    <!-- 运行robot_state_publisher节点,发布tf  -->
    <node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher"  output="screen" >
        <param name="publish_frequency" type="double" value="50.0" />
    </node>

    <!-- 在gazebo中加载机器人模型-->
    <node name="urdf_spawner" pkg="gazebo_ros" type="spawn_model" respawn="false" output="screen"
          args="-urdf -model mrobot -param robot_description"/> 
</launch>

正常启动后如下所示

Gazebo——仿真平台搭建(基于Ubuntu20.04)
                    
            
1.gazebo--SpawnModel: Failure - model name mrobot already exists.

创建仿真环境 

这里有两种方法添加场景模型

第一:直接添加

将模型放置到~/.gazebo/models 文件夹下——在gazebo的左侧列表点击“insert”(可以看到里面有很多的模型,我们只需要从列表中拖出我们需要的模型放置到仿真环境中就可以)

https://bitbucket.org/osrf/gazebo_models/downloads/

Gazebo——仿真平台搭建(基于Ubuntu20.04)
                    
            
1.gazebo--SpawnModel: Failure - model name mrobot already exists.

这里本文开始时的下载如果已经下载完成可以跳过,如果还未下载完成请等待下载完成再进行后续操作。 

 Gazebo——仿真平台搭建(基于Ubuntu20.04)
                    
            
1.gazebo--SpawnModel: Failure - model name mrobot already exists.

 选择需要的模型直接拖动到场景中搭建即可

Gazebo——仿真平台搭建(基于Ubuntu20.04)
                    
            
1.gazebo--SpawnModel: Failure - model name mrobot already exists.

 注意这一步需要将原本的机器人模型进行删除然后保存。

Gazebo——仿真平台搭建(基于Ubuntu20.04)
                    
            
1.gazebo--SpawnModel: Failure - model name mrobot already exists.

 这里如果显示conectting----说明还未连接完成,等待出现http-----连接完成后即可正常显示模型,再选择需要的模型添加即可。

 Gazebo——仿真平台搭建(基于Ubuntu20.04)
                    
            
1.gazebo--SpawnModel: Failure - model name mrobot already exists.

 自定义文件名称和位置即可

建议存放在catkin_ws/src/mbot_descritpion/worlds下

Gazebo——仿真平台搭建(基于Ubuntu20.04)
                    
            
1.gazebo--SpawnModel: Failure - model name mrobot already exists.

 第二:使用Building editor

模型创建:

Edit——Building editor——绘制环境模型——File——Save保存我们的模型文件(自己设置模型文件名字)——Exit Building Editor(退出编辑界面),可以看到我们的仿真环境已经在gazebo中显示;

保存环境模型同第一种方法一致,然后关闭gazebo界面即可。

仿真使用

    <!-- 设置launch文件的参数 -->
    <arg name="world_name" value="$(find mbot_description)/worlds/Ambulance.world"/><!-- 要加入的部分 -->
    <arg name="paused" default="false"/>
    <arg name="use_sim_time" default="true"/>
    <arg name="gui" default="true"/>
    <arg name="headless" default="false"/>
    <arg name="debug" default="false"/>

传感器仿真 

cd ~/catkin_ws/src/mbot_description/urdf/xacro
mkdir sensors
cd sensors
sudo gedit camera_gazebo.xacro
<?xml version="1.0"?>
<robot xmlns:xacro="http://www.ros.org/wiki/xacro" name="camera">
	<xacro:macro name="usb_camera" params="prefix:=camera">
    	<link name="${prefix}_link">
            <inertial>
                <mass value="0.1" />
                <origin xyz="0 0 0" />
                <inertia ixx="0.01" ixy="0.0" ixz="0.0"
                         iyy="0.01" iyz="0.0"
                         izz="0.01" />
            </inertial>

            <visual>
                <origin xyz=" 0 0 0 " rpy="0 0 0" />
                <geometry>
                    <box size="0.01 0.04 0.04" />
                </geometry>
                <material name="black"/>
            </visual>

            <collision>
                <origin xyz="0.0 0.0 0.0" rpy="0 0 0" />
                <geometry>
                    <box size="0.01 0.04 0.04" />
                </geometry>
            </collision>
        </link>
        <gazebo reference="${prefix}_link">
            <material>Gazebo/Black</material>
        </gazebo>
	     <gazebo reference="${prefix}_link"> <!-- 这个sensor代表的link -->
            <sensor type="camera" name="camera_node">
                <update_rate>30.0</update_rate><!-- 摄像头发布频率 -->
                <camera name="head">
                    <horizontal_fov>1.3962634</horizontal_fov><!-- 摄像头可视范围 -->
                    <image>
                        <width>1280</width><!-- 摄像头分辨率 -->
                        <height>720</height><!-- 摄像头分辨率 -->
                        <format>R8G8B8</format><!-- 摄像头数据格式 -->
                    </image>
                    <clip>
                        <near>0.02</near><!-- 最近距离 -->
                        <far>300</far><!-- 最远距离 -->
                    </clip>
                    <noise>
                        <type>gaussian</type><!-- 摄像头高斯噪声 -->
                        <mean>0.0</mean>
                        <stddev>0.007</stddev>
                    </noise>
                </camera>
                <plugin name="gazebo_camera" filename="libgazebo_ros_camera.so"><!-- 加载插件,实现摄像头功能 -->
                    <alwaysOn>true</alwaysOn>
                    <updateRate>0.0</updateRate>
                    <cameraName>/camera</cameraName><!-- 命名空间 -->
                    <imageTopicName>image_raw</imageTopicName><!-- 发布图片信息话题名称 -->
                    <cameraInfoTopicName>camera_info</cameraInfoTopicName><!-- 发布摄像头信息话题名称 -->
                    <frameName>camera_link</frameName><!-- 数据的坐标系统 -->
                    <hackBaseline>0.07</hackBaseline>
                    <distortionK1>0.0</distortionK1>
                    <distortionK2>0.0</distortionK2>
                    <distortionK3>0.0</distortionK3>
                    <distortionT1>0.0</distortionT1>
                    <distortionT2>0.0</distortionT2>
                </plugin>
            </sensor>
        </gazebo>
    </xacro:macro>
</robot>
cd ~/catkin_ws/src/mbot_description/urdf/xacro/gazebo
sudo gedit mbot_with_camera_gazebo.xacro

在文件中写入以下内容即可

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

    <xacro:include filename="$(find mbot_description)/urdf/xacro/gazebo/mbot_base_gazebo.xacro" />
    <xacro:include filename="$(find mbot_description)/urdf/xacro/sensors/camera_gazebo.xacro" />

    <xacro:property name="camera_offset_x" value="0.17" />
    <xacro:property name="camera_offset_y" value="0" />
    <xacro:property name="camera_offset_z" value="0.10" />

    <mbot_base/>

    <!-- Camera -->
    <joint name="camera_joint" type="fixed">
        <origin xyz="${camera_offset_x} ${camera_offset_y} ${camera_offset_z}" rpy="0 0 0" />
        <parent link="base_link"/>
        <child link="camera_link"/>
    </joint>

    <xacro:usb_camera prefix="camera"/>

    <xacro:mbot_base_gazebo/>

</robot>

带摄像头的机器人launch启动文件的编写

cd ~/catkin_ws/src/mbot_description/launch/xacro/gazebo
sudo gedit view_mbot_with_camera_gazebo.launch
<launch>
    <arg name="world_name" value="$(find mbot_description)/worlds/Ambulance.world"/>
    <arg name="paused" default="false"/>
    <arg name="use_sim_time" default="true"/>
    <arg name="gui" default="true"/>
    <arg name="headless" default="false"/>
    <arg name="debug" default="false"/>
  
    <include file="$(find gazebo_ros)/launch/empty_world.launch">
        <arg name="world_name" value="$(arg world_name)" />
        <arg name="debug" value="$(arg debug)" />
        <arg name="gui" value="$(arg gui)" />
        <arg name="paused" value="$(arg paused)"/>
        <arg name="use_sim_time" value="$(arg use_sim_time)"/>
        <arg name="headless" value="$(arg headless)"/>
    </include>

    <param name="robot_description" command="$(find xacro)/xacro '$(find mbot_description)/urdf/xacro/gazebo/mbot_with_camera_gazebo.xacro'" /> 

    
    <node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher" ></node> 

    <node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher"  output="screen" >
        <param name="publish_frequency" type="double" value="50.0" />
    </node>

    <node name="urdf_spawner" pkg="gazebo_ros" type="spawn_model" respawn="false" output="screen"
          args="-urdf -model mrobot -param robot_description"/> 

</launch>

 然后运行显示模型

roslaunch mbot_description view_mbot_with_camera_gazebo.launch 

 Gazebo——仿真平台搭建(基于Ubuntu20.04)
                    
            
1.gazebo--SpawnModel: Failure - model name mrobot already exists.

注意如果说出现

[ERROR] [1666006852.591762, 106.467000]: Spawn service failed. Exiting.
[urdf_spawner-6] process has died [pid 35261, exit code 1, cmd /opt/ros/noetic/lib/gazebo_ros/spawn_model -urdf -model mrobot -param robot_description __name:=urdf_spawner __log:=/home/q/.ros/log/89f24a6e-4e10-11ed-b861-1f202bd9bc85/urdf_spawner-6.log].
log file: /home/q/.ros/log/89f24a6e-4e10-11ed-b861-1f202bd9bc85/urdf_spawner-6*.log

 则说明gazebo进程关闭不完全,需要将所有gazebo进程关闭

killall gzserver

然后发现可以正常启动  

使用qt可视化工具查看摄像头画面显示

另起终端

rqt_image_view

注意摄像头参数选定 

 Gazebo——仿真平台搭建(基于Ubuntu20.04)
                    
            
1.gazebo--SpawnModel: Failure - model name mrobot already exists.

 启用键盘控制

roslaunch mbot_teleop mbot_teleop.launch

 Gazebo——仿真平台搭建(基于Ubuntu20.04)
                    
            
1.gazebo--SpawnModel: Failure - model name mrobot already exists.

注意键盘控制按键

Gazebo——仿真平台搭建(基于Ubuntu20.04)
                    
            
1.gazebo--SpawnModel: Failure - model name mrobot already exists.

这里如果报错无法定位python 软件包

需要进行下载配置python插件

sudo ln -s /usr/bin/python3 /usr/bin/python

然后再允许键盘控制节点即可

如果读者功能包的src目录下没有mbot_teleop功能包,也可下载另键盘控制功能包

cd ~/carkin_ws/src
git clone https://github.com/ros-teleop/teleop_twist_keyboard.git
//然后启用即可
rosrun teleop_twist_keyboard teleop_twist_keyboard.py


 注意该teleop_twist_keyboard.py需要更改为可执行的文件

如果不想使用该功能包,想知道如何自主创建mbot_teleop功能包可参考Arbotix+rviz那篇文章mbot_teleop 功能包创建方法

Rviz查看摄像头采集的信息

rosrun rviz rviz

 Gazebo——仿真平台搭建(基于Ubuntu20.04)
                    
            
1.gazebo--SpawnModel: Failure - model name mrobot already exists.

 首先固定框架(fixed frame)选择base_footprint

然后Add——robotmodel——ok

然后Add——image——ok

然后image——image topic——/camera/image_raw

Gazebo——仿真平台搭建(基于Ubuntu20.04)
                    
            
1.gazebo--SpawnModel: Failure - model name mrobot already exists.

 激光雷达仿真

cd ~/catkin_ws/src/mbot_description/urdf/xacro/sensors
sudo gedit lidar_gazebo.xacro
<?xml version="1.0"?>
<robot xmlns:xacro="http://www.ros.org/wiki/xacro" name="laser">

    <xacro:macro name="rplidar" params="prefix">
        <!-- Create laser reference frame -->
        <link name="${prefix}_link">
            <inertial>
                <mass value="0.1" />
                <origin xyz="0 0 0" />
                <inertia ixx="0.01" ixy="0.0" ixz="0.0"
                         iyy="0.01" iyz="0.0"
                         izz="0.01" />
            </inertial>

            <visual>
                <origin xyz=" 0 0 0 " rpy="0 0 0" />
                <geometry>
                    <cylinder length="0.05" radius="0.05"/>
                </geometry>
                <material name="black"/>
            </visual>

            <collision>
                <origin xyz="0.0 0.0 0.0" rpy="0 0 0" />
                <geometry>
                    <cylinder length="0.06" radius="0.05"/>
                </geometry>
            </collision>
        </link>
        <gazebo reference="${prefix}_link">
            <material>Gazebo/Black</material>
        </gazebo>

        <gazebo reference="${prefix}_link">
            <sensor type="ray" name="rplidar">
                <pose>0 0 0 0 0 0</pose>
                <visualize>false</visualize>
                <update_rate>5.5</update_rate>
                <ray>
                    <scan>
                      <horizontal>
                        <samples>360</samples>
                        <resolution>1</resolution>
                        <min_angle>-3</min_angle>
                        <max_angle>3</max_angle>
                      </horizontal>
                    </scan>
                    <range>
                      <min>0.10</min>
                      <max>6.0</max>
                      <resolution>0.01</resolution>
                    </range>
                    <noise>
                      <type>gaussian</type>
                      <mean>0.0</mean>
                      <stddev>0.01</stddev>
                    </noise>
                </ray>
                <plugin name="gazebo_rplidar" filename="libgazebo_ros_laser.so">
                    <topicName>/scan</topicName>
                    <frameName>laser_link</frameName>
                </plugin>
            </sensor>
        </gazebo>

    </xacro:macro>
</robot>

然后编写主体xacro文件

cd ~/catkin_ws/src/mbot_description/urdf/xacro/gazebo
sudo gedit mbot_with_laser_gazebo.xacro

 内容如下所示

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

    <xacro:include filename="$(find mbot_description)/urdf/xacro/gazebo/mbot_base_gazebo.xacro" />
    <xacro:include filename="$(find mbot_description)/urdf/xacro/sensors/lidar_gazebo.xacro" />

    <xacro:property name="lidar_offset_x" value="0" />
    <xacro:property name="lidar_offset_y" value="0" />
    <xacro:property name="lidar_offset_z" value="0.105" />

    <!-- lidar -->
    <joint name="lidar_joint" type="fixed">
        <origin xyz="${lidar_offset_x} ${lidar_offset_y} ${lidar_offset_z}" rpy="0 0 0" />
        <parent link="base_link"/>
        <child link="laser_link"/>
    </joint>
    <xacro:rplidar prefix="laser"/>
    <xacro:mbot_base_gazebo/>
</robot>

然后编写launch 启动文件

cd ~/catkin_ws/src/mbot_description/launch/xacro/gazebo
sudo gedit view_mbot_with_laser_gazebo.launch
<launch>


    <arg name="world_name" value="$(find mbot_description)/worlds/Ambulance.world"/>
    <arg name="paused" default="false"/>
    <arg name="use_sim_time" default="true"/>
    <arg name="gui" default="true"/>
    <arg name="headless" default="false"/>
    <arg name="debug" default="false"/>


    <include file="$(find gazebo_ros)/launch/empty_world.launch">
        <arg name="world_name" value="$(arg world_name)" />
        <arg name="debug" value="$(arg debug)" />
        <arg name="gui" value="$(arg gui)" />
        <arg name="paused" value="$(arg paused)"/>
        <arg name="use_sim_time" value="$(arg use_sim_time)"/>
        <arg name="headless" value="$(arg headless)"/>
    </include>

 
    <param name="robot_description" command="$(find xacro)/xacro '$(find mbot_description)/urdf/xacro/gazebo/mbot_with_laser_gazebo.xacro'" />

   
    <node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher" ></node> 

   
    <node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher"  output="screen" >
        <param name="publish_frequency" type="double" value="50.0" />
    </node>

    
    <node name="urdf_spawner" pkg="gazebo_ros" type="spawn_model" respawn="false" output="screen"
          args="-urdf -model mrobot -param robot_description"/> 
</launch>

 激光雷达正常显示Gazebo——仿真平台搭建(基于Ubuntu20.04)
                    
            
1.gazebo--SpawnModel: Failure - model name mrobot already exists.

 然后启用键盘控制

roslaunch mbot_teleop mbot_teleop.launch

 Gazebo——仿真平台搭建(基于Ubuntu20.04)
                    
            
1.gazebo--SpawnModel: Failure - model name mrobot already exists.

rviz查看雷达采集信息

rosrun rviz rviz

 需要注意的地方与刚才类似

首先固定框架(fixed frame)选择base_footprint

然后Add——robotmodel——ok

Gazebo——仿真平台搭建(基于Ubuntu20.04)
                    
            
1.gazebo--SpawnModel: Failure - model name mrobot already exists.

然后Add——laserscan——ok

然后laserscan——topic——scan

在图中的红色线条即为雷达检测到的障碍物,由于我的小车卡在消防车和救护车之间懒得动了,就不附图说明了,红色线条很淡,建议将小车周围拿障碍物包满。

Kinect仿真

方法跟上面摄像头和激光雷达实现的方法类似,这里就不多加说明了,直接给出结果显示了。
gazebo显示

cd ~/catkin_ws/src/mbot_description/urdf/xacro/sensors
sudo gedit kinect_gazebo.xacro
<?xml version="1.0"?>
<robot xmlns:xacro="http://www.ros.org/wiki/xacro" name="kinect_camera">

    <xacro:macro name="kinect_camera" params="prefix:=camera">
        <!-- Create kinect reference frame -->
        <!-- Add mesh for kinect -->
        <link name="${prefix}_link">
            <origin xyz="0 0 0" rpy="0 0 0"/>
            <visual>
                <origin xyz="0 0 0" rpy="0 0 ${M_PI/2}"/>
                <geometry>
                    <mesh filename="package://mbot_description/meshes/kinect.dae" />
                </geometry>
            </visual>
            <collision>
                <geometry>
                    <box size="0.07 0.3 0.09"/>
                </geometry>
            </collision>
        </link>

        <joint name="${prefix}_optical_joint" type="fixed">
            <origin xyz="0 0 0" rpy="-1.5708 0 -1.5708"/>
            <parent link="${prefix}_link"/>
            <child link="${prefix}_frame_optical"/>
        </joint>

        <link name="${prefix}_frame_optical"/>

        <gazebo reference="${prefix}_link">
            <sensor type="depth" name="${prefix}">
                <always_on>true</always_on>
                <update_rate>20.0</update_rate>
                <camera>
                    <horizontal_fov>${60.0*M_PI/180.0}</horizontal_fov>
                    <image>
                        <format>R8G8B8</format>
                        <width>640</width>
                        <height>480</height>
                    </image>
                    <clip>
                        <near>0.05</near>
                        <far>8.0</far>
                    </clip>
                </camera>
                <plugin name="kinect_${prefix}_controller" filename="libgazebo_ros_openni_kinect.so">
                    <cameraName>${prefix}</cameraName>
                    <alwaysOn>true</alwaysOn>
                    <updateRate>10</updateRate>
                    <imageTopicName>rgb/image_raw</imageTopicName>
                    <depthImageTopicName>depth/image_raw</depthImageTopicName>
                    <pointCloudTopicName>depth/points</pointCloudTopicName>
                    <cameraInfoTopicName>rgb/camera_info</cameraInfoTopicName>
                    <depthImageCameraInfoTopicName>depth/camera_info</depthImageCameraInfoTopicName>
                    <frameName>${prefix}_frame_optical</frameName>
                    <baseline>0.1</baseline>
                    <distortion_k1>0.0</distortion_k1>
                    <distortion_k2>0.0</distortion_k2>
                    <distortion_k3>0.0</distortion_k3>
                    <distortion_t1>0.0</distortion_t1>
                    <distortion_t2>0.0</distortion_t2>
                    <pointCloudCutoff>0.4</pointCloudCutoff>
                </plugin>
            </sensor>
        </gazebo>

    </xacro:macro>
</robot>

 然后编写主体xacro文件

cd ~/catkin_ws/src/mbot_desctiption/urdf/xacro/gazebo
sudo gedit mbot_with_kinect_gazebo.xacro
<?xml version="1.0"?>
<robot name="arm" xmlns:xacro="http://www.ros.org/wiki/xacro">

    <xacro:include filename="$(find mbot_description)/urdf/xacro/gazebo/mbot_base_gazebo.xacro" />
    <xacro:include filename="$(find mbot_description)/urdf/xacro/sensors/kinect_gazebo.xacro" />

    <xacro:property name="kinect_offset_x" value="0.15" />
    <xacro:property name="kinect_offset_y" value="0" />
    <xacro:property name="kinect_offset_z" value="0.11" />

    <mbot_base/>

    <!-- kinect -->
    <joint name="kinect_joint" type="fixed">
        <origin xyz="${kinect_offset_x} ${kinect_offset_y} ${kinect_offset_z}" rpy="0 0 0" />
        <parent link="base_link"/>
        <child link="kinect_link"/>
    </joint>

    <xacro:kinect_camera prefix="kinect"/>

    <xacro:mbot_base_gazebo/>

</robot>

然后编写launch 启动文件

cd ~/catkin_ws/src/mbot_description/launch/xacro/gazebo
sudo gedit view_mbot_with_kinect_gazebo.launch
<launch>

    <!-- 设置launch文件的参数 -->
    <arg name="world_name" value="$(find mbot_description)/worlds/Ambulance.world"/><!-- 设置仿真环境文件路径 -->
    <arg name="paused" default="false"/>
    <arg name="use_sim_time" default="true"/>
    <arg name="gui" default="true"/>
    <arg name="headless" default="false"/>
    <arg name="debug" default="false"/>

    <!-- 运行gazebo仿真环境 -->
    <include file="$(find gazebo_ros)/launch/empty_world.launch">
        <arg name="world_name" value="$(arg world_name)" />
        <arg name="debug" value="$(arg debug)" />
        <arg name="gui" value="$(arg gui)" />
        <arg name="paused" value="$(arg paused)"/>
        <arg name="use_sim_time" value="$(arg use_sim_time)"/>
        <arg name="headless" value="$(arg headless)"/>
    </include>

    <!-- 加载机器人模型描述参数 -->
    <param name="robot_description" command="$(find xacro)/xacro '$(find mbot_description)/urdf/xacro/gazebo/mbot_with_kinect_gazebo.xacro'" /> <!-- 设置机器人模型文件路径 -->

    <!-- 运行joint_state_publisher节点,发布机器人的关节状态  -->
    <node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher" ></node> 

    <!-- 运行robot_state_publisher节点,发布tf  -->
    <node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher"  output="screen" >
        <param name="publish_frequency" type="double" value="50.0" />
    </node>

    <!-- 在gazebo中加载机器人模型-->
    <node name="urdf_spawner" pkg="gazebo_ros" type="spawn_model" respawn="false" output="screen"
          args="-urdf -model mrobot -param robot_description"/> 
</launch>

 运行后如下所示

Gazebo——仿真平台搭建(基于Ubuntu20.04)
                    
            
1.gazebo--SpawnModel: Failure - model name mrobot already exists.

查看kinect采集到的信息

rosrun rviz rviz

 Gazebo——仿真平台搭建(基于Ubuntu20.04)
                    
            
1.gazebo--SpawnModel: Failure - model name mrobot already exists.

 注意:

首先固定框架(fixed frame)选择base_footprint

然后Add——robotmodel——ok

然后Add——pointcloud2——ok

然后pointcloud2——topic——/kinect/depth/points

 以上就是本节内容,关于Gazebo物理仿真平台搭建已经全部完成。

问题解决:

1.gazebo--SpawnModel: Failure - model name mrobot already exists.

roslaunch gazebo_ros empty_world.launch

在开启后的gazebo界面中选中mrobot模型delete删除即可

然后退出。

在上述模型创建且.world 保存前需要把机器人模型删除再保存,不然会出现模型重名报错。

2. [ERROR] [1666006852.591762, 106.467000]: Spawn service failed. Exiting.
[urdf_spawner-6] process has died [pid 35261, exit code 1, cmd
/opt/ros/noetic/lib/gazebo_ros/spawn_model -urdf -model mrobot -param robot_description __name:=urdf_spawner __log:=/home/q/.ros/log/89f24a6e-4e10-11ed-b861-1f202bd9bc85/urdf_spawner-6.log].
log file: /home/q/.ros/log/89f24a6e-4e10-11ed-b861-1f202bd9bc85/urdf_spawner-6*.log

 将所有gazebo进程关闭再重启即可文章来源地址https://www.toymoban.com/news/detail-418429.html

killall gzserver

到了这里,关于Gazebo——仿真平台搭建(基于Ubuntu20.04) 1.gazebo--SpawnModel: Failure - model name mrobot already exists.的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • Ubuntu20.04搭建PX4仿真环境及XTDrone开发平台(最详细最明白)

    PX4-Autopilot仿真平台是由PX4官方提供的集虚拟px4固件、真机烧录固件、gazebo环境及模型于一体的平台,用户可以自己编写程序,通过mavros接口与虚拟px4固件进行mavlink协议的通讯,并在gazebo中显示虚拟世界和模型。因此PX官方手册里给了一个经典的例程:offboard.cpp和offboard.py,让

    2024年02月04日
    浏览(91)
  • 在ubuntu22.04(LTS)上搭建ROS2+PX4+Gazebo的联合仿真环境

    说明:本案例仅仅是跑通了ROS2+PX4+Gazebo的联合仿真,还没有实现使用键盘控制无人机飞行(以后会补充)。 1.准备工作 2.安装PX4仿真工具链 3.安装ROS2 4.安装ROS2的相关依赖 5.安装XRCE-DDS代理(AGENT) 6.创建ROS2工作空间并生成代码样例 7.运行XRCE代理 8.编译PX4固件并运行 (1)确保

    2024年04月29日
    浏览(69)
  • 基于Ubuntu20.04搭建OpenHarmony v3.0.6的qemu仿真环境

    出于个人兴趣,也出于对国产操作系统的好奇,想尝试一下以LiteOS为内核的Openharmony。但过程相当不顺利,主要原因是官方文档内容组织的不敢恭维。挺好的东西,不把说明书写好,让用户怎么用?我研究的核心问题就一个:如何在基于Qemu仿真的Openharmony中输出一个hello worl

    2024年02月09日
    浏览(30)
  • Moveit + Gazebo:搭建双臂仿真平台(方案一)

    环境ubuntu20.04 ROS-noetic         国内少有搭建Moveit和Gazebo联合仿真的教程,对于搭建双臂等复杂的仿真平台更是鲜有资料,因此想要把自己的见解分享出来供大家参考,共同提高。         本文提出了两种方法实现Moveit 对双臂的规划,并在gazebo中进行仿真         

    2023年04月08日
    浏览(27)
  • Moveit +Gazebo:搭建单臂机械臂仿真平台

    环境:Ubuntu20.04 ros-noetic 先放上效果展示:    首先要先安装ROS 和 Moveit,ROS的安装就不说了,Moeit的安装参看官网教程 Getting Started — moveit_tutorials Noetic documentation 安装过程中,用到了命令: rosdep update 最好在安装的时候能够科学上网 搭建单臂仿真平台主要分为4大步     

    2024年02月11日
    浏览(27)
  • Ubuntu18.04 Turtlebot2机器人移动控制 Rviz Gazebo仿真实现

    操作系统为ubuntu18.04 安装ROS Melodic Turtlebot2,很多大佬分享了详细的安装过程,在这里就不多赘述,安装遇到问题多百度,大部分都是可以解决的。 前期学习了赵虚左老师的ROS入门课程,结合Turtlebot2资料这里方便大家打开,放的创客制造的文档,也推荐大家去看官方文档 首先

    2023年04月25日
    浏览(56)
  • Ubuntu20.04 搭建W版本OpenStack平台

    目录 一、基础环境配置 1.controller、compute配置网卡地址 2.配置域名解析 3.NTP时间同步 二、添加OpenStack-wallaby软件包及基本环境 1、OpenStack 服务的所有节点上添加软件包 2、Mysql数据库 3、Rabbitmq消息队列 4、Memcached 5、etcd环境部署 三、keystone服务 四、glance镜像服务 五、Placement环

    2024年02月15日
    浏览(28)
  • Ubuntu18.04搭配无人机仿真环境(ROS,PX4,gazebo,Mavros,QGC安装教程)

    我个人使用了代理环境进行下载。Linux没有代理的可以使用国内源。 清华大学源 sudo sh -c ‘. /etc/lsb-release echo “deb http://mirrors.tuna.tsinghua.edu.cn/ros/ubuntu/ $DISTRIB_CODENAME main” /etc/apt/sources.list.d/ros-latest.list’ 中科大源 sudo sh -c ‘. /etc/lsb-release echo “deb http://mirrors.ustc.edu.cn/ros/ubu

    2024年02月13日
    浏览(37)
  • 基于Gazebo搭建移动机器人,并结合SLAM系统完成建图仿真

    博客地址:https://www.cnblogs.com/zylyehuo/ gazebo小车模型创建及仿真详见之前博客 gazebo小车模型(附带仿真环境) - zylyehuo - 博客园 gazebo+rviz 仿真 - zylyehuo - 博客园 参考链接 Autolabor-ROS机器人入门课程《ROS理论与实践》 安装 gmapping 包(用于构建地图): sudo apt install ros-melodic-gmapping 安

    2024年02月04日
    浏览(39)
  • Ubuntu18.04 ROS melodic环境下,通过Gazebo软件仿真SLAM算法的学习(gmapping/karto/cartographer/hector)

    目录 一 环境场景搭建world 1.下载insert插件(该插件下会提供一些建好的场景,也可不下载) 2.环境搭建(自建) 3.保存环境 4.配置修改 5.启动环境 二 机器人模型URDF 1.模型创建的文件书写规范 2.检查文件格式是否正确 3.启动模型 三 机器人在场景中运动 1.机器人放在场景中

    2024年02月04日
    浏览(31)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包