ROS2 URDF(4)

2024. 10. 4. 09:26ROS2/URDF

오늘은 전에 만들었던 xacro파일을 매크로화 시키고 최종적으로 가제보에 띄워볼 계획이다.

 

<?xml version="1.0"?>
<robot xmlns:xacro="http://ros.org/wiki/xacro" name="rb10_1300e">

  <!-- Links -->
  <xacro:macro name="link" params="name visual_file collision_file mass inertia">
    <link name="${name}">
      <visual>
        <geometry>
          <mesh filename="file://$(find urdf_tutorial)/visual/${visual_file}"/>
        </geometry>
      </visual>
      <collision>
        <geometry>
          <mesh filename="file://$(find urdf_tutorial)/collision/${collision_file}"/>
        </geometry>
      </collision>
      <inertial>
        <origin rpy="0 0 0" xyz="0 0 0"/>
        <mass value="${mass}"/>
        <inertia>${inertia}</inertia>
      </inertial>
    </link>
  </xacro:macro>

  <!-- Define each link using the macro -->
  <xacro:link name="link0" visual_file="link0.dae" collision_file="link0.stl" mass="0" inertia=""/>
  <xacro:link name="link1" visual_file="link1.dae" collision_file="link1.stl" mass="8.366" 
              inertia="ixx='0.027403652' ixy='-5.926e-06' ixz='-1.0119e-05' 
                       iyy='0.027770573' iyz='0.003030512' izz='0.026140211'"/>
  <xacro:link name="link2" visual_file="link2.dae" collision_file="link2.stl" mass="15.61" 
              inertia="ixx='1.140650644' ixy='-1.3042e-05' ixz='-6.7084e-05' 
                       iyy='1.134398623' iyz='0.024507884' izz='0.050849068'"/>
  <xacro:link name="link3" visual_file="link3.dae" collision_file="link3.stl" mass="5.69" 
              inertia="ixx='0.312033029' ixy='9.298e-06' ixz='1.169e-05' 
                       iyy='0.311287646' iyz='0.005331552' izz='0.011397824'"/>
  <xacro:link name="link4" visual_file="link4.dae" collision_file="link4.stl" mass="2.062" 
              inertia="ixx='0.0027111' ixy='-8.022e-06' ixz='1.1208e-05' 
                       iyy='0.002715407' iyz='0.000144243' izz='0.002157043'"/>
  <xacro:link name="link5" visual_file="link5.dae" collision_file="link5.stl" mass="2.061" 
              inertia="ixx='0.002706437' ixy='1.1205e-05' ixz='-8.016e-06' 
                       iyy='0.002153592' iyz='0.000141528' izz='0.002712272'"/>
  <xacro:link name="link6" visual_file="link6.dae" collision_file="link6.stl" mass="0.406" 
              inertia="ixx='0.000345314' ixy='5.73e-07' ixz='6.61e-07' 
                       iyy='0.000532873' iyz='-5.4e-08' izz='0.000340021'"/>

  <link name="tcp"/>

  <!-- Joints -->
  <xacro:macro name="joint" params="name parent child xyz rpy axis">
    <joint name="${name}" type="revolute">
      <origin xyz="${xyz}" rpy="${rpy}"/>
      <parent link="${parent}"/>
      <child link="${child}"/>
      <axis xyz="${axis}"/>
      <limit effort="10" lower="-3.14" upper="3.14" velocity="3.14"/>
    </joint>
  </xacro:macro>

  <!-- Define each joint -->
  <xacro:joint name="base" parent="link0" child="link1" xyz="0 0 0.197" rpy="0 0 0" axis="0 0 1"/>
  <xacro:joint name="shoulder" parent="link1" child="link2" xyz="0 -0.1875 0" rpy="0 0 0" axis="0 1 0"/>
  <xacro:joint name="elbow" parent="link2" child="link3" xyz="0 0 0.6127" rpy="0 0 0" axis="0 1 0"/>
  <xacro:joint name="wrist1" parent="link3" child="link4" xyz="0 0.11715 0.57015" rpy="0 0 0" axis="0 1 0"/>
  <xacro:joint name="wrist2" parent="link4" child="link5" xyz="0 -0.11715 0" rpy="0 0 0" axis="0 0 1"/>
  <xacro:joint name="wrist3" parent="link5" child="link6" xyz="0 0 0.11715" rpy="0 0 0" axis="0 1 0"/>
  <xacro:joint name="tcp_joint" parent="link6" child="tcp" xyz="0 -0.1153 0" rpy="0 0 0" axis="0 0 0"/>

