初学URDF总结

来源:互联网 发布:ovid数据库 编辑:程序博客网 时间:2024/06/04 18:08

link.png

看图理解很重要!

写URDF分步骤:

打开:http://wiki.ros.org/urdf/Tutorials/Create%20your%20own%20urdf%20file

1,描述最基本的:robot name,link,joint,以及joint的parent和child;

2,添加jiont的origin坐标——平移加旋转:每个link有自己的坐标系,jiont平移坐标为该joint相对于parent  link的坐标,旋转坐标为child  link相对于parent link坐标系的旋转,逆时针为正;

针对jiont2<origin xyz="-2 5 0" rpy="0 0 1.57" />    ## rpy="0 0 1.57"表示绕Z轴逆时针旋转90度

3,添加joint的旋转轴axis,单位化的旋转轴向量,相对于child link坐标系的旋转;

针对jiont1: <axis xyz="-0.707 0.707 0" />    ##单位化的旋转轴向量


解析自己设计的.urdf文件

打开: http://wiki.ros.org/urdf/Tutorials/Parse%20a%20urdf%20file

urdf::Model model;   ## urdf::Model is a class containing robot model data structure.model.initFile(urdf_file)  ##返回解析成功或失败

纠错:

$ catkin_make$ .<path>/parser <path>my_robot.urdf# ./devel/lib/robot_description/parser /src/robot_description/urdf/my_robot.urdf (for example)   !!!!!这句改为<pre name="code" class="cpp"># ./devel/lib/robot_description/parser  src/robot_description/urdf/my_robot.urdf (for example)

codeapi

The URDF parser API contains the following methods:

  • Parse and build tree from XML: urdf::Model::initXml
  • Parse and build tree from File: urdf::Model::initFile
  • Parse and build tree from String: urdf::Model::initString
  • Get Root Link: urdf::Model::getRoot
  • Get Link by name urdf::Model::getLink
  • Get all Link's urdf::Model::getLinks
  • Get Joint by name urdf::Model::getJoint

机器人状态发布器:

链接: http://wiki.ros.org/robot_state_publisher/Tutorials/Using%20the%20robot%20state%20publisher%20on%20your%20own%20robot

robot state publisher以节点方式使用:

<launch><param name="robot_description" command="cat $(find my_pkg)/my_model.xml" /><node name="robot_state_publisher" pkg="robot_state_publisher" type="state_publisher" /> ##robot_state_publisher默认使用robot_description参数</launch>
或者
<launch><param name="pr2_description" command="cat $(find pkg)/model.xml" /><node pkg="robot_state_publisher" type="robot_state_publisher" name="rob_st_pub" ><remap from="robot_description" to="pr2_description" /><remap from="joint_states" to="different_joint_states" /></node></launch>

robot state publisher以库函数使用:

包含头文件

#include <robot_state_publisher/robot_state_publisher.h>
  // publish moving joints  void publishTransforms(const std::map<std::string, double>& joint_positions,                         const ros::Time& time);  // publish fixed joints  void publishFixedTransforms();




REFERENCE:ROS WIKI
0 0
原创粉丝点击