Robot Model - URDF 2 에러 해결

김성빈·2024년 7월 12일
0

두개의 에러 발생

ROS

  1. version error
Command failed: bash --login -c "xacro '/home/vboxuser/bumperbot_ws/src/bumperbot_description/urdf/bumperbot.urdf' && env"
XML parsing error: XML or text declaration not at start of entity: line 22, column 0
when processing file: /home/vboxuser/bumperbot_ws/src/bumperbot_description/urdf/bumperbot.urdf

Check that:
 - Your XML is well-formed
 - You have the xacro xmlns declaration: xmlns:xacro="http://www.ros.org/wiki/xacro"

error

https://github.com/gkjohnson/vscode-urdf-preview?tab=readme-ov-file

  1. 문법에러
Could not render URDF due to: Error: Vector ${vec} does not have 3 values
Error: Vector ${vec} does not have 3 values
    at h (https://file+.vscode-resource.vscode-cdn.net/home/vboxuser/.vscode/extensions/ms-iot.vscode-ros-0.9.6/dist/webview.js:2:1481833)
    at https://file+.vscode-resource.vscode-cdn.net/home/vboxuser/.vscode/extensions/ms-iot.vscode-ros-0.9.6/dist/webview.js:2:1488205
    at Generator.next (<anonymous>)
    at https://file+.vscode-resource.vscode-cdn.net/home/vboxuser/.vscode/extensions/ms-iot.vscode-ros-0.9.6/dist/webview.js:2:1485370
    at new Promise (<anonymous>)
    at y (https://file+.vscode-resource.vscode-cdn.net/home/vboxuser/.vscode/extensions/ms-iot.vscode-ros-0.9.6/dist/webview.js:2:1485115)
    at S (https://file+.vscode-resource.vscode-cdn.net/home/vboxuser/.vscode/extensions/ms-iot.vscode-ros-0.9.6/dist/webview.js:2:1487153)
    at https://file+.vscode-resource.vscode-cdn.net/home/vboxuser/.vscode/extensions/ms-iot.vscode-ros-0.9.6/dist/webview.js:2:1488908
    at Generator.next (<anonymous>)
    at https://file+.vscode-resource.vscode-cdn.net/home/vboxuser/.vscode/extensions/ms-iot.vscode-ros-0.9.6/dist/webview.js:2:1485370
The following packages were not found in the workspace:
bumperbot_description

NOTE: If this occurs at startup, please try saving the open file to refresh.

fix



라즈베리파이, Nano 고정을 위한 브라켓 두개, 바퀴 2개 몸체 한개를 우선 연결 시켰다.

수정한 부분.

1. Extension


0.9.6버전으로 설치했음, 그냥 다운로드하면 0.9.2로 다운로드 되는데 시험판, 테스트판으로 설치하는 설정으로 다운로드하면 0.9.6 버전으로 다운로드 가능

다른버전 설치로 버전을 옮기면서 테스트 했는데

2. workspace activate

bumperbot_ws 폴더를 열고있는 VScode 터미널에서 아래 명령어를 실행시켜줌

source ~/bumperbot_ws/devel/setup.bash
cd ~/bumperbot_ws
catkin_make
source devel/setup.bash

3. CMakeLists

Extension 설치 관련으로 설정하다가 4개 설정칸이 떠서 여러번 테스트 하다 두번째것으로 했는데 그 뒤로부터 vscode 실행시 자동으로 bash 실행

vscode settings.js edit
"cmake.sourceDirectory": "/home/vboxuser/bumperbot_ws/src"

요약하자면 버전 수정 > WS 활성화가 돼야 동작 > CMake로 WS 활성 자동화 > 했는데 urdf preview에 변화가 없으면 다시 urdf 실행으로 해결하였다.

테스트로 virtual box를 재부팅 후 vscode를 실행시켰을때에도 자동으로 bash 실행과 preview가 정상적으로 동작했다.

Fix code

<?xml version="1.0"?>

<!-- 
로봇 구조 요약:
1. base_footprint: 로봇의 기준점
2. base_link: 로봇의 주 본체
3. wheel_right_link: 오른쪽 바퀴
4. wheel_left_link: 왼쪽 바퀴
5. caster_front_link: 전방 캐스터 휠
6. caster_rear_link: 후방 캐스터 휠

조인트 구조:
- base_joint: base_footprint와 base_link 연결 (고정)
- wheel_right_joint: base_link와 오른쪽 바퀴 연결 (연속 회전)
- wheel_left_joint: base_link와 왼쪽 바퀴 연결 (연속 회전)
- caster_front_joint: base_link와 전방 캐스터 연결 (고정)
- caster_rear_joint: base_link와 후방 캐스터 연결 (고정)

이 로봇은 두 개의 구동 바퀴와 두 개의 캐스터 휠을 가진 이동 로봇입니다.
STL 파일을 사용하여 각 부품의 3D 모델을 정의하고 있습니다.
-->

<!-- 로봇 정의 시작 -->
<robot name="bumperbot">
    <!-- 베이스 발자국 링크 정의 -->
    <link name="base_footprint">
    </link>

    <!-- 베이스 링크 정의 -->
    <link name="base_link">
        <visual>
            <origin rpy="0 0 0" xyz="0 0 0"/>
            <geometry>
                <!-- 베이스 링크의 3D 모델 파일 지정 -->
                <mesh filename="package://bumperbot_description/meshes/base_link.STL"/>
            </geometry>
        </visual>
    </link>

    <!-- 베이스 발자국과 베이스 링크를 연결하는 고정 조인트 -->
    <joint name="base_joint" type="fixed">
        <parent link="base_footprint"/>
        <child link="base_link"/>
        <origin rpy="0 0 0" xyz="0 0 0.033"/>
    </joint>

    <!-- 오른쪽 바퀴 링크 정의 -->
    <link name="wheel_right_link">
        <visual>
            <origin rpy="1.57 0 0" xyz="0 0 0"/>
            <geometry>
                <!-- 오른쪽 바퀴의 3D 모델 파일 지정 -->
                <mesh filename="package://bumperbot_description/meshes/wheel_right_link.STL"/>
            </geometry>
        </visual>
    </link>

    <!-- 오른쪽 바퀴 조인트 정의 (연속 회전) -->
    <joint name="wheel_right_joint" type="continuous">
        <origin rpy="0 0 0" xyz="0 -0.07 0"/>
        <parent link="base_link"/>
        <child link="wheel_right_link"/>
        <axis xyz="0 1 0"/>
    </joint>

    <!-- 왼쪽 바퀴 링크 정의 -->
    <link name="wheel_left_link">
        <visual>
            <origin rpy="-1.57 0 0" xyz="0 0 0"/>
            <geometry>
                <!-- 왼쪽 바퀴의 3D 모델 파일 지정 -->
                <mesh filename="package://bumperbot_description/meshes/wheel_left_link.STL"/>
            </geometry>
        </visual>
    </link>

    <!-- 왼쪽 바퀴 조인트 정의 (연속 회전) -->
    <joint name="wheel_left_joint" type="continuous">
        <origin rpy="0 0 0" xyz="0 0.07 0"/>
        <parent link="base_link"/>
        <child link="wheel_left_link"/>
        <axis xyz="0 1 0"/>
    </joint>

    <!-- 전방 캐스터 링크 정의 -->
    <link name="caster_front_link">
        <visual>
            <origin rpy="0 0 0" xyz="0 0 0"/>
            <geometry>
                <!-- 전방 캐스터의 3D 모델 파일 지정 -->
                <mesh filename="package://bumperbot_description/meshes/caster_front_link.STL"/>
            </geometry>
        </visual>
    </link>

    <!-- 전방 캐스터 조인트 정의 (고정) -->
    <joint name="caster_front_joint" type="fixed">
        <origin rpy="0 0 0" xyz="0.0475 0 -0.0275"/>
        <parent link="base_link"/>
        <child link="caster_front_link"/>
    </joint>   

    <!-- 후방 캐스터 링크 정의 -->
    <link name="caster_rear_link">
        <visual>
            <origin rpy="0 0 0" xyz="0 0 0"/>
            <geometry>
                <!-- 후방 캐스터의 3D 모델 파일 지정 -->
                <mesh filename="package://bumperbot_description/meshes/caster_rear_link.STL"/>
            </geometry>
        </visual>
    </link>

    <!-- 후방 캐스터 조인트 정의 (고정) -->
    <joint name="caster_rear_joint" type="fixed">
        <origin rpy="0 0 0" xyz="-0.0475 0 -0.0275"/>
        <parent link="base_link"/>
        <child link="caster_rear_link"/>
    </joint>
</robot>
<!-- 로봇 정의 끝 -->

vscode
settings.json

{
    "python.autoComplete.extraPaths": [
        "/opt/ros/noetic/lib/python3/dist-packages"
    ],
    "python.analysis.extraPaths": [
        "/opt/ros/noetic/lib/python3/dist-packages"
    ],
    "ros.distro": "noetic",
    "ros.packagePath": [
        "/home/vboxuser/bumperbot_ws/src",
        "/opt/ros/noetic/share"
    ],
    **"cmake.sourceDirectory": "/home/vboxuser/bumperbot_ws/src"**
}
profile
감사합니다. https://www.youtube.com/channel/UCxlkiu9_aWijoD7BannNM7w

0개의 댓글