</robot>

 

이 코드를 돌리게 되면

Deprecated: xacro tag 'link' w/o 'xacro' xml namespace prefix (will be forbidden in F-turtle)
when processing file: /home/mgt/ch2_ws/install/urdf_tutorial/share/urdf_tutorial/urdf/rb10.xacro
Use the following command to fix incorrect tag usage:
find . -iname "*.xacro" | xargs sed -i 's#<\([/]\?\)\(if\|unless\|include\|arg\|property\|macro\|insert_block\)#<\1xacro:\2#g'

Task exception was never retrieved
future: <Task finished name='Task-2' coro=<LaunchService._process_one_event() done, defined at /opt/ros/foxy/lib/python3.8/site-packages/launch/launch_service.py:226> exception=InvalidLaunchFileError('py')>
Traceback (most recent call last):
  File "/opt/ros/foxy/lib/python3.8/site-packages/launch/launch_description_sources/any_launch_file_utilities.py", line 53, in get_launch_description_from_any_launch_file
    return loader(launch_file_path)
  File "/opt/ros/foxy/lib/python3.8/site-packages/launch/launch_description_sources/python_launch_file_utilities.py", line 68, in get_launch_description_from_python_launch_file
    return getattr(launch_file_module, 'generate_launch_description')()
  File "/home/mgt/ch2_ws/install/urdf_tutorial/share/urdf_tutorial/launch/robot_2.launch.py", line 14, in generate_launch_description
    robot_description = xacro.process_file(xacro_file)
  File "/opt/ros/foxy/lib/python3.8/site-packages/xacro/__init__.py", line 1074, in process_file
    process_doc(doc, **kwargs)
  File "/opt/ros/foxy/lib/python3.8/site-packages/xacro/__init__.py", line 1025, in process_doc
    eval_all(doc.documentElement, macros, symbols)
  File "/opt/ros/foxy/lib/python3.8/site-packages/xacro/__init__.py", line 955, in eval_all
    elif handle_macro_call(node, macros, symbols):
  File "/opt/ros/foxy/lib/python3.8/site-packages/xacro/__init__.py", line 797, in handle_macro_call
    eval_all(body, scoped_macros, scoped_symbols)
  File "/opt/ros/foxy/lib/python3.8/site-packages/xacro/__init__.py", line 955, in eval_all
    elif handle_macro_call(node, macros, symbols):
  File "/opt/ros/foxy/lib/python3.8/site-packages/xacro/__init__.py", line 779, in handle_macro_call
    raise XacroException("Unused block '%s'" % block.tagName, macro=m)
xacro.XacroException: Unused block 'visual'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/opt/ros/foxy/lib/python3.8/site-packages/launch/launch_service.py", line 228, in _process_one_event
    await self.__process_event(next_event)
  File "/opt/ros/foxy/lib/python3.8/site-packages/launch/launch_service.py", line 248, in __process_event
    visit_all_entities_and_collect_futures(entity, self.__context))
  File "/opt/ros/foxy/lib/python3.8/site-packages/launch/utilities/visit_all_entities_and_collect_futures_impl.py", line 45, in visit_all_entities_and_collect_futures
    futures_to_return += visit_all_entities_and_collect_futures(sub_entity, context)
  File "/opt/ros/foxy/lib/python3.8/site-packages/launch/utilities/visit_all_entities_and_collect_futures_impl.py", line 45, in visit_all_entities_and_collect_futures
    futures_to_return += visit_all_entities_and_collect_futures(sub_entity, context)
  File "/opt/ros/foxy/lib/python3.8/site-packages/launch/utilities/visit_all_entities_and_collect_futures_impl.py", line 38, in visit_all_entities_and_collect_futures
    sub_entities = entity.visit(context)
  File "/opt/ros/foxy/lib/python3.8/site-packages/launch/action.py", line 108, in visit
    return self.execute(context)
  File "/opt/ros/foxy/lib/python3.8/site-packages/launch/actions/include_launch_description.py", line 130, in execute
    launch_description = self.__launch_description_source.get_launch_description(context)
  File "/opt/ros/foxy/lib/python3.8/site-packages/launch/launch_description_source.py", line 84, in get_launch_description
    self._get_launch_description(self.__expanded_location)
  File "/opt/ros/foxy/lib/python3.8/site-packages/launch/launch_description_sources/any_launch_description_source.py", line 53, in _get_launch_description
    return get_launch_description_from_any_launch_file(location)
  File "/opt/ros/foxy/lib/python3.8/site-packages/launch/launch_description_sources/any_launch_file_utilities.py", line 56, in get_launch_description_from_any_launch_file
    raise InvalidLaunchFileError(extension, likely_errors=exceptions)
