1.制作一个夹爪
本文介绍通过sdf的编辑,实现两指的简单夹爪。
1.1制作模型
(1)新建一个文件夹
mkdir ~/simple_gripper_tutorial; cd ~/simple_gripper_tutorial
(2)通过gedit打开gripper.world文件
gedit ~/simple_gripper_tutorial/gripper.world
复制以下内容:
<?xml version="1.0"?>
<sdf version="1.4">
<world name="default">
<!-- A ground plane -->
<include>
<uri>model://ground_plane</uri>
</include>
<!-- A global light source -->
<include>
<uri>model://sun</uri>
</include>
<include>
<uri>model://my_gripper</uri>
</include>
</world>
</sdf>
(3)在.model下新建一个my_gripper文件夹
mkdir -p ~/.gazebo/models/my_gripper
cd ~/.gazebo/models/my_gripper
(4)新建model.config
gedit model.config
并拷贝以下内容:
<?xml version="1.0"?>
<model>
<name>My Gripper</name>
<version>1.0</version>
<sdf version='1.4'>simple_gripper.sdf</sdf>
<author>
<name>My Name</name>
<email>me@my.email</email>
</author>
<description>
My awesome robot.
</description>
</model>
(5)新建simple_gripper.sdf
gedit simple_gripper.sdf
并拷贝以下内容:
<?xml version="1.0"?>
<sdf version="1.4">
<model name="simple_gripper">
<link name="riser">
<pose>-0.15 0.0 0.5 0 0 0</pose>
<inertial>
<pose>0 0 -0.5 0 0 0</pose>
<inertia>
<ixx>0.01</ixx>
<ixy>0</ixy>
<ixz>0</ixz>
<iyy>0.01</iyy>
<iyz>0</iyz>
<izz>0.01</izz>
</inertia>
<mass>10.0</mass>
</inertial>
<collision name="collision">
<geometry>
<box>
<size>0.2 0.2 1.0</size>
</box>
</geometry>
</collision>
<visual name="visual">
<geometry>
<box>
<size>0.2 0.2 1.0</size>
</box>
</geometry>
<material>
<script>Gazebo/Purple</script>
</material>
</visual>
</link>
<link name="palm">
<pose>0.0 0.0 0.05 0 0 0</pose>
<inertial>
<inertia>
<ixx>0.01</ixx>
<ixy>0</ixy>
<ixz>0</ixz>
<iyy>0.01</iyy>
<iyz>0</iyz>
<izz>0.01</izz>
</inertia>
<mass>0.5</mass>
</inertial>
<collision name="collision">
<geometry>
<box>
<size>0.1 0.2 0.1</size>
</box>
</geometry>
</collision>
<visual name="visual">
<geometry>
<box>
<size>0.1 0.2 0.1</size>
</box>
</geometry>
<material>
<script>Gazebo/Red</script>
</material>
</visual>
</link>
<link name="left_finger">
<pose>0.1 0.2 0.05 0 0 -0.78539</pose>
<inertial>
<inertia>
<ixx>0.01</ixx>
<ixy>0</ixy>
<ixz>0</ixz>
<iyy>0.01</iyy>
<iyz>0</iyz>
<izz>0.01</izz>
</inertia>
<mass>0.1</mass>
</inertial>
<collision name="collision">
<geometry>
<box>
<size>0.1 0.3 0.1</size>
</box>
</geometry>
</collision>
<visual name="visual">
<geometry>
<box>
<size>0.1 0.3 0.1</size>
</box>
</geometry>
<material>
<script>Gazebo/Blue</script>
</material>
</visual>
</link>
<link name="left_finger_tip">
<pose>0.336 0.3 0.05 0 0 1.5707</pose>
<inertial>
<inertia>
<ixx>0.01</ixx>
<ixy>0</ixy>
<ixz>0</ixz>
<iyy>0.01</iyy>
<iyz>0</iyz>
<izz>0.01</izz>
</inertia>
<mass>0.1</mass>
</inertial>
<collision name="collision">
<geometry>
<box>
<size>0.1 0.2 0.1</size>
</box>
</geometry>
</collision>
<visual name="visual">
<geometry>
<box>
<size>0.1 0.2 0.1</size>
</box>
</geometry>
<material>
<script>Gazebo/Blue</script>
</material>
</visual>
</link>
<link name="right_finger">
<pose>0.1 -0.2 0.05 0 0 .78539</pose>
<inertial>
<inertia>
<ixx>0.01</ixx>
<ixy>0</ixy>
<ixz>0</ixz>
<iyy>0.01</iyy>
<iyz>0</iyz>
<izz>0.01</izz>
</inertia>
<mass>0.1</mass>
</inertial>
<collision name="collision">
<geometry>
<box>
<size>0.1 0.3 0.1</size>
</box>
</geometry>
</collision>
<visual name="visual">
<geometry>
<box>
<size>0.1 0.3 0.1</size>
</box>
</geometry>
<material>
<script>Gazebo/Green</script>
</material>
</visual>
</link>
<link name="right_finger_tip">
<pose>0.336 -0.3 0.05 0 0 1.5707</pose>
<inertial>
<inertia>
<ixx>0.01</ixx>
<ixy>0</ixy>
<ixz>0</ixz>
<iyy>0.01</iyy>
<iyz>0</iyz>
<izz>0.01</izz>
</inertia>
<mass>0.1</mass>
</inertial>
<collision name="collision">
<geometry>
<box>
<size>0.1 0.2 0.1</size>
</box>
</geometry>
</collision>
<visual name="visual">
<geometry>
<box>
<size>0.1 0.2 0.1</size>
</box>
</geometry>
<material>
<script>Gazebo/Green</script>
</material>
</visual>
</link>
<static>true</static>
</model>
</sdf>
(6)检测,gazebo会显示如下图所示
gazebo ~/simple_gripper_tutorial/gripper.world
(7)上图的simple_gripper.sdf只有link,而没有joint,所以是不能动的,在</model>之前添加如下内容,并将<static>true</static>中的true修改成false:
<joint name="palm_left_finger" type="revolute">
<pose>0 -0.15 0 0 0 0</pose>
<child>left_finger</child>
<parent>palm</parent>
<axis>
<limit>
<lower>-0.4</lower>
<upper>0.4</upper>
</limit>
<xyz>0 0 1</xyz>
</axis>
</joint>
<joint name="left_finger_tip" type="revolute">
<pose>0 0.1 0 0 0 0</pose>
<child>left_finger_tip</child>
<parent>left_finger</parent>
<axis>
<limit>
<lower>-0.4</lower>
<upper>0.4</upper>
</limit>
<xyz>0 0 1</xyz>
</axis>
</joint>
<joint name="palm_right_finger" type="revolute">
<pose>0 0.15 0 0 0 0</pose>
<child>right_finger</child>
<parent>palm</parent>
<axis>
<limit>
<lower>-0.4</lower>
<upper>0.4</upper>
</limit>
<xyz>0 0 1</xyz>
</axis>
</joint>
<joint name="right_finger_tip" type="revolute">
<pose>0 0.1 0 0 0 0</pose>
<child>right_finger_tip</child>
<parent>right_finger</parent>
<axis>
<limit>
<lower>-0.4</lower>
<upper>0.4</upper>
</limit>
<xyz>0 0 1</xyz>
</axis>
</joint>
<joint name="palm_riser" type="prismatic">
<child>palm</child>
<parent>riser</parent>
<axis>
<limit>
<lower>0</lower>
<upper>0.9</upper>
</limit>
<xyz>0 0 1</xyz>
</axis>
</joint>
(8)然后重启刚才的文件
在View菜单栏,勾选以下两个View->Joints" and "View->Wireframe"
然后五个坐标就代表了五个joint,如下图所示
(9)运动控制
左侧右键点击某个link,例如palm,选择apply Force/Torque,然后弹出一个窗口:
然后设置X,Y,Z轴不同方向的力就可以移动不同的关节;
如果设置力的时候,没有动静,可以把力设置的大一点。
2.组成小车
(1)重新编辑model.sdf,修改尺寸与gripper相配合
gedit ~/.gazebo/models/my_robot/model.sdf
修改成以下内容:
<?xml version='1.0'?>
<sdf version='1.5'>
<model name="mobile_base">
<link name='chassis'>
<pose>0 0 .25 0 0 0</pose>
<inertial>
<mass>20.0</mass>
<pose>-0.1 0 -0.1 0 0 0</pose>
<inertia>
<ixx>0.5</ixx>
<iyy>1.0</iyy>
<izz>0.1</izz>
</inertia>
</inertial>
<collision name='collision'>
<geometry>
<box>
<size>2 1 0.3</size>
</box>
</geometry>
</collision>
<visual name='visual'>
<geometry>
<box>
<size>2 1 0.3</size>
</box>
</geometry>
</visual>
<collision name='caster_collision'>
<pose>-0.8 0 -0.125 0 0 0</pose>
<geometry>
<sphere>
<radius>.125</radius>
</sphere>
</geometry>
<surface>
<friction>
<ode>
<mu>0</mu>
<mu2>0</mu2>
</ode>
</friction>
</surface>
</collision>
<visual name='caster_visual'>
<pose>-0.8 0 -0.125 0 0 0</pose>
<geometry>
<sphere>
<radius>.125</radius>
</sphere>
</geometry>
</visual>
</link>
<link name="left_wheel">
<pose>0.8 0.6 0.125 0 1.5707 1.5707</pose>
<collision name="collision">
<geometry>
<cylinder>
<radius>.125</radius>
<length>.05</length>
</cylinder>
</geometry>
</collision>
<visual name="visual">
<geometry>
<cylinder>
<radius>.125</radius>
<length>.05</length>
</cylinder>
</geometry>
</visual>
</link>
<link name="right_wheel">
<pose>0.8 -0.6 0.125 0 1.5707 1.5707</pose>
<collision name="collision">
<geometry>
<cylinder>
<radius>.125</radius>
<length>.05</length>
</cylinder>
</geometry>
</collision>
<visual name="visual">
<geometry>
<cylinder>
<radius>.125</radius>
<length>.05</length>
</cylinder>
</geometry>
</visual>
</link>
<joint type="revolute" name="left_wheel_hinge">
<pose>0 0 -0.03 0 0 0</pose>
<child>left_wheel</child>
<parent>chassis</parent>
<axis>
<use_parent_model_frame>true</use_parent_model_frame>
<xyz>0 1 0</xyz>
</axis>
</joint>
<joint type="revolute" name="right_wheel_hinge">
<pose>0 0 0.03 0 0 0</pose>
<child>right_wheel</child>
<parent>chassis</parent>
<axis>
<use_parent_model_frame>true</use_parent_model_frame>
<xyz>0 1 0</xyz>
</axis>
</joint>
</model>
</sdf>
(2)构建
首先新建一个文件夹
mkdir ~/.gazebo/models/simple_mobile_manipulator
然后编辑配置文件
gedit ~/.gazebo/models/simple_mobile_manipulator/model.config
配置文件内容如下:
<?xml version="1.0"?>
<model>
<name>Simple Mobile Manipulator</name>
<version>1.0</version>
<sdf version='1.5'>manipulator.sdf</sdf>
<author>
<name>My Name</name>
<email>me@my.email</email>
</author>
<description>
My simple mobile manipulator
</description>
</model>
最后编写sdf文件
gedit ~/.gazebo/models/simple_mobile_manipulator/manipulator.sdf
内容如下:
<?xml version="1.0" ?>
<sdf version="1.5">
<model name="simple_mobile_manipulator">
<include>
<uri>model://my_gripper</uri>
<pose>1.3 0 0.1 0 0 0</pose>
</include>
<include>
<uri>model://my_robot</uri>
<pose>0 0 0 0 0 0</pose>
</include>
<joint name="arm_gripper_joint" type="fixed">
<parent>mobile_base::chassis</parent>
<child>simple_gripper::riser</child>
</joint>
<!-- attach sensor to the gripper -->
<include>
<uri>model://hokuyo</uri>
<pose>1.3 0 0.3 0 0 0</pose>
</include>
<joint name="hokuyo_joint" type="fixed">
<child>hokuyo::link</child>
<parent>simple_gripper::palm</parent>
</joint>
</model>
</sdf>
(3)运行
运行gazebo
然后insert相应的模型Simple Mobile Manipula
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)