Skip to content

NuclearVenom/ROS-2-setup-and-visualizing-a-CAD-model-in-RViz-2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 

Repository files navigation

ROS 2 Humble → Fusion 360 → URDF → RViz 2

Complete Beginner-Proof Workflow (Tested & Practical)


Overview

This document provides a complete, correct, and repeatable workflow for:

  • Installing ROS 2 Humble
  • Creating a ROS 2 workspace
  • Creating a robot description package
  • Exporting a robot model from Autodesk Fusion 360 to URDF
  • Fixing common CAD → URDF problems
  • Visualizing the robot in RViz2
  • Debugging URDF, TF, RViz, mesh, and launch errors

Assumptions

  • Zero prior ROS knowledge
  • You are using Ubuntu (native or WSL)
  • You want reliable results, not shortcuts

Prerequisites

Operating System

  • Ubuntu 22.04 (recommended)
  • Ubuntu on WSL2 is acceptable

System Requirements

  • Internet connection
  • At least 8 GB RAM recommended
  • GPU acceleration helps but is not required

Installing and Verifying ROS 2 Humble

Set Locale

sudo apt update
sudo apt install -y locales
sudo locale-gen en_US en_US.UTF-8
sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8

Add ROS 2 Repository

sudo apt install -y software-properties-common
sudo add-apt-repository universe
sudo apt update
sudo apt install -y curl
sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key \
  -o /usr/share/keyrings/ros-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] \
http://packages.ros.org/ros2/ubuntu $(lsb_release -cs) main" | \
sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null

Install ROS 2 Humble

sudo apt update
sudo apt install -y ros-humble-desktop

Source ROS 2 Automatically

echo "source /opt/ros/humble/setup.bash" >> ~/.bashrc
source ~/.bashrc

Verify Installation

ros2 --version

Expected Output:

ros2 cli version: 0.xx.x

Creating and Structuring a ROS 2 Workspace

Create Workspace

mkdir -p ~/ros2_ws/src
cd ~/ros2_ws

Build Empty Workspace

colcon build

Source Workspace

source install/setup.bash

Note: ROS only detects packages inside a sourced workspace.

Verify Workspace

ros2 pkg list

Expected: Many default ROS packages listed with no errors


Creating a Robot Description Package

Create Package

cd ~/ros2_ws/src
ros2 pkg create robot_description --build-type ament_cmake

Package Structure (Expected)

robot_description/
├── CMakeLists.txt
├── package.xml

Create Required Directories

cd robot_description
mkdir urdf meshes launch rviz

Fusion 360 → URDF Workflow

Prepare Model in Fusion 360

Mandatory rules:

  • Each moving part = one Component
  • Base body = grounded
  • Use revolute joints for wheels
  • Joint axes must be correct
  • Avoid spaces in component names

Install Fusion2URDF Add-In

Repository: https://github.com/syuntoku14/fusion2urdf

In Fusion 360:

Tools → Add-Ins → Scripts and Add-Ins → Add

Export Using Fusion2URDF

Enable:

  • URDF/Xacro export
  • Mesh export
  • Package structure export

Export result:

ROS_description/
├── urdf/
├── meshes/
├── CMakeLists.txt
├── package.xml

Copy Exported Package into Workspace

Copy from Windows (WSL)

cp -r /mnt/c/Users/<your_name>/Downloads/ROS_description ~/ros2_ws/src/

Verify

ls ~/ros2_ws/src/ROS_description

Fixing Common Fusion → URDF Issues

Scale Issue (MOST COMMON)

Fusion exports in millimeters.

Fix in URDF/Xacro:

scale="0.001 0.001 0.001"

Symptom: Robot invisible or extremely tiny in RViz.

Multiple <robot> Tags

URDF must contain only one <robot> element.

Check:

xacro ROS.xacro

Invalid Joint Names

❌ Bad: Revolute 1

✅ Good: revolute_1

Mesh Path Errors

✅ Correct:

package://robot_description/meshes/file.stl

❌ Incorrect:

/home/user/meshes/file.stl

Build the Package

cd ~/ros2_ws
colcon build
source install/setup.bash

Verify

ros2 pkg list | grep robot_description

RViz2 Visualization

Install Required Packages

sudo apt install -y \
ros-humble-robot-state-publisher \
ros-humble-joint-state-publisher \
ros-humble-joint-state-publisher-gui \
ros-humble-rviz2 \
ros-humble-xacro

Create Minimal Launch File

Create file:

nano launch/display.launch.py

Add content:

from launch import LaunchDescription
from launch_ros.actions import Node
from launch.substitutions import Command
from ament_index_python.packages import get_package_share_directory
import os

def generate_launch_description():
    pkg = get_package_share_directory('robot_description')
    xacro = os.path.join(pkg, 'urdf', 'robot.xacro')

    return LaunchDescription([
        Node(
            package='robot_state_publisher',
            executable='robot_state_publisher',
            parameters=[{'robot_description': Command(['xacro ', xacro])}]
        ),
        Node(
            package='joint_state_publisher_gui',
            executable='joint_state_publisher_gui'
        ),
        Node(
            package='rviz2',
            executable='rviz2'
        )
    ])

Launch

ros2 launch robot_description display.launch.py

RViz Setup

  • Fixed Frame: base_link
  • Add → RobotModel
  • Add → TF
  • Add → Grid

Debugging Common Errors

Model Not Visible

  • Wrong fixed frame
  • Scale too small
  • No TF published
  • No joint_state_publisher running

Mesh Not Found

ls install/robot_description/share/robot_description/meshes

Package Not Found

source install/setup.bash

TF Errors

ros2 run tf2_tools view_frames

URDF Syntax Errors

check_urdf robot.urdf

Validation Checklist

  • ros2 pkg list shows robot_description
  • check_urdf passes
  • RViz opens without errors
  • Robot visible
  • Joints move via GUI
  • TF tree valid

Final Notes

  • RViz is for runtime understanding, not simulation
  • Gazebo is required for physics
  • URDF correctness is critical
  • Always verify scale and TF first

This workflow is production-correct and scalable.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors