前言:此文章主要在上一节学习完ROS机器人URDF建模后为方便后续开发,做的一个RoBomatser机器人UDRF建模
一、新建launch文件
首先在~/catkin_ws/src/mbot_description/launch/urdf目录下创建Ydisplay_robot_with_laser_urdf.launch启动文件
<launch>
<param name="robot_description" textfile="$(find mbot_description)/urdf/Ymbot_base.urdf" />
<!-- 设置GUI参数,显示关节控制插件 -->
<param name="use_gui" value="true"/>
<!-- 运行joint_state_publisher节点,发布机器人的关节状态 -->
<node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher" />
<!-- 运行robot_state_publisher节点,发布tf -->
<node name="robot_state_publisher" pkg="robot_state_publisher" type="state_publisher" />
<!-- 运行rviz可视化界面 -->
<node name="rviz" pkg="rviz" type="rviz" args="-d $(find mbot_description)/config/mbot_urdf.rviz" required="true" />
</launch>
此文件用来启动Ymbot_base.urdf机器人文件
二、新建urdf文件
在~/catkin_ws/src/mbot_description/urdf/urdf目录下创建Ymbot_base.urdf机器人模型文件
<?xml version="1.0"?>
<robot name="mecanum_robot">
<link name="base_link">
<visual>
<geometry>
<box size="0.35 .22 .115"/>
</geometry>
<origin rpy="0 0 0" xyz="0 0 0"/>
<material name="blue">
<color rgba="0 0 .8 1"/>
</material>
</visual>
</link>
<link name="head">
<visual>
<geometry>
<box size=".21 .10 .05"/>
</geometry>
<material name="white">
<color rgba="1 1 1 1"/>
</material>
</visual>
</link>
<joint name="tobox" type="fixed">
<parent link="base_link"/>
<child link="head"/>
<origin xyz="-0.07 0 0.0825"/>
</joint>
<link name="lidar_chear">
<visual>
<geometry>
<box size=".07 .10 .045"/>
</geometry>
<material name="white">
<color rgba="1 1 1 1"/>
</material>
</visual>
</link>
<joint name="tobox3" type="fixed">
<parent link="base_link"/>
<child link="lidar_chear"/>
<origin xyz="0.14 0 0.08"/>
</joint>
<link name="laser_link">
<visual>
<geometry>
<cylinder length="0.04" radius="0.037"/>
</geometry>
<material name="red">
<color rgba="1 0 0 1"/>
</material>
</visual>
</link>
<joint name="laser_joint" type="fixed">
<origin xyz="0 0 0.0425" rpy="0 0 0"/>
<parent link="lidar_chear"/>
<child link="laser_link"/>
</joint>
<link name="front">
<visual>
<geometry>
<box size=".05 .335 .05"/>
</geometry>
<material name="black">
<color rgba="0 0 0 1"/>
</material>
</visual>
</link>
<joint name="tobox1" type="fixed">
<parent link="base_link"/>
<child link="front"/>
<origin xyz="0.2 0 -0.0325"/>
</joint>
<link name="left_front_wheel">
<visual>
<geometry>
<cylinder length=".04" radius="0.08"/>
</geometry>
<material name="yellow">
<color rgba="1 1 0 1"/>
</material>
</visual>
</link>
<joint name="left_front_wheel_joint" type="continuous">
<axis xyz="0 0 -1"/>
<parent link="front"/>
<child link="left_front_wheel"/>
<origin rpy="1.57075 0 0" xyz="0 0.1675 0"/>
<limit effort="100" velocity="100"/>
<joint_properties damping="0.0" friction="0.0"/>
</joint>
<link name="right_front_wheel">
<visual>
<geometry>
<cylinder length=".04" radius="0.08"/>
</geometry>
<material name="yellow">
<color rgba="1 1 0 1"/>
</material>
</visual>
</link>
<joint name="right_front_wheel_joint" type="continuous">
<axis xyz="0 0 -1"/>
<parent link="front"/>
<child link="right_front_wheel"/>
<origin rpy="1.57075 0 0" xyz="0 -0.1675 0"/>
<limit effort="100" velocity="100"/>
<joint_properties damping="0.0" friction="0.0"/>
</joint>
<link name="back">
<visual>
<geometry>
<box size=".05 .335 .05"/>
</geometry>
<material name="black">
<color rgba="0 0 0 1"/>
</material>
</visual>
</link>
<joint name="tobox2" type="fixed">
<parent link="base_link"/>
<child link="back"/>
<origin xyz="-0.2 0 -0.0325"/>
</joint>
<link name="right_back_wheel">
<visual>
<geometry>
<cylinder length=".04" radius="0.08"/>
</geometry>
<material name="yellow">
<color rgba="1 1 0 1"/>
</material>
</visual>
</link>
<joint name="right_back_wheel_joint" type="continuous">
<axis xyz="0 0 -1"/>
<parent link="back"/>
<child link="right_back_wheel"/>
<origin rpy="1.57075 0 0" xyz="0 -0.1675 0"/>
<limit effort="100" velocity="100"/>
<joint_properties damping="0.0" friction="0.0"/>
</joint>
<link name="left_back_wheel">
<visual>
<geometry>
<cylinder length=".04" radius="0.08"/>
</geometry>
<material name="yellow">
<color rgba="1 1 0 1"/>
</material>
</visual>
</link>
<joint name="left_back_wheel_joint" type="continuous">
<axis xyz="0 0 -1"/>
<parent link="back"/>
<child link="left_back_wheel"/>
<origin rpy="1.57075 0 0" xyz="0 0.1675 0"/>
<limit effort="100" velocity="100"/>
<joint_properties damping="0.0" friction="0.0"/>
</joint>
</robot>
注释2-3:
<robot name="mecanum_robot">
<link name="base_link">
机器人模型名字:mecanum_robot
机器人基础模块连接:base_link
注释:2-8-10:
<visual>
<geometry>
<box size="0.35 .22 .115"/>
</geometry>
<origin rpy="0 0 0" xyz="0 0 0"/>
<material name="blue">
<color rgba="0 0 .8 1"/>
</material>
</visual>
1.机器人长X轴长度35cm,Y轴宽度22cm,Z轴高度11.5cm
2.机器人rpy绕着X,Y,Z轴的旋转分别为0,也就是不旋转
3.机器人在xyz三个轴的不移动
4.机器人的颜色为蓝色,RGB编号为0 0 0.8 1,其中第四位1为不透明,0为透明
注释:16-31
<link name="head">
<visual>
<geometry>
<box size=".21 .10 .05"/>
</geometry>
<material name="white">
<color rgba="1 1 1 1"/>
</material>
</visual>
</link>
1.新建一个模块
<box size=".21 .10 .05"/>
长宽高为21cm,10cm,5cm
<joint name="tobox" type="fixed">
<parent link="base_link"/>
<child link="head"/>
<origin xyz="-0.07 0 0.0825"/>
</joint>
1.关节的名字为tobox,父link为base_link,子link为head,
2.基于父base_link关节,子head的位置在x,y,z轴的偏移分别为-0.07 0 0.0825
注释:左后轮子
<link name="left_back_wheel">
<visual>
<geometry>
<cylinder length=".04" radius="0.08"/>
</geometry>
<material name="yellow">
<color rgba="1 1 0 1"/>
</material>
</visual>
</link>
<joint name="left_back_wheel_joint" type="continuous">
<axis xyz="0 0 -1"/>
<parent link="back"/>
<child link="left_back_wheel"/>
<origin rpy="1.57075 0 0" xyz="0 0.1675 0"/>
<limit effort="100" velocity="100"/>
<joint_properties damping="0.0" friction="0.0"/>
</joint>
<cylinder length=".04" radius="0.08"/>
1.轮子的宽度为4cm,半径为8cm
<axis xyz="0 0 -1"/>
轮子绕着Z轴 顺时针旋转,在实验中是绕着Y轴顺时针旋转
<origin rpy="1.57075 0 0" xyz="0 0.1675 0"/>
轮子在绕着X轴旋转90度,也即是让轮子立起来,轮子在y轴的移动16.75cm
编写代码,分别建立front,back车轴连接,建立四个轮子,左前,右前,左后,右后轮子,建立激光雷达座,建立激光雷达模型,类似轮子.
执行launch文件
roslaunch mbot_description Ydispaly_robot_with_laser_urdf.launch