launch.invalid_launch_file_error.InvalidLaunchFileError: Caught exception when trying to load file of format [py]: Unused block 'visual'

이런 오류가 뜬다 간단하게 설명하자면 visual 블럭이 사용되고 있지않다는 뜻이다.

알고 봤더니 매크로의 이름을 link, joint로 해서 그런 것 같다.

그래서 이름을 바꾸어 주었다.

 

<?xml version="1.0"?>
<robot xmlns:xacro="http://ros.org/wiki/xacro" name="rb10_1300e">

  <!-- 링크 매크로 정의 -->
  <xacro:macro name="create_link" params="name visual_file collision_file mass inertia">
    <link name="${name}">
      <visual>
        <geometry>
          <mesh filename="file://$(find urdf_tutorial)/visual/${visual_file}"/>
        </geometry>
        <material name="blue"/> <!-- 원하는 재질로 변경 가능 -->
      </visual>
      <collision>
        <geometry>
          <mesh filename="file://$(find urdf_tutorial)/collision/${collision_file}"/>
        </geometry>
      </collision>
      <inertial>
        <origin rpy="0 0 0" xyz="0 0 0"/>
        <mass value="${mass}"/>
        <inertia>
          ${inertia}
        </inertia>
      </inertial>
    </link>
  </xacro:macro>

  <!-- 조인트 매크로 정의 -->
  <xacro:macro name="create_joint" params="name parent child xyz rpy axis type limit_effort limit_lower limit_upper limit_velocity">
    <joint name="${name}" type="${type}">
      <origin xyz="${xyz}" rpy="${rpy}"/>
      <parent link="${parent}"/>
      <child link="${child}"/>
      <axis xyz="${axis}"/>
      <limit effort="${limit_effort}" lower="${limit_lower}" upper="${limit_upper}" velocity="${limit_velocity}"/>
    </joint>
  </xacro:macro>

  <!-- 링크 정의 using 매크로 -->
  <xacro:create_link name="link0" visual_file="link0.dae" collision_file="link0.stl" mass="0" inertia="ixx='0.0' ixy='0.0' ixz='0.0' iyy='0.0' iyz='0.0' izz='0.0'"/>
  <xacro:create_link name="link1" visual_file="link1.dae" collision_file="link1.stl" mass="8.366" 
                     inertia="ixx='0.027403652' ixy='-5.926e-06' ixz='-1.0119e-05' 
                              iyy='0.027770573' iyz='0.003030512' izz='0.026140211'"/>
  <xacro:create_link name="link2" visual_file="link2.dae" collision_file="link2.stl" mass="15.61" 
                     inertia="ixx='1.140650644' ixy='-1.3042e-05' ixz='-6.7084e-05' 
                              iyy='1.134398623' iyz='0.024507884' izz='0.050849068'"/>
  <xacro:create_link name="link3" visual_file="link3.dae" collision_file="link3.stl" mass="5.69" 
                     inertia="ixx='0.312033029' ixy='9.298e-06' ixz='1.169e-05' 
                              iyy='0.311287646' iyz='0.005331552' izz='0.011397824'"/>
  <xacro:create_link name="link4" visual_file="link4.dae" collision_file="link4.stl" mass="2.062" 
                     inertia="ixx='0.0027111' ixy='-8.022e-06' ixz='1.1208e-05' 
                              iyy='0.002715407' iyz='0.000144243' izz='0.002157043'"/>
  <xacro:create_link name="link5" visual_file="link5.dae" collision_file="link5.stl" mass="2.061" 
                     inertia="ixx='0.002706437' ixy='1.1205e-05' ixz='-8.016e-06' 
                              iyy='0.002153592' iyz='0.000141528' izz='0.002712272'"/>
  <xacro:create_link name="link6" visual_file="link6.dae" collision_file="link6.stl" mass="0.406" 
                     inertia="ixx='0.000345314' ixy='5.73e-07' ixz='6.61e-07' 
                              iyy='0.000532873' iyz='-5.4e-08' izz='0.000340021'"/>
  <link name="tcp"/> <!-- tcp는 관성 속성이 없으므로 매크로를 사용하지 않음 -->

  <!-- 조인트 정의 using 매크로 -->
  <xacro:create_joint name="base" parent="link0" child="link1" xyz="0 0 0.197" rpy="0 0 0" axis="0 0 1" type="revolute" limit_effort="10" limit_lower="-3.14" limit_upper="3.14" limit_velocity="3.14"/>
  <xacro:create_joint name="shoulder" parent="link1" child="link2" xyz="0 -0.1875 0" rpy="0 0 0" axis="0 1 0" type="revolute" limit_effort="10" limit_lower="-3.14" limit_upper="3.14" limit_velocity="3.14"/>
  <xacro:create_joint name="elbow" parent="link2" child="link3" xyz="0 0 0.6127" rpy="0 0 0" axis="0 1 0" type="revolute" limit_effort="10" limit_lower="-3.14" limit_upper="3.14" limit_velocity="3.14"/>
  <xacro:create_joint name="wrist1" parent="link3" child="link4" xyz="0 0.11715 0.57015" rpy="0 0 0" axis="0 1 0" type="revolute" limit_effort="10" limit_lower="-3.14" limit_upper="3.14" limit_velocity="3.14"/>
  <xacro:create_joint name="wrist2" parent="link4" child="link5" xyz="0 -0.11715 0" rpy="0 0 0" axis="0 0 1" type="revolute" limit_effort="10" limit_lower="-3.14" limit_upper="3.14" limit_velocity="3.14"/>
  <xacro:create_joint name="wrist3" parent="link5" child="link6" xyz="0 0 0.11715" rpy="0 0 0" axis="0 1 0" type="revolute" limit_effort="10" limit_lower="-3.14" limit_upper="3.14" limit_velocity="3.14"/>
  <xacro:create_joint name="tcp_joint" parent="link6" child="tcp" xyz="0 -0.1153 0" rpy="0 0 0" axis="0 0 0" type="fixed" limit_effort="0" limit_lower="0" limit_upper="0" limit_velocity="0"/>
  
