关闭

ROS RVIZ小车模型

标签: rviz
489人阅读 评论(0) 收藏 举报
分类:

1、ROS URDF小车模型


安装urdf_tutorial包

$ sudo apt-get install ros-indigo-urdf-tutorial

2、创建功能包和依赖项


 $ cd catkin_ws/
 $ cd src/
 $ catkin_create_pkg smartcar urdf(std_msgs rospy roscpp urdf) 

语法
生成 .xml .txt文件,在smartcar文件下新建smart.urdf和display.launch文件
urdf文件添加如下代码


<?xml version="1.0"?>
<robot name="smartcar">
  <link name="base_link">
    <visual>
      <geometry>
        <box size="0.25 .16 .05"/>
    </geometry>
    <origin rpy="0 0 1.57075" xyz="0 0 0"/>
    <material name="blue">
        <color rgba="0 0 .8 1"/>
    </material>
    </visual>
 </link>

 <link name="right_front_wheel">
    <visual>
      <geometry>
        <cylinder length=".02" radius="0.025"/>
      </geometry>
      <material name="black">
        <color rgba="0 0 0 1"/>
      </material>
    </visual>
  </link>

  <joint name="right_front_wheel_joint" type="continuous">
    <axis xyz="0 0 1"/>
    <parent link="base_link"/>
    <child link="right_front_wheel"/>
    <origin rpy="0 1.57075 0" xyz="0.08 0.1 -0.03"/>
    <limit effort="100" velocity="100"/>
    <joint_properties damping="0.0" friction="0.0"/>
  </joint>

  <link name="right_back_wheel">
    <visual>
      <geometry>
        <cylinder length=".02" radius="0.025"/>
      </geometry>
      <material name="black">
        <color rgba="0 0 0 1"/>
      </material>
    </visual>
  </link>

  <joint name="right_back_wheel_joint" type="continuous">
    <axis xyz="0 0 1"/>
    <parent link="base_link"/>
    <child link="right_back_wheel"/>
    <origin rpy="0 1.57075 0" xyz="0.08 -0.1 -0.03"/>
    <limit effort="100" velocity="100"/>
    <joint_properties damping="0.0" friction="0.0"/>
 </joint>

 <link name="left_front_wheel">
    <visual>
      <geometry>
        <cylinder length=".02" radius="0.025"/>
      </geometry>
      <material name="black">
        <color rgba="0 0 0 1"/>
      </material>
    </visual>
  </link>

  <joint name="left_front_wheel_joint" type="continuous">
    <axis xyz="0 0 1"/>
    <parent link="base_link"/>
    <child link="left_front_wheel"/>
    <origin rpy="0 1.57075 0" xyz="-0.08 0.1 -0.03"/>
    <limit effort="100" velocity="100"/>
    <joint_properties damping="0.0" friction="0.0"/>
  </joint>

  <link name="left_back_wheel">
    <visual>
      <geometry>
        <cylinder length=".02" radius="0.025"/>
      </geometry>
      <material name="black">
        <color rgba="0 0 0 1"/>
      </material>
    </visual>
  </link>

  <joint name="left_back_wheel_joint" type="continuous">
    <axis xyz="0 0 1"/>
    <parent link="base_link"/>
    <child link="left_back_wheel"/>
    <origin rpy="0 1.57075 0" xyz="-0.08 -0.1 -0.03"/>
    <limit effort="100" velocity="100"/>
    <joint_properties damping="0.0" friction="0.0"/>
  </joint>

  <link name="demo_try">
   <visual>
    <geometry>
     <box size=".03 .03 .03"/>
   </geometry>
      <material name="red">
              <color rgba="1 0 0 1"/>
      </material>
     </visual>
   </link>

 <joint name="demo_joint" type="continuous">
    <axis xyz="0 0 1"/>
    <parent link="base_link"/>
    <child link="demo_try"/>
    <origin rpy="0 1.57075 0" xyz="0 0 0.03"/>
    <limit effort="100" velocity="100"/>
    <joint_properties damping="0.0" friction="0.0"/>
  </joint>

  <link name="head">
    <visual>
      <geometry>
        <box size=".02 .03 .03"/>
      </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 0.08 0.025"/>
  </joint>
</robot>

urdf文件语法


display.launch 加入如下代码

<launch>
    <arg name="model" />
    <arg name="gui" default="False" />
    <param name="smartcar" textfile="$(find smartcar)/smartcar.urdf" />
    <param name="use_gui" value="$(arg gui)"/>
    <node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher" />
    <node name="robot_state_publisher" pkg="robot_state_publisher" type="state_publisher" />
    <node name="rviz" pkg="rviz" type="rviz" args="-d $(find urdf_tutorial)/urdf.rviz" required="true" />
</launch>

launch文件可根据错误提示修改
保存.urdf .launch文件

3、运行

 $ roslaunch smartcar display.launch gui:=true 
1
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:1504次
    • 积分:45
    • 等级:
    • 排名:千里之外
    • 原创:3篇
    • 转载:0篇
    • 译文:0篇
    • 评论:1条
    文章分类
    文章存档
    最新评论