当前位置:   article > 正文

基于hector算法的真实机器人建图与自主导航(一)——机器人URDF模型建立_hector机器人

hector机器人

URDF全称为Unified Robot Description Format,中文可以翻译为“统一机器人描述格式”。与计算机文件中的.txt文本格式、.jpg图像格式等类似,URDF是一种基于XML规范、用于描述机器人结构的格式。根据该格式的设计者所言,设计这一格式的目的在于提供一种尽可能通用(as general as possible)的机器人描述规范。
URDF文件可用于GAZEBO仿真,网上关于URDF文件用于仿真环境中的例程较多,此处不再详述,重点关注于真实机器人的导航算法。
机器人描述格式将机器人用若干个link和jiont表示,并定义其相互关系。便于ROS系统获取机器人各个组件间的tf变换。
此部分工作是基于ROS导航算法的机器人模型建立,是重要的基础工作,便于代码的维护和算法的实现。

<?xml version="1.0"?> 
<robot name="robot" xmlns:xacro="http://wwww.ros.org/wiki/xacro">
	<xacro:property name="Pi" value="3.1416"/>
	<xacro:property name="box_length" value="0.324"/>
	<xacro:property name="box_width" value="0.242"/>
	<xacro:property name="box_height" value="0.093"/>
	<xacro:property name="wheel_diameter" value="0.1524"/>
	<xacro:property name="wheel_length" value="0.060"/>
	<xacro:property name="wheel_distance" value="0.200"/>
	<xacro:property name="lidar_length" value="0.030"/>
	<xacro:property name="lidar_diameter" value="0.060"/>

	<link name="base_footprint">
			<origin rpy="0 0 0" xyz="0 0 0"/>
	</link>

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

	<link name="base_link">
        <visual>
            <geometry>
                <box size="${box_length} ${box_width} ${box_height}"/>
            </geometry>
            <origin rpy="0 0 0" xyz="0 0 ${(wheel_diameter+box_height)/2}"/>
            <material name="blue">
                <color rgba="0 .5 .8 1"/>
            </material>
        </visual>
    </link>

    <link name="right_front_wheel">  
        <visual>  
            <geometry>  
                <cylinder length="${wheel_length}" radius="${wheel_diameter/2}"/>  
            </geometry> 
			<origin rpy="0 0 0" xyz="0 0 0"/>
            <material name="black">  
                <color rgba="0 0 0 1"/>  
            </material>  
        </visual>  
    </link>  
    
    <joint name="right_front_wheel_joint" type="continuous">  
        <axis xyz="0 1 0"/>  
        <parent link="base_link"/>  
        <child link="right_front_wheel"/>  
        <origin rpy="${Pi/2} 0 0" xyz="${wheel_distance/2} ${-(box_width+wheel_length)/2} ${wheel_diameter/2}"/>  
        <limit effort="100" velocity="100"/>  
        <joint_properties damping="0.0" friction="0.0"/>  
    </joint>  
    
    <link name="right_back_wheel">  
    <visual>  
        <geometry>  
        	<cylinder length="${wheel_length}" radius="${wheel_diameter/2}"/> 
        </geometry>
		<origin rpy="0 0 0" xyz="0 0 0"/>
        <material name="black">  
        <color rgba="0 0 0 1"/>  
        </material>  
    </visual>  
    </link>  
    
    <joint name="right_back_wheel_joint" type="continuous">  
        <axis xyz="0 1 0"/>  
        <parent link="base_link"/>  
        <child link="right_back_wheel"/>  
        <origin rpy="${Pi/2} 0 0" xyz="${-wheel_distance/2} ${-(box_width+wheel_length)/2} ${wheel_diameter/2}"/>  
        <limit effort="100" velocity="100"/>  
        <joint_properties damping="0.0" friction="0.0"/>  
    </joint>  
    
    <link name="left_front_wheel">  
        <visual>  
            <geometry>  
                <cylinder length="${wheel_length}" radius="${wheel_diameter/2}"/>   
            </geometry>  
			<origin rpy="0 0 0" xyz="0 0 0"/>
            <material name="black">  
                <color rgba="0 0 0 1"/>  
            </material>  
        </visual>  
    </link>  
    
    <joint name="left_front_wheel_joint" type="continuous">  
        <axis xyz="0 1 0"/>  
        <parent link="base_link"/>  
        <child link="left_front_wheel"/>  
        <origin rpy="${Pi/2} 0 0" xyz="${wheel_distance/2} ${(box_width+wheel_length)/2} ${wheel_diameter/2}"/>   
        <limit effort="100" velocity="100"/>  
        <joint_properties damping="0.0" friction="0.0"/>  
    </joint>  
    
    <link name="left_back_wheel">  
        <visual>  
            <geometry>  
                <cylinder length="${wheel_length}" radius="${wheel_diameter/2}"/>  
            </geometry>  
			<origin rpy="0 0 0" xyz="0 0 0"/>
            <material name="black">  
                <color rgba="0 0 0 1"/>  
            </material>  
        </visual>  
    </link>  
    
    <joint name="left_back_wheel_joint" type="continuous">  
        <axis xyz="0 1 0"/>  
        <parent link="base_link"/>  
        <child link="left_back_wheel"/>  
        <origin rpy="${Pi/2} 0 0" xyz="${-wheel_distance/2} ${(box_width+wheel_length)/2} ${wheel_diameter/2}"/>  
        <limit effort="100" velocity="100"/>  
        <joint_properties damping="0.0" friction="0.0"/>  
    </joint>  
    
    <link name="laser">  
        <visual>  
            <geometry>  
                <cylinder length="${lidar_length}" radius="${lidar_diameter/2}"/>  
            </geometry>   
            <material name="white">
                <color rgba="1 1 1 1"/>  
            </material>  
        </visual>  
    </link>  
    
    <joint name="laser_joint" type="fixed">  
        <parent link="base_link"/>  
        <child link="laser"/>  
        <origin xyz="0.05 0 ${(wheel_diameter+2*box_height+lidar_length)/2}" rpy="0 0 0"/>  
    </joint>  