</robot>

이렇게 하니까 정상적으로 실행되었다.

근데 이런 에러가 뜨고

이렇게 로봇 모델 또한 불러와지지 않았다.

오류의 내용은 관성 모멘트 쪽의 값이 제대로 불러와지지 않았다.

그래서 코드를 다시 수정하여 값을 제대로 받아오도록 만들었다.

<?xml version="1.0"?>
<robot xmlns:xacro="http://ros.org/wiki/xacro" name="urdf_tutorial">

  <!-- 링크 매크로 정의 -->
  <xacro:macro name="create_link" params="name visual_file collision_file mass ixx ixy ixz iyy iyz izz">
    <link name="${name}">
      <visual>
        <geometry>
          <mesh filename="file://$(find urdf_tutorial)/visual/${visual_file}"/>
        </geometry>
      </visual>
      <collision>
        <geometry>
          <mesh filename="file://$(find urdf_tutorial)/collision/${collision_file}"/>
        </geometry>
      </collision>
      <inertial>
        <origin rpy="0 0 0" xyz="0 0 0"/>
        <mass value="${mass}"/>
        <inertia ixx="${ixx}" ixy="${ixy}" ixz="${ixz}" iyy="${iyy}" iyz="${iyz}" izz="${izz}"/>
      </inertial>
    </link>
  </xacro:macro>

  <!-- 조인트 매크로 정의 -->
  <xacro:macro name="create_joint" params="name parent child xyz rpy axis type limit_effort limit_lower limit_upper limit_velocity">
    <joint name="${name}" type="${type}">
      <origin xyz="${xyz}" rpy="${rpy}"/>
      <parent link="${parent}"/>
      <child link="${child}"/>
      <axis xyz="${axis}"/>
      <limit effort="${limit_effort}" lower="${limit_lower}" upper="${limit_upper}" velocity="${limit_velocity}"/>
    </joint>
  </xacro:macro>

  <!-- 링크 정의 using 매크로 -->
   <link name="base_link">
      <visual>
        <geometry>
          <mesh filename="file://$(find urdf_tutorial)/visual/link0.dae"/>
        </geometry>
      </visual>
      <collision>
        <geometry>
          <mesh filename="file://$(find urdf_tutorial)/collision/link0.stl"/>
        </geometry>
      </collision>
   </link>

  <xacro:create_link name="link1" visual_file="link1.dae" collision_file="link1.stl" mass="8.366" ixx="0.027403652" ixy="-5.926e-06" ixz="-1.0119e-05" iyy="0.027770573" iyz="0.003030512" izz="0.026140211"/>
  
  <xacro:create_link name="link2" visual_file="link2.dae" collision_file="link2.stl" mass="15.61" ixx="1.140650644" ixy="-1.3042e-05" ixz="-6.7084e-05" iyy="1.134398623" iyz="0.024507884" izz="0.050849068"/>
  
  <xacro:create_link name="link3" visual_file="link3.dae" collision_file="link3.stl" mass="5.69" ixx="0.312033029" ixy="9.298e-06" ixz="1.169e-05" iyy="0.311287646" iyz="0.005331552" izz="0.011397824"/>
  
  <xacro:create_link name="link4" visual_file="link4.dae" collision_file="link4.stl" mass="2.062" ixx="0.0027111" ixy="-8.022e-06" ixz="1.1208e-05" iyy="0.002715407" iyz="0.000144243" izz="0.002157043"/>
  
  <xacro:create_link name="link5" visual_file="link5.dae" collision_file="link5.stl" mass="2.061" ixx="0.002706437" ixy="1.1205e-05" ixz="-8.016e-06" iyy="0.002153592" iyz="0.000141528" izz="0.002712272"/>
  
  <xacro:create_link name="link6" visual_file="link6.dae" collision_file="link6.stl" mass="0.406" ixx="0.000345314" ixy="5.73e-07" ixz="6.61e-07" iyy="0.000532873" iyz="-5.4e-08" izz="0.000340021"/>
  
  <link name="tcp"/>
  
  <!-- 조인트 정의 using 매크로 -->
  <xacro:create_joint name="base" parent="base_link" child="link1" xyz="0 0 0.197" rpy="0 0 0" axis="0 0 1" type="revolute" limit_effort="10" limit_lower="-3.14" limit_upper="3.14" limit_velocity="3.14"/>
  <xacro:create_joint name="shoulder" parent="link1" child="link2" xyz="0 -0.1875 0" rpy="0 0 0" axis="0 1 0" type="revolute" limit_effort="10" limit_lower="-3.14" limit_upper="3.14" limit_velocity="3.14"/>
  <xacro:create_joint name="elbow" parent="link2" child="link3" xyz="0 0 0.6127" rpy="0 0 0" axis="0 1 0" type="revolute" limit_effort="10" limit_lower="-3.14" limit_upper="3.14" limit_velocity="3.14"/>
  <xacro:create_joint name="wrist1" parent="link3" child="link4" xyz="0 0.11715 0.57015" rpy="0 0 0" axis="0 1 0" type="revolute" limit_effort="10" limit_lower="-3.14" limit_upper="3.14" limit_velocity="3.14"/>
  <xacro:create_joint name="wrist2" parent="link4" child="link5" xyz="0 -0.11715 0" rpy="0 0 0" axis="0 0 1" type="revolute" limit_effort="10" limit_lower="-3.14" limit_upper="3.14" limit_velocity="3.14"/>
  <xacro:create_joint name="wrist3" parent="link5" child="link6" xyz="0 0 0.11715" rpy="0 0 0" axis="0 1 0" type="revolute" limit_effort="10" limit_lower="-3.14" limit_upper="3.14" limit_velocity="3.14"/>
  <xacro:create_joint name="tcp_joint" parent="link6" child="tcp" xyz="0 -0.1153 0" rpy="0 0 0" axis="0 0 0" type="fixed" limit_effort="0" limit_lower="0" limit_upper="0" limit_velocity="0"/>

