参考资料
开源项目:https://github.com/czhherry/self-driving-vehicle-101
rosWiki:http://wiki.ros.org/cn/ROS/Tutorials
launch
<node>
:标签指明启动所需的节点
eg :
<node name="controller_spawner" pkg="controller_manager" type="spawner" respawn="false"
output="screen" ns="/$(arg robot_name)"
args="joint_state_controller
rear_right_velocity_controller
rear_left_velocity_controller
front_right_steering_position_controller
front_left_steering_position_controller"/>
Attributes
- name: 节点名称
- pkg: 节点包
- type: 节点类型———包内的可执行文件
- respawn(optional, default: False): 如果节点挂掉是否自动重启
- respawn_delay=“30” (optional, default 0): 自动重启延迟
- output(optional, default:log(screen)"): 节点的输出信息流向,默认’log’:$ROS_HOME/log,‘screen’:屏幕
- ns=“foo”(optional): 在命名空间"foo"中运行节点
- args: 将参数传递给节点
- …
Elements
<remap>
: 话题重映射- Attributes:
- from=“original-name”
- to=“new-name”
- Attributes:
<env>
: 设置该节点的环境变量- Attributes
- name=“environment-variable-name”
- value=“environment-variable-value”
- Attributes
<rosparam>
<param>
<include>
: 包含其他到roslaunch文件到但前文件
eg:
<include file="$(find car_model)/launch/control.launch">
<arg name="robot_name" value="smart"/>
<arg name="config_file" value="smart_control_config.yaml"/>
</include>
Attributes
- file: “$(find pkg-name)/path/filename.launch”
- …
Elements
<arg>
: 向被include的文件传递参数<env>
<param>
: 在参数服务器中设置参数
eg:
<param name="robot_description" command="$(find xacro)/xacro '$(arg urdf_robot_file)' roboname:='smart'" />
Attributes
- name: 参数名称
- command(optional):
"$(find pkg-name)/exe '$(find pkg-name)/arg.txt'"
执行读取文件的命令 - value(optional): 参数值
- type(optional):
"str|int|double|bool|yaml"
<rosparam>
: 操作rosparam YAML文件
eg:
<rosparam file="$(find car_model)/config/$(arg config_file)" command="load"/>
Attributes
- command(optional, default=load): “load|dump|delete”
- file(optional): “$(find pkg-name)/path/foo.yaml” 文件名
- …
URDF
- Unified Robot Description Format
eg:
<link name="rear_right_wheel_link">
<collision>...</collision>
<visual>...</visual>
<inertial>...</inertial>
</link>
<link>
:刚体部分
-
<visual>
:外观参数eg:
<visual> <origin xyz="0 0 0" rpy="0 0 -${PI/2}"/> <geometry> <mesh filename="package://car_model/meshes/wheel.dae"/> <!-- <cylinder length="${rear_tyre_length}" radius="${rear_tyre_r}"/> --> </geometry> </visual>
-
<inertial>
:惯性参数eg:
<inertial> <origin xyz="0 0 0" rpy="0 0 0"/> <mass value="${rear_tyre_mass}"/> <inertia ixx="${rear_tyre_mass_ixx}" ixy="0.000000" ixz="0.000000" iyy="${rear_tyre_mass_iyy}" iyz="0.000000" izz="${rear_tyre_mass_izz}"/> </inertial>
-
<collision>
:碰撞参数eg:
<collision> <origin xyz="0 0 0" rpy="${PI/2} 0 0"/> <geometry> <cylinder length="${rear_tyre_length}" radius="${rear_tyre_r}"/> </geometry> </collision>
<joint>
:关节
eg:
<joint name="rear_left_wheel_joint" type="continuous">
<parent link="base_link"/>
<child link="rear_left_wheel_link"/>
<origin xyz="${-rear_tyre_x} ${rear_tyre_y} ${rear_tyre_r}" rpy="0 0 0"/>
<axis xyz="0 1 0"/>
<dynamics damping="0.1"/>
<limit effort="100000" velocity="10000" />
<joint_properties damping="0.0" friction="0.0" />
</joint>
- type:关节类型
- continuous:旋转关节,无限旋转
- revolute:旋转关节,有旋转角度极限
- prismatic:滑动关节,沿一轴线性移动,有位置极限
- planar:平面关节,允许在平面正交方向上平移或旋转
- floating:浮动关节,允许进行平移、旋转
- fixed:固定关节
<calibration>
:关节参考位置<dynamics>
:动力学属性,阻尼值、物理静摩擦力<limit>
:极限值,上下限、速度限制<mimic>
:与以有关节的关系<safety_controller>
:安全控制器参数
xacro
-
常量的定义与使用
<xacro:property name="M_PI" value="3.1415926/>` <origin xyz="0 0 0" rpy="${M_PI/2} 0 0"/>
-
数学计算 自动转换为浮点数
<origin xyz="0 ${(motor_length+wheel_length)/2} 0" rpy="0 0 0"/>
-
宏定义与使用
<xacro:macro name="NAME" params="A B C"> ... </xacro:macro> <NAME A="A_value" B="B_value" C="C_value"/>
-
文件包含
<xacro:include filename="$(find mbot_description)/urdf/xacro/mbot_base.xacro">
Gazebo
为link添加gazebo标签
<gazebo reference="link">
<material>Gazebo/Blue</material>
</gazebo>
为joint添加传动装置
<transmission name="${prefix}_wheel_joint_trans">
<type>transmission_interface/SimpleTransmission</type>
<joint name="${prefix}_wheel_joint" >
<hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface>
</joint>
<actuator name="${prefix}_wheel_joint_motor">
<hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface>
<mechanicalReduction>1</mechanicalReduction>
</actuator>
</transmission>
为gazebo添加控制器插件
eg:
<gazebo>
<plugin name="differential_drive_controller"
filename="libgazebo_r`os_diff_drive.so">
<rosDebugLevel>Debug</rosDebugLevel>
<publishWheelTF>true</publishWheelTF>
<robotNamespace>/</robotNamespace>
<publishTf>1</publishTf>
<publishWheelJointState>true</publishWheelJointState>
<alwaysOn>true</alwaysOn>
<updateRate>100.0</updateRate>
<legacyMode>true</legacyMode>
<leftJoint>left_wheel_joint</leftJoint>
<rightJoint>right_wheel_joint</rightJoint>
<wheelSeparation>${wheel_joint_y*2}</wheelSeparation>
<wheelDiameter>${2*wheel_radius}</wheelDiameter>
<broadcastTF>1</broadcastTF>
<wheelTorque>30</wheelTorque>
<wheelAcceleration>1.8</wheelAcceleration>
<commandTopic>cmd_vel</commandTopic>
<odometryFrame>odom</odometryFrame>
<odometryTopic>odom</odometryTopic>
<robotBaseFrame>base_footprint</robotBaseFrame>
</plugin>
</gazebo>
<robotNamespace>
: 机器人命名空间<leftJoint>,<rightJoint>
: 左右轮转动关节<wheelSeparation>,<wheelDiameter>
: 模型相关尺寸<commandTopic>
: 控制器订阅的指令<odometryFrame>
: 里程计数据到参考坐标系