</robot>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135

上述为机器人xacro描述文件,具体功能包下载地址:https://download.csdn.net/download/ustcyr/24559934
编译完成后,启动launch文件,可在rviz中看到机器人模型

roslaunch description_function robot.launch 
  • 1

在这里插入图片描述此机器人模型仅仅定义了各个link和joint间的关系,与我现在使用的实验平台相同,包含一个激光雷达和四轮小车。可根据需求更改调整参数,与自己的实验平台相一直。
另外此文件并未添加雷达插件,四轮差分平台插件,还不能实现与GAZEBO系统间的交互。ROS与GAZEBO实际上是独立的两个模块,初学者在使用ROS和GZAEBO序偶开发时,切莫混淆两者。为了将两者连起来,就是通过这些插件和ros_control模块。
此处另附激光雷达的GAZEBO插件,电机驱动插件和四轮差分驱动控制器插件。
激光雷达:

        <gazebo reference="laser">
            <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>

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32

电机驱动,此处以左前轮为例,剩下的三个轮子可根据自己的joint名称定义,更改joint name
的参数即可。使用xacro文件的宏定义方法来简化代码,也是可以的。

        <transmission name="wheel_left_front_joint_trans">
            <type>transmission_interface/SimpleTransmission</type>
            <joint name="left_front_wheel_joint" />
            <actuator name="wheel_left_front_joint_motor">
                <hardwareInterface>VelocityJointInterface</hardwareInterface>
                <mechanicalReduction>1</mechanicalReduction>
            </actuator>
        </transmission>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

四轮差分驱动:网络和论坛上有很多两轮差分驱动的模块,四轮差分驱动的插件本人未找到,寻至ros官网,寻到此插件。
四轮与两轮并无本质区别,只是真实机器人多为四轮驱动,为了和真实机器人一致,可以使用以下代码作为差分驱动插件

<gazebo>
  <plugin name="skid_steer_drive_controller" filename="libgazebo_ros_skid_steer_drive.so">
    <updateRate>100.0</updateRate>
    <robotNamespace>/</robotNamespace>
    <leftFrontJoint>front_left_wheel_joint</leftFrontJoint>
    <rightFrontJoint>front_right_wheel_joint</rightFrontJoint>
    <leftRearJoint>back_left_wheel_joint</leftRearJoint>
    <rightRearJoint>back_right_wheel_joint</rightRearJoint>
    <wheelSeparation>0.4</wheelSeparation>
    <wheelDiameter>0.215</wheelDiameter>
    <robotBaseFrame>base_link</robotBaseFrame>
    <torque>20</torque>
    <topicName>cmd_vel</topicName>
    <broadcastTF>false</broadcastTF>
  </plugin>
</gazebo>
————————————————
版权声明:本文为CSDN博主「yrain·」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/ustcyr/article/details/118557140


  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21

写至此,用于真实机器人建图导航算法的四轮差分驱动模型的URDF已详述,若想用GAZEBO仿真环境来模拟开发,还需关注ros_control的内容,此处不再详述。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/黑客灵魂/article/detail/925601
推荐阅读
相关标签
  

闽ICP备14008679号