参考blog: https://blog.csdn.net/ktigerhero3/article/details/64439815
https://blog.csdn.net/sujun3304/article/details/18962719
其中:
rpy角是描述船舶在海中航行时姿态的一种方法. 将船的行驶方向取为z轴, 绕z轴旋转称为滚动(Roll), 绕y轴旋转称为俯仰(Pitch), 绕x轴旋转称为偏转(Yaw).
<origin xyz="0 0 .1" rpy="0 0 -1.57" />
xyz表示空间原点位置 ,rpy 0,0,-1.57 表示初始pose为绕上一级坐标系的z轴(?)顺时针旋转90度(1.57=pi/2,一周为2pi)。
<?xml version="1.0"?>
<robot name="spqrobot">
<link name="base_link">
<visual>
<geometry>
<box size="0.36 .18 .09"/>
</geometry>
<!--origin rpy="0 0 1.57075" xyz="0 0 0"/-->
<origin rpy="0 0 0" xyz="0 0 0.106"/>
<material name="grey">
<color rgba="0.5 0.5 .5 5"/>
</material>
</visual>
</link>
<link name="right_front_wheel">
<visual>
<geometry>
<cylinder length=".058" radius="0.0575"/>
</geometry>
<material name="grey2">
<color rgba="0.1 0.1 0.1 5"/>
</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="1.57075 0 0" xyz="0.1225 0.119 0.0575"/>
<limit effort="100" velocity="100"/>
<joint_properties damping="0.0" friction="0.0"/>
</joint>
<link name="right_back_wheel">
<visual>
<geometry>
<cylinder length=".058" radius="0.0575"/>
</geometry>
<material name="grey2">
<color rgba="0.1 0.1 0.1 5"/>
</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="1.57075 0 0" xyz="0.1225 -0.119 0.0575"/>
<limit effort="100" velocity="100"/>
<joint_properties damping="0.0" friction="0.0"/>
</joint>
<link name="left_front_wheel">
<visual>
<geometry>
<cylinder length=".058" radius="0.0575"/>
</geometry>
<material name="grey2">
<color rgba="0.1 0.1 0.1 5"/>
</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="1.57075 0 0" xyz="-0.1225 0.119 0.0575"/>
<limit effort="100" velocity="100"/>
<joint_properties damping="0.0" friction="0.0"/>
</joint>
<link name="left_back_wheel">
<visual>
<geometry>
<cylinder length=".058" radius="0.0575"/>
</geometry>
<material name="grey2">
<color rgba="0.1 0.1 0.1 5"/>
</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="1.57075 0 0" xyz="-0.1225 -0.119 0.0575"/>
<limit effort="100" velocity="100"/>
<joint_properties damping="0.0" friction="0.0"/>
</joint>
<link name="head">
<visual>
<geometry>
<box size=".098 .07 .03"/>
</geometry>
<material name="black">
<color rgba=".6 .6 .6 5"/>
</material>
</visual>
</link>
<joint name="tobox" type="fixed">
<parent link="base_link"/>
<child link="head"/>
<origin xyz="0 0 0.151"/>
</joint>
<link name="head2">
<visual>
<geometry>
<cylinder length=".03" radius="0.035"/>
</geometry>
<material name="blue">
<color rgba="1 1 1 5"/>
</material>
</visual>
</link>
<joint name="tobox2" type="fixed">
<parent link="head"/>
<child link="head2"/>
<origin xyz="0.01 0 0.03"/>
</joint>
</robot>
launch文件:
<launch>
<arg name="model" default="/home/urdf.urdf" />
<!--arg name="gui" default="true" /-->
<arg name="rvizconfig" default="/home/rvizconfig.rviz" />
<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 name="robot_state_publisher" pkg="robot_state_publisher" type="state_publisher" />
<node name="rviz" pkg="rviz" type="rviz" args="-d $(arg rvizconfig)" required="true" />
</launch>