Sslishy / ROS_catkin

ros learning note
1 stars 0 forks source link

robot 模型合并过程 #2

Open Sslishy opened 2 years ago

Sslishy commented 2 years ago

手臂宏定义

 <?xml version="1.0"?>
<robot xmlns:xacro="http://wiki.ros.org/xacro">
  <xacro:macro name="hg_description" params="arm_id='hg' description_pkg:=''">
link 信息
 </xacro:macro>
</robot>

夹持器宏定义

<?xml version="1.0"?>
<robot xmlns:xacro="http://wiki.ros.org/xacro">
 <xacro:macro name="hand" params="connected_to:='' ns:='' rpy:='0 0 0' xyz:='0 0 0' description_pkg:=''">
    <xacro:unless value="${connected_to == ''}">
      <joint name="${ns}_hand_joint" type="fixed">
        <parent link="${connected_to}"/>
        <child link="gripper_base"/>
        <origin xyz="${xyz}" rpy="${rpy}"/>
      </joint>
    </xacro:unless> 
模型link信息
</xacro:macro>  
</robot>

将两个xacro 文件合并

<?xml version="1.0"?>
<robot name="hg_description" xmlns:xacro="http://wiki.ros.org/xacro">
  <xacro:include filename="$(find hg_descriptiontest)/urdf/hg_arc_macro.xacro" />
  <xacro:include filename="$(find hg_descriptiontest)/urdf/hand_arc_macro.xacro" />
  <xacro:hg_description description_pkg="hg_descriptiontest"/>
  <xacro:hand ns="hg" rpy="0 0 0" xyz="0 0 0" connected_to="hg_Link6" description_pkg="hg_descriptiontest"/>
</robot>
Sslishy commented 2 years ago

launch 制作

Sslishy commented 2 years ago

发射制作

首先LOAD模型

<?xml version="1.0"?>
<launch>
  <!-- Load robot description to parameter server -->
  <param name="robot_description" command="$(find xacro)/xacro '$(find hg_descriptiontest)/urdf/hg_arc.xacro'"/>
</launch>

然后显示在RVIZ上

<?xml version="1.0"?>
<launch>
  <include file="$(find hg_descriptiontest)/launch/load_arm.launch" />
  <node name="joint_state_publisher_gui" pkg="joint_state_publisher_gui" type="joint_state_publisher_gui">
  </node>
  <node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher"/>
  <node name="rviz" pkg="rviz" type="rviz" args="-d $(find hg_descriptiontest)/config/robot_state_visualize.rviz" required="true" />
</launch>
Sslishy commented 2 years ago

如果更改了最外层文件夹名称该怎么做?

Sslishy commented 2 years ago

如果改变了最外层一个名称 需要更改的地方是description_pkg:=''“”将这里改为当前文件夹名称 将带有$(find hg_descriptiontest)地方的代码find 地址该外当前文件夹地址