</robot>

 

이후 가제보에 띄우기 위해 엄청나게 많은 오류가 뜰줄알았는데 아무런 오류없이 아무런 로봇도 가제보에 뜨지않았다.

오류는 뜨지 않는데 가제보에 로봇도 안떴다.... rviz2에는 정상적으로 뜨는데 왜 gazebo에만 안뜰까...

그래서 전에 만들었던 자동차와 비교해가며 뭐가 문제인지 어떤 부분이 다른지 비교해가며 계속 해보았다.

 

첫 번째 가설. stl파일과 dae파일이 문제다.

전에 만들었던 자동차 파일은 내부에서 visual, collision을 다뤘지 파일을 불러오는 일은 없었다.

그래서 나는 로봇팔 visual과 collision을 간단한 원통으로 만들어보았고 실험해 본 결과 똑같이 rviz2에만 뜨고 gazebo에는 뜨지 않았다.

 

두 번째 가설. 자동차 파일에는 있지만 로봇 팔 파일에는 없는 색상을 입혀주는 xml구문이 문제다.

똑같이 xml구문을 추가해보았지만 결과는 마찬가지였다.

 

세 번째 가설. control 구문을 임의 삭제한 것이 문제다.

지금 당장에 필요하지 않은 control 구문을 삭제한 것이 문제일까 생각도 해보았다.

