1. 机器人的启动文件
1.1. 整体叙述
-
<?xml version="1.0"?> <launch> <arg name="world" default="robocup_at_work_2012"/> <arg name="init_pos_x" default="0.0"/> <arg name="init_pos_y" default="0.0"/> <arg name="init_pos_z" default="0.0"/> <!-- launch world --> <!--<include file="$(find youbot_gazebo_worlds)/launch/$(arg world).launch" />--> <include file="$(find gazebo_ros)/launch/willowgarage_world.launch"/> <param name="robot_description" command="$(find xacro)/xacro.py $(find youbot_description)/robots/youbot_base_only.urdf.xacro" /> <node pkg="gazebo_ros" type="spawn_model" name="spawn_robot" respawn="false" output="screen" args="-param robot_description -urdf -x $(arg init_pos_x) -y $(arg init_pos_y) -z $(arg init_pos_z) -model youbot"> </node> <!-- launch joint state controller --> <include file="$(find youbot_gazebo_control)/launch/joint_state_controller.launch" /> <node pkg="robot_state_publisher" type="robot_state_publisher" name="robot_state_publisher"> <param name="publish_frequency" type="double" value="30.0" /> </node> </launch>
-
1.2. 具体解释
1. 启动一个gazebo场景
首先是把ros自带的gazebo_ros包的启动文件加载进来, 并启动里面的节点
- <include file=”$(find gazebo_ros)/launch/willowgarage_world.launch”/>
2. 加载机器人的描述文件
然后解码xacro
- <param name=”robot_description” command=”$(find xacro)/xacro.py $(find youbot_description)/robots/youbot_base_only.urdf.xacro” />
然后启动一个urdf转换节点:
-
<node pkg="gazebo_ros" type="spawn_model" name="spawn_robot" respawn="false" output="screen" args="-param robot_description -urdf -x $(arg init_pos_x) -y $(arg init_pos_y) -z $(arg init_pos_z) -model youbot"> </node>
-
3. 启动joint state 控制
- <include file=”$(find youbot_gazebo_control)/launch/joint_state_controller.launch” />
4. 机器人状态发布
-
<node pkg="robot_state_publisher" type="robot_state_publisher" name="robot_state_publisher"> <param name="publish_frequency" type="double" value="30.0" /> </node>
2. 每个文件的内容分析
2.1 启动一个gazebo场景
- <include file=”$(find gazebo_ros)/launch/willowgarage_world.launch”/>
具体内容:
-
<launch> <!-- We resume the logic in empty_world.launch, changing only the name of the world to be launched --> <include file="$(find gazebo_ros)/launch/empty_world.launch"> <arg name="world_name" value="worlds/willowgarage.world"/> <!-- Note: the world_name is with respect to GAZEBO_RESOURCE_PATH environmental variable --> <arg name="paused" value="false"/> <arg name="use_sim_time" value="true"/> <arg name="gui" value="true"/> <arg name="headless" value="false"/> <!-- Inert - see gazebo_ros_pkgs issue #491 --> <arg name="recording" value="false"/> <arg name="debug" value="false"/> </include> </launch>
-
2.2 加载机器人的描述文件
1. 然后解码xacro
-
<?xml version="1.0"?> <robot xmlns:sensor="http://playerstage.sourceforge.net/gazebo/xmlschema/#sensor" xmlns:controller="http://playerstage.sourceforge.net/gazebo/xmlschema/#controller" xmlns:interface="http://playerstage.sourceforge.net/gazebo/xmlschema/#interface" xmlns:xacro="http://ros.org/wiki/xacro" name="youbot" > <!-- The following xacro:included files set up definitions of parts of the robot body --> <!-- misc common stuff? --> <xacro:include filename="$(find youbot_description)/urdf/common.xacro" /> <!-- youbot base --> <xacro:include filename="$(find youbot_description)/urdf/youbot_base/base.urdf.xacro" /> <!-- controller manager --> <xacro:include filename="$(find youbot_description)/controller/ros_controller.urdf.xacro" /> <!-- materials for visualization --> <xacro:include filename="$(find youbot_description)/urdf/materials.urdf.xacro" /> <!-- sensors --> <xacro:include filename="$(find youbot_description)/urdf/sensors/hokuyo_urg30_laser.urdf.xacro"/> <xacro:youbot_base name="base"/> <xacro:hokuyo_urg30_laser name="base_laser_front" parent="base" ros_topic="base_scan" update_rate="40" min_angle="-2.36" max_angle="2.36"> <origin xyz="0.3 0 0.1" rpy="0 0 0"/> </xacro:hokuyo_urg30_laser> <!-- <xacro:include filename="$(find youbot_description)/urdf/sensors/hokuyo_urg04_laser.urdf.xacro"/> <xacro:youbot_base name="base"/> <xacro:hokuyo_urg04_laser name="base_laser_front" parent="base" ros_topic="base_scan" update_rate="10" min_angle="-1.37" max_angle="1.37"> <origin xyz="0.3 0 -0.03" rpy="0 0 0"/> </xacro:hokuyo_urg04_laser>--> </robot>
-
2. 解释:
1.1 确定xml版本 和机器人 的一些信息 , 没用
-
<?xml version="1.0"?> <robot xmlns:sensor="http://playerstage.sourceforge.net/gazebo/xmlschema/#sensor" xmlns:controller="http://playerstage.sourceforge.net/gazebo/xmlschema/#controller" xmlns:interface="http://playerstage.sourceforge.net/gazebo/xmlschema/#interface" xmlns:xacro="http://ros.org/wiki/xacro" name="youbot" >
-
1.2 xacro:包含文件设置机器人部件的定义
通用的配置参数:
- <xacro:include filename=”$(find youbot_description)/urdf/common.xacro” />
-
<?xml version="1.0"?> <robot xmlns:xacro="http://ros.org/wiki/xacro"> <xacro:property name="M_PI" value="3.1415926535897931" /> <!-- Casters --> <xacro:property name="cal_caster_fl" value="0.0" /> <xacro:property name="cal_caster_fr" value="0.0" /> <xacro:property name="cal_caster_bl" value="0.0" /> <xacro:property name="cal_caster_br" value="0.0" /> </robot>
-
机器人的一些基本配置文件
- <xacro:include filename=”$(find youbot_description)/urdf/youbot_base/base.urdf.xacro” />
-
<?xml version="1.0"?> <robot xmlns:sensor="http://playerstage.sourceforge.net/gazebo/xmlschema/#sensor" xmlns:controller="http://playerstage.sourceforge.net/gazebo/xmlschema/#controller" xmlns:interface="http://playerstage.sourceforge.net/gazebo/xmlschema/#interface" xmlns:xacro="http://ros.org/wiki/xacro"> <!-- sensors --> <xacro:include filename="$(find youbot_description)/urdf/youbot_base/base.gazebo.xacro"/> <xacro:include filename="$(find youbot_description)/urdf/youbot_base/base.transmission.xacro"/> <!-- simplified box collision geometry for base --> <xacro:property name="base_size_x" value="0.570"/> <xacro:property name="base_size_y" value="0.360"/> <xacro:property name="base_size_z" value="0.100"/> <xacro:property name="base_mass" value="22.0"/> <xacro:property name="caster_offset_x" value="0.228"/> <xacro:property name="caster_offset_y" value="0.158"/> <xacro:property name="caster_offset_z" value="-0.034"/> <xacro:property name="caster_mass" value="0.1"/> <xacro:property name="wheel_offset_x" value="0.0"/> <xacro:property name="wheel_offset_y" value="0.0"/> <xacro:property name="wheel_offset_z" value="0.0"/> <xacro:property name="wheel_mass" value="0.4"/> <xacro:property name="wheel_radius" value="0.05"/> <xacro:property name="wheel_length" value="0.005"/> <xacro:property name="caster_joint_damping" value="1.0"/> <xacro:property name="caster_joint_friction" value="1.0"/> <xacro:property name="caster_joint_effort" value="30"/> <xacro:property name="caster_joint_velocity" value="10"/> <xacro:property name="caster_joint_safety_k_velocity" value="10.0"/> <xacro:property name="wheel_joint_damping" value="1.0"/> <xacro:property name="wheel_joint_friction" value="1.0"/> <xacro:property name="wheel_joint_effort" value="30"/> <xacro:property name="wheel_joint_velocity" value="10"/> <xacro:property name="wheel_joint_safety_k_velocity" value="10.0"/> <xacro:macro name="youbot_base" params="name"> <link name="${name}_footprint"> <inertial> <mass value="0.1"/> <origin xyz="0 0 ${-base_size_z / 2.0}" rpy="0 0 0"/> <inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/> </inertial> <visual> <origin xyz="0 0 0" rpy="0 0 0"/> <geometry> <box size="0.001 0.001 0.001"/> </geometry> <material name="Red"/> </visual> <collision> <origin xyz="0 0 ${-base_size_z / 2.0}" rpy="0 0 0"/> <geometry> <box size="0.001 0.001 0.001"/> </geometry> </collision> </link> <joint name="${name}_footprint_joint" type="fixed"> <origin xyz="0 0 0" rpy="0 0 0"/> <child link="${name}_link"/> <parent link="${name}_footprint"/> </joint> <link name="${name}_link"> <inertial> <mass value="${base_mass}"/> <origin xyz="0 0 0"/> <inertia ixx="5.652232699207" ixy="-0.009719934438" ixz="1.293988226423" iyy="5.669473158652" iyz="-0.007379583694" izz="3.683196351726"/> </inertial> <visual> <origin xyz="0 0 0" rpy="0 0 0"/> <geometry> <mesh filename="package://youbot_description/meshes/youbot_base/base.dae"/> </geometry> <material name="DarkGrey"/> </visual> <collision> <origin xyz="0 0 0" rpy="0 0 0"/> <geometry> <!--<box size="${base_size_x} ${base_size_y} ${base_size_z}" />--> <mesh filename="package://youbot_description/meshes/youbot_base/base_convex.dae"/> </geometry> </collision> </link> <!-- front left wheel --> <joint name="caster_joint_fl" type="continuous"> <origin xyz="${caster_offset_x} ${caster_offset_y} ${caster_offset_z}" rpy="0 0 0"/> <axis xyz="0 0 1"/> <limit effort="${caster_joint_effort}" velocity="${caster_joint_velocity}"/> <dynamics damping="${caster_joint_damping}" friction="${caster_joint_friction}"/> <safety_controller k_velocity="${caster_joint_safety_k_velocity}"/> <parent link="${name}_link"/> <child link="caster_link_fl"/> </joint> <link name="caster_link_fl"> <inertial> <mass value="${caster_mass}"/> <origin xyz="0 0 0"/> <inertia ixx="0.012411765597" ixy="-0.000711733678" ixz="0.00050272983" iyy="0.015218160428" iyz="-0.000004273467" izz="0.011763977943"/> </inertial> </link> <joint name="wheel_joint_fl" type="continuous"> <axis xyz="0 1 0"/> <limit effort="${wheel_joint_effort}" velocity="${wheel_joint_velocity}"/> <origin xyz="${wheel_offset_x} ${wheel_offset_y} ${wheel_offset_z}" rpy="0 0 0"/> <parent link="caster_link_fl"/> <dynamics damping="${wheel_joint_damping}" friction="${wheel_joint_friction}"/> <safety_controller k_velocity="${wheel_joint_safety_k_velocity}"/> <child link="wheel_link_fl"/> </joint> <link name="wheel_link_fl"> <inertial> <mass value="${wheel_mass}"/> <origin xyz="0 0 0"/> <inertia ixx="0.012411765597" ixy="-0.000711733678" ixz="0.00050272983" iyy="0.015218160428" iyz="-0.000004273467" izz="0.011763977943"/> </inertial> <visual> <origin xyz="0 0 0" rpy="0 0 0"/> <!--<mesh filename="package://youbot_description/meshes/youbot_base/youbot_wheel.stl" />--> <geometry> <sphere radius="${wheel_radius}"/> </geometry> <material name="Orange"/> </visual> <collision> <origin xyz="0 0 0" rpy="${M_PI/2} 0 0"/> <geometry> <cylinder radius="${wheel_radius}" length="${wheel_radius}"/> </geometry> </collision> </link> <!-- front right wheel --> <joint name="caster_joint_fr" type="continuous"> <origin xyz="${caster_offset_x} ${-caster_offset_y} ${caster_offset_z}" rpy="0 0 0"/> <axis xyz="0 0 1"/> <limit effort="${caster_joint_effort}" velocity="${caster_joint_velocity}"/> <dynamics damping="${caster_joint_damping}" friction="${caster_joint_friction}"/> <safety_controller k_velocity="${caster_joint_safety_k_velocity}"/> <parent link="${name}_link"/> <child link="caster_link_fr"/> </joint> <link name="caster_link_fr"> <inertial> <mass value="${caster_mass}"/> <origin xyz="0 0 0"/> <inertia ixx="0.012411765597" ixy="-0.000711733678" ixz="0.00050272983" iyy="0.015218160428" iyz="-0.000004273467" izz="0.011763977943"/> </inertial> </link> <joint name="wheel_joint_fr" type="continuous"> <axis xyz="0 1 0"/> <limit effort="${wheel_joint_effort}" velocity="${wheel_joint_velocity}"/> <dynamics damping="${wheel_joint_damping}" friction="${wheel_joint_friction}"/> <safety_controller k_velocity="${wheel_joint_safety_k_velocity}"/> <origin xyz="${wheel_offset_x} ${wheel_offset_y} ${wheel_offset_z}" rpy="0 0 0"/> <parent link="caster_link_fr"/> <child link="wheel_link_fr"/> </joint> <link name="wheel_link_fr"> <inertial> <mass value="${wheel_mass}"/> <origin xyz="0 0 0"/> <inertia ixx="0.012411765597" ixy="-0.000711733678" ixz="0.00050272983" iyy="0.015218160428" iyz="-0.000004273467" izz="0.011763977943"/> </inertial> <visual> <origin xyz="0 0 0" rpy="0 0 0"/> <geometry> <!--<mesh filename="package://youbot_description/meshes/youbot_base/youbot_wheel.stl" />--> <sphere radius="${wheel_radius}"/> </geometry> <material name="Orange"/> </visual> <collision> <origin xyz="0 0 0" rpy="${M_PI/2} 0 0"/> <geometry> <cylinder radius="${wheel_radius}" length="${wheel_radius}"/> </geometry> </collision> </link> <!-- back left wheel --> <joint name="caster_joint_bl" type="continuous"> <origin xyz="${-caster_offset_x} ${caster_offset_y} ${caster_offset_z}" rpy="0 0 0"/> <axis xyz="0 0 1"/> <limit effort="${caster_joint_effort}" velocity="${caster_joint_velocity}"/> <dynamics damping="${caster_joint_damping}" friction="${caster_joint_friction}"/> <safety_controller k_velocity="${caster_joint_safety_k_velocity}"/> <parent link="${name}_link"/> <child link="caster_link_bl"/> </joint> <link name="caster_link_bl"> <inertial> <mass value="${caster_mass}"/> <origin xyz="0 0 0"/> <inertia ixx="0.012411765597" ixy="-0.000711733678" ixz="0.00050272983" iyy="0.015218160428" iyz="-0.000004273467" izz="0.011763977943"/> </inertial> </link> <joint name="wheel_joint_bl" type="continuous"> <axis xyz="0 1 0"/> <limit effort="10" velocity="10"/> <limit effort="${wheel_joint_effort}" velocity="${wheel_joint_velocity}"/> <dynamics damping="${wheel_joint_damping}" friction="${wheel_joint_friction}"/> <safety_controller k_velocity="${wheel_joint_safety_k_velocity}"/> <origin xyz="${wheel_offset_x} ${wheel_offset_y} ${wheel_offset_z}" rpy="0 0 0"/> <parent link="caster_link_bl"/> <child link="wheel_link_bl"/> </joint> <link name="wheel_link_bl"> <inertial> <mass value="${wheel_mass}"/> <origin xyz="0 0 0"/> <inertia ixx="0.012411765597" ixy="-0.000711733678" ixz="0.00050272983" iyy="0.015218160428" iyz="-0.000004273467" izz="0.011763977943"/> </inertial> <visual> <origin xyz="0 0 0" rpy="0 0 0"/> <geometry> <!--<mesh filename="package://youbot_description/meshes/youbot_base/youbot_wheel.stl" />--> <sphere radius="${wheel_radius}"/> </geometry> <material name="Orange"/> </visual> <collision> <origin xyz="0 0 0" rpy="${M_PI/2} 0 0"/> <geometry> <cylinder radius="${wheel_radius}" length="${wheel_radius}"/> </geometry> </collision> </link> <!-- back right wheel --> <joint name="caster_joint_br" type="continuous"> <origin xyz="${-caster_offset_x} ${-caster_offset_y} ${caster_offset_z}" rpy="0 0 0"/> <axis xyz="0 0 1"/> <limit effort="${caster_joint_effort}" velocity="${caster_joint_velocity}"/> <dynamics damping="${caster_joint_damping}" friction="${caster_joint_friction}"/> <safety_controller k_velocity="${caster_joint_safety_k_velocity}"/> <parent link="${name}_link"/> <child link="caster_link_br"/> </joint> <link name="caster_link_br"> <inertial> <mass value="${caster_mass}"/> <origin xyz="0 0 0"/> <inertia ixx="0.012411765597" ixy="-0.000711733678" ixz="0.00050272983" iyy="0.015218160428" iyz="-0.000004273467" izz="0.011763977943"/> </inertial> </link> <joint name="wheel_joint_br" type="continuous"> <axis xyz="0 1 0"/> <limit effort="${wheel_joint_effort}" velocity="${wheel_joint_velocity}"/> <dynamics damping="${wheel_joint_damping}" friction="${wheel_joint_friction}"/> <safety_controller k_velocity="${wheel_joint_safety_k_velocity}"/> <origin xyz="${wheel_offset_x} ${wheel_offset_y} ${wheel_offset_z}" rpy="0 0 0"/> <parent link="caster_link_br"/> <child link="wheel_link_br"/> </joint> <link name="wheel_link_br"> <inertial> <mass value="${wheel_mass}"/> <origin xyz="0 0 0"/> <inertia ixx="0.012411765597" ixy="-0.000711733678" ixz="0.00050272983" iyy="0.015218160428" iyz="-0.000004273467" izz="0.011763977943"/> </inertial> <visual> <origin xyz="0 0 0" rpy="0 0 0"/> <geometry> <!--<mesh filename="package://youbot_description/meshes/youbot_base/youbot_wheel.stl" />--> <sphere radius="${wheel_radius}"/> </geometry> <material name="Orange"/> </visual> <collision> <origin xyz="0 0 0" rpy="${M_PI/2} 0 0"/> <geometry> <cylinder radius="${wheel_radius}" length="${wheel_radius}"/> </geometry> </collision> </link> <!-- extensions --> <xacro:youbot_base_gazebo/> <xacro:youbot_base_transmission/> </xacro:macro> </robot>
-
控制管理 controller manager
-
<?xml version="1.0"?> <robot xmlns:sensor="http://playerstage.sourceforge.net/gazebo/xmlschema/#sensor" xmlns:controller="http://playerstage.sourceforge.net/gazebo/xmlschema/#controller" xmlns:interface="http://playerstage.sourceforge.net/gazebo/xmlschema/#interface"> <gazebo> <plugin name="gazebo_ros_controller" filename="libgazebo_ros_control.so" /> </gazebo> </robot>
-
可视化材料 materials for visualization
-
<?xml version="1.0"?> <robot> <material name="Orange"> <color rgba="1.0 0.4 0.0 1.0"/> </material> <material name="Grey"> <color rgba="0.7 0.7 0.7 1.0"/> </material> <material name="DarkGrey"> <color rgba="0.3 0.3 0.3 1.0"/> </material> <material name="White"> <color rgba="1.0 1.0 1.0 1.0"/> </material> <material name="Black"> <color rgba="0.0 0.0 0.0 1.0"/> </material> <material name="Red"> <color rgba="1.0 0.0 0.0 1.0"/> </material> <material name="Green"> <color rgba="0.0 1.0 0.0 1.0"/> </material> <material name="Blue"> <color rgba="0.0 0.0 0.8 1.0"/> </material> <material name="LightGrey"> <color rgba="0.82 0.82 0.82 1.0"/> </material> </robot>
-
启动传感器
30 米 or 10 米
-
<!-- sensors --> <xacro:include filename="$(find youbot_description)/urdf/sensors/hokuyo_urg30_laser.urdf.xacro"/> <xacro:youbot_base name="base"/> <xacro:hokuyo_urg30_laser name="base_laser_front" parent="base" ros_topic="base_scan" update_rate="40" min_angle="-2.36" max_angle="2.36"> <origin xyz="0.3 0 0.1" rpy="0 0 0"/> </xacro:hokuyo_urg30_laser>
-
- <xacro:include filename=”$(find youbot_description)/urdf/sensors/hokuyo_urg30_laser.urdf.xacro”/>
-
<?xml version="1.0"?> <robot xmlns:sensor="http://playerstage.sourceforge.net/gazebo/xmlschema/#sensor" xmlns:controller="http://playerstage.sourceforge.net/gazebo/xmlschema/#controller" xmlns:interface="http://playerstage.sourceforge.net/gazebo/xmlschema/#interface" xmlns:xacro="http://ros.org/wiki/xacro"> <xacro:include filename="$(find youbot_description)/urdf/sensors/hokuyo_urg30_laser.gazebo.xacro" /> <xacro:macro name="hokuyo_urg30_laser" params="name parent *origin ros_topic update_rate min_angle max_angle"> <joint name="${name}_hokuyo_urg30_laser_joint" type="fixed"> <axis xyz="0 1 0" /> <xacro:insert_block name="origin" /> <parent link="${parent}_link"/> <child link="${name}_link"/> </joint> <link name="${name}_link" type="laser"> <inertial> <mass value="0.16" /> <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> <origin xyz="0 0 0" rpy="0 0 0" /> <geometry> <mesh filename="package://youbot_description/meshes/sensors/hokuyo.dae" /> </geometry> <material name="DarkGrey" /> </visual> <collision> <origin xyz="0 0 0" rpy="0 0 0" /> <geometry> <mesh filename="package://youbot_description/meshes/sensors/hokuyo_convex.dae" /> </geometry> </collision> </link> <!-- gazebo extensions --> <xacro:hokuyo_urg30_laser_gazebo name="${name}" ros_topic="${ros_topic}" update_rate="${update_rate}" min_angle="${min_angle}" max_angle="${max_angle}" /> </xacro:macro> </robot>
-
- <xacro:include filename=”$(find youbot_description)/urdf/sensors/hokuyo_urg30_laser.gazebo.xacro” />
-
<?xml version="1.0"?> <robot xmlns:sensor="http://playerstage.sourceforge.net/gazebo/xmlschema/#sensor" xmlns:controller="http://playerstage.sourceforge.net/gazebo/xmlschema/#controller" xmlns:interface="http://playerstage.sourceforge.net/gazebo/xmlschema/#interface" xmlns:xacro="http://ros.org/wiki/xacro"> <xacro:macro name="hokuyo_urg30_laser_gazebo" params="name ros_topic update_rate min_angle max_angle"> <gazebo reference="${name}_link"> <sensor name="${name}" type="ray"> <always_on>true</always_on> <update_rate>${update_rate}</update_rate> <pose>0 0 0 0 0 0</pose> <visualize>false</visualize> <ray> <scan> <horizontal> <samples>1080</samples> <resolution>0.25</resolution> <min_angle>${min_angle}</min_angle> <max_angle>${max_angle}</max_angle> </horizontal> </scan> <range> <min>0.10</min> <max>30.0</max> <resolution>0.01</resolution> </range> <noise> <type>gaussian</type> <mean>0.0</mean> <stddev>0.03</stddev> </noise> </ray> <plugin name="gazebo_ros_${name}_controller" filename="libgazebo_ros_laser.so"> <gaussianNoise>0.005</gaussianNoise> <alwaysOn>true</alwaysOn> <updateRate>${update_rate}</updateRate> <topicName>${ros_topic}</topicName> <frameName>/${name}_link</frameName> </plugin> </sensor> </gazebo> </xacro:macro> </robot>
-
2.3 启动joint state 控制
- <include file=”$(find youbot_gazebo_control)/launch/joint_state_controller.launch” />
-
<?xml version="1.0"?> <launch> <rosparam file="$(find youbot_gazebo_control)/config/joint_state_controller.yaml" command="load"/> <node pkg="controller_manager" type="spawner" name="joint_state_controller_spawner" args="joint_state_controller" respawn="false" output="screen" /> </launch>
-
评论(0)
您还未登录,请登录后发表或查看评论