ROS总结(一)用URDF创建机器人模型

最近开始用urdf机器人描述文件搭建自己的omni底盘,记录一下问题和要点

官方教程

ros wiki/urdf

urdf描述形式如下图:
ROS总结(一)用URDF创建机器人模型_第1张图片

上图的urdf代码

<robot name="test_robot">
	<link name="link1" />
	<link name="link2" />
	<link name="link3" />
	<link name="link4" />
	
	<joint name="joint1" type="continuous">
		<parent link="link1"/>
		<child link="link2"/>
	joint>
	
	<joint name="joint2" type="continuous">
		<parent link="link1"/>
		<child link="link3"/>
	joint>
	
	<joint name="joint3" type="continuous">
		<parent link="link3"/>
		<child link="link4"/>
	joint>
robot>

安装依赖包

sudo apt-get install liburdfdom-tools

检查urdf文件

check_urdf	*.urdf

搭建omni底盘

代码实现:
omni_base.urdf



<robot name="sirius">

	<link name="base_link">
		<visual>
			<geometry>
				<cylinder length="0.2" radius="0.2"/>
			geometry>
			<material name="red">
				<color rgba="0.8 0 0 1"/>
			material>
		visual>
		<collision>
			<geometry>
				<cylinder length="0.2" radius="0.2"/>
			geometry>
		collision>
		<inertial>
			<mass value="10"/>
			<inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>
		inertial>
	link>

	<link name="front_wheel">
		<visual>
			<origin rpy="0 1.57 0" xyz="0 0 0"/>
			<geometry>
				<cylinder length="0.03" radius="0.08"/>
			geometry>
			<material name="black">
				<color rgba="0 0 0 1"/>
			material>
		visual>
		<collision>
			<origin rpy="0 1.57 0" xyz="0 0 0"/>
			<geometry>
				<cylinder length="0.03" radius="0.08"/>
			geometry>
		collision>
		<inertial>
			<origin rpy="0 1.57 0" xyz="0 0 0"/>
			<mass value="10"/>
			<inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>
		inertial>
	link>
	
	<link name="left_wheel">
		<visual>
			<origin rpy="0 1.57 2.09" xyz="0 0 0"/>
			<geometry>
				<cylinder length="0.03" radius="0.08"/>
			geometry>
			<material name="white">
				<color rgba="1 1 1 1"/>
			material>
		visual>
		<collision>
			<origin rpy="0 1.57 2.09" xyz="0 0 0"/>
			<geometry>
				<cylinder length="0.03" radius="0.08"/>
			geometry>
		collision>
		<inertial>
			<origin xyz="0 0 0"/>
			<mass value="10"/>
			<inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>
		inertial>
	link>
	
	<link name="right_wheel">
		<visual>
			<origin rpy="0 1.57 -2.09" xyz="0 0 0"/>
			<geometry>
				<cylinder length="0.03" radius="0.08"/>
			geometry>
			<material name="blue">
				<color rgba="0 0 0.8 1"/>
			material>
		visual>
		<collision>
			<origin rpy="0 1.57 -2.09" xyz="0 0 0"/>
			<geometry>
				<cylinder length="0.03" radius="0.08"/>
			geometry>
		collision>
		<inertial>
			<origin xyz="0 0 0"/>
			<mass value="10"/>
			<inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>
		inertial>
	link>

	<joint name="base_to_front_wheel" type="fixed">
		<parent link="base_link"/>
		<child link="front_wheel"/>
		<origin rpy="0 0 0" xyz="0.2 0 -0.08"/>
	joint>

	<joint name="base_to_left_wheel" type="fixed">
		<parent link="base_link"/>
		<child link="left_wheel"/>
		<origin rpy="0 0 0" xyz="-0.1 0.1732 -0.08"/>
	joint>

	<joint name="base_to_right_wheel" type="fixed">
		<parent link="base_link"/>
		<child link="right_wheel"/>
		<origin rpy="0 0 0" xyz="-0.1 -0.1732 -0.08"/>
	joint>

robot>

这个urdf文件包含了
4个link:base_link、front_wheel、left_wheel、right_wheel
3个关节:base_to_front_wheel、base_to_left_wheel、base_to_right_wheel

代码说明:
link标签中name是名字
形状标签:cylinder——圆柱、box——长方体
位置标签:origin,其中rpy是方位角roll、pitch、yaw,xyz为空间位置
物理属性:collision
碰撞属性:inertial
关节标签:joint(其中parent是父节点,child是子节点,origin是该关节的位姿)

display.launch

<launch>
        <arg name="model" default="$(find omni_base)/urdf/omni_base.urdf"/>
        <arg name="gui" default="true"/>

        <param name="robot_description" command="$(find xacro)/xacro.py $(arg model)"/>
        <param name="use_gui" value="$(arg gui)"/>

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

        <node name="robot_state_publisher" pkg="robot_state_publisher" type="state_publisher">
                <param name="publisher_frequency" type="double" value="20.0"/>
        node>

        <node name="rviz" pkg="rviz" type="rviz" required="true"/>
launch>

在RVIZ中显示
ROS总结(一)用URDF创建机器人模型_第2张图片

你可能感兴趣的:(ROS)