그래서 자동차 파일에 있는 control구문도 똑같이 삭제해보았지만 자동차는 gazebo에 잘떴다.

그리고 잘 생각해보면 robot_description 토픽을 받아오는건데 control부분은 딱히 상관없다는 것을 깨달았다.

 

네 번째 가설. 혹시 link0이라고 되어 있는 부분때문에 오류가 난걸까?

원래 기본적으로 가장 밑단에는 base_link라고 쓰는데 레인보우 로보틱스 쪽에서는 제일 밑단을 link0으로 썼다.

그래서 나는 월요일에 자잘한 오류가 뜨는 것을 보고 base_link로 바꿨기 때문에 이것도 문제가 되지 않는다.

 

다섯 번째 가설. 가제보에 파일경로가 없어서 그렇다.

어차피 spawn 기능을 사용해서 로봇을 올리는거라 이것도 의미가 없었다.

 

여섯 번째 가설. 관성모멘트 값이 너무 작아서 문제다.

관성모멘트를 잘 살펴보면 굉장히 작은 숫자였고 소수점 아래로 꽤 길었기때문에 이것을 적절한 값으로 바꾸려고 했다.

여기서부터 문제를 찾았다.

gpt에게 적절한 값으로 바꾸어 달라고 했고 gpt가 만들어준 수치대로 넣었더니 아까 수정했던 원통형 로봇팔이 터지면서 가제보에 떴다.

 

일곱 번째 가설. 관성모멘트에 있는 소수점아래로 너무 길다.

그래서 나는 e를 이용한 문자로 소수점을 전부 다 교체하려고 했다.

그런데 이게 왠걸 gazebo에는 e를 인식을 못한다는 것을 알게되었다.

 

정답. 관성모멘트에 있는 e가 문제였다.

드디어 정답을 찾아낸 나는 관성모멘트에 있는 e를 모두 소수점으로 바꾸었고

gazebo에 로봇이 뜨게 되었다.

 

이 모든 과정중에 빨간글씨가 한번도 안뜬다는 것이 너무 힘들었다..

토픽도 제대로 받아와지고 rviz2에는 제대로 뜨고 gazebo에 spawn도 제대로 되었다는 신호도 받았는데 시각화만 안되니까 너무 답답했다.

 

그래서 결국 로봇을 불러왔다.

내 로봇팔은 마치 소금에 절여진 미꾸라지마냥 팔딱팔딱 거렸다.

base부분이 가벼워서 그런가 싶어 질량을 올려보았지만 똑같았다

그래서 gazebo에 있는 world링크에 고정시키기 위해 joint를 만들었다.

<?xml version="1.0"?>
<robot xmlns:xacro="http://ros.org/wiki/xacro" name="rb10_1300e">

    <!-- Link Definitions -->

    <link name="world"/>
    
    <link name="base_link">
      <visual>
        <geometry>
          <mesh filename="file://$(find urdf_tutorial)/visual/link0.dae"/>
        </geometry>
      </visual>
      <collision>
        <geometry>
          <mesh filename="file://$(find urdf_tutorial)/collision/link0.stl"/>
        </geometry>
      </collision>
      <inertial>
        <origin rpy="0 0 0" xyz="0 0 0"/>
        <mass value="1.0"/>
        <inertia ixx="0.00166667" ixy="0.0" ixz="0.0" iyy="0.00166667" iyz="0.0" izz="0.00166667"/>
      </inertial>
    </link>

    <link name="link1">
      <visual>
        <geometry>
          <mesh filename="file://$(find urdf_tutorial)/visual/link1.dae"/>
        </geometry>
      </visual>
      <collision>
        <geometry>
          <mesh filename="file://$(find urdf_tutorial)/collision/link1.stl"/>
        </geometry>
      </collision>
      <inertial>
        <origin rpy="0 0 0" xyz="0.000021 -0.007855 -0.042537"/>
        <mass value="8.366"/>
        <inertia ixx="0.027403652" ixy="-0.000005926" ixz="-0.000010119" iyy="0.027770573" iyz="0.003030512" izz="0.026140211"/>
      </inertial>
    </link>

    <link name="link2">
      <visual>
        <geometry>
          <mesh filename="file://$(find urdf_tutorial)/visual/link2.dae"/>
        </geometry>
      </visual>
      <collision>
        <geometry>
          <mesh filename="file://$(find urdf_tutorial)/collision/link2.stl"/>
        </geometry>
      </collision>
      <inertial>
        <origin rpy="0 0 0" xyz="-0.000013 -0.155462 0.225241"/>
        <mass value="15.61"/>
        <inertia ixx="1.140650644" ixy="-0.000013042" ixz="-0.000067084" iyy="1.134398623" iyz="0.024507884" izz="0.050849068"/>
      </inertial>
    </link>

    <link name="link3">
      <visual>
        <geometry>
          <mesh filename="file://$(find urdf_tutorial)/visual/link3.dae"/>
        </geometry>
      </visual>
      <collision>
        <geometry>
          <mesh filename="file://$(find urdf_tutorial)/collision/link3.stl"/>
        </geometry>
      </collision>
      <inertial>
        <origin rpy="0 0 0" xyz="-0.000048 -0.013885 0.325013"/>
        <mass value="5.69"/>
        <inertia ixx="0.312033029" ixy="0.000009298" ixz="0.000011690" iyy="0.311287646" iyz="0.005331552" izz="0.011397824"/>
      </inertial>
    </link>

    <link name="link4">
      <visual>
        <geometry>
          <mesh filename="file://$(find urdf_tutorial)/visual/link4.dae"/>
        </geometry>
      </visual>
      <collision>
        <geometry>
          <mesh filename="file://$(find urdf_tutorial)/collision/link4.stl"/>
        </geometry>
      </collision>
      <inertial>
        <origin rpy="0 0 0" xyz="0.000093 -0.113949 0.026461"/>
        <mass value="2.062"/>
        <inertia ixx="0.0027111" ixy="-0.000008022" ixz="0.000011208" iyy="0.002715407" iyz="0.000144243" izz="0.002157043"/>
      </inertial>
    </link>

    <link name="link5">
      <visual>
        <geometry>
          <mesh filename="file://$(find urdf_tutorial)/visual/link5.dae"/>
        </geometry>
      </visual>
      <collision>
        <geometry>
          <mesh filename="file://$(find urdf_tutorial)/collision/link5.stl"/>
        </geometry>
      </collision>
      <inertial>
        <origin rpy="0 0 0" xyz="-0.000093 -0.026434 -0.003233"/>
        <mass value="2.061"/>
        <inertia ixx="0.002706437" ixy="0.000011205" ixz="-0.000008016" iyy="0.002153592" iyz="0.000141528" izz="0.002712272"/>
      </inertial>
    </link>

    <link name="link6">
      <visual>
        <geometry>
          <mesh filename="file://$(find urdf_tutorial)/visual/link6.dae"/>
        </geometry>
      </visual>
      <collision>
        <geometry>
          <mesh filename="file://$(find urdf_tutorial)/collision/link6.stl"/>
        </geometry>
      </collision>
      <inertial>
        <origin rpy="0 0 0" xyz="-0.000210 -0.092540 -0.000292"/>
        <mass value="0.406"/>
        <inertia ixx="0.000345314" ixy="0.000000573" ixz="0.000000661" iyy="0.000532873" iyz="-0.000000054" izz="0.000340021"/>
      </inertial>
    </link>

    <link name="tcp"/>

    <!-- Joint Definitions -->
    <joint name="fixed_to_world" type="fixed">
      <parent link="world"/>
      <child link="base_link"/>
      <origin rpy="0 0 0" xyz="0 0 0"/>
    </joint>

    <joint name="base" type="revolute">
      <origin rpy="0 0 0" xyz="0 0 0.197"/>
      <parent link="base_link"/>
      <child link="link1"/>
      <axis xyz="0 0 1"/>
      <limit effort="10" lower="-3.14" upper="3.14" velocity="3.14"/>
    </joint>

    <joint name="shoulder" type="revolute">
      <origin rpy="0 0 0" xyz="0 -0.1875 0"/>
      <parent link="link1"/>
      <child link="link2"/>
      <axis xyz="0 1 0"/>
      <limit effort="10" lower="-3.14" upper="3.14" velocity="3.14"/>
    </joint>

    <joint name="elbow" type="revolute">
      <origin rpy="0 0 0" xyz="0 0 0.6127"/>
      <parent link="link2"/>
      <child link="link3"/>
      <axis xyz="0 1 0"/>
      <limit effort="10" lower="-3.14" upper="3.14" velocity="3.14"/>
    </joint>

    <joint name="wrist1" type="revolute">
      <origin rpy="0 0 0" xyz="0 0.11715 0.57015"/>
      <parent link="link3"/>
      <child link="link4"/>
      <axis xyz="0 1 0"/>
      <limit effort="10" lower="-3.14" upper="3.14" velocity="3.14"/>
    </joint>

    <joint name="wrist2" type="revolute">
      <origin rpy="0 0 0" xyz="0 -0.11715 0"/>
      <parent link="link4"/>
      <child link="link5"/>
      <axis xyz="0 0 1"/>
      <limit effort="10" lower="-3.14" upper="3.14" velocity="3.14"/>
    </joint>

    <joint name="wrist3" type="revolute">
      <origin rpy="0 0 0" xyz="0 0 0.11715"/>
      <parent link="link5"/>
      <child link="link6"/>
      <axis xyz="0 1 0"/>
      <limit effort="10" lower="-3.14" upper="3.14" velocity="3.14"/>
    </joint>

    <joint name="tcp_joint" type="fixed">
      <origin rpy="0 0 0" xyz="0 -0.1153 0"/>
      <parent link="link6"/>
      <child link="tcp"/>
    </joint>

</robot>

 

바닥에 고정은 되었지만 힘은 없다.

왜 그런지는 모르겠다. 지금 생각으로는 아마도 moveit을 써야하지않을까라는 생각을 해본다.

왜 joint_state_publisher_gui로는 안되는걸까 이것도  마찬가지로 rviz에서는 된다.

'ROS2 > URDF' 카테고리의 다른 글

ROS2 URDF rb10-1300  (0) 2024.11.08
ROS2 URDF doosan robot arm  (0) 2024.11.08
ROS2 URDF(3)  (0) 2024.09.30
ROS2 6일차(2) URDF  (0) 2024.09.27
ROS2 6일차(1) URDF  (0) 2024.09.27