Installation Guide
This tutorial provides a reproducible ROS 2 Jazzy environment compatible with MATLAB R2025.
It supports:
- Docker-based environments (recommended)
- Native Ubuntu installation (advanced users)
MATLAB Requirements
Supported Versions
- MATLAB R2025a
- MATLAB R2025b
Required Toolboxes
- Simulink
- ROS Toolbox
- Robotics System Toolbox
- Symbolic Math Toolbox
- Universal Robots Support Package
Supported Environments
You can run this tutorial using:
- Windows 11 + WSL2 + Docker
- Ubuntu 24 + Docker
- Ubuntu 24 Native (no Docker)
Installation Using the Script
All environments use:
bash install.sh
Script Modes Overview
| Mode | Installs Docker | Installs ROS | Builds Workspace | Use Case |
|---|---|---|---|---|
| fulldocker | ✅ Yes | Inside container | ✅ Yes | Fresh machine |
| docker | ❌ No | Inside container | ✅ Yes | Docker already installed |
| fullnative | ❌ No | ✅ Yes | ✅ Yes | Native Ubuntu |
| native | ❌ No | ❌ No | ✅ Yes | ROS already installed |
Docker Installation (Recommended)
Docker provides:
- Reproducibility
- MATLAB integration
- Easy setup
Windows 11 + WSL2 + Docker
1. Install WSL2
Install Ubuntu 24:
https://learn.microsoft.com/en-us/windows/wsl/install
2. Install Using Script
Inside WSL:
git clone -b docker https://github.com/iocroblab/from_code_to_robot_ros2_stack.gitcd from_code_to_robot_ros2_stack/scriptsbash install.sh fulldocker
This will:
- Install Docker Engine
- Build the tutorial Docker image
- Create the container named FCTR-container
If Docker is already installed in WSL
git clone -b docker https://github.com/iocroblab/from_code_to_robot_ros2_stack.gitcd from_code_to_robot_ros2_stack/scriptsbash install.sh docker
This will:
- Build the tutorial Docker image
- Create the preconfigured container
Docker Container Behavior
The installer:
- Builds the image
- Creates a named container
- Leaves it stopped
MATLAB will:
- Start the container
- Attach to it
- Manage lifecycle automatically
Custom Docker Options
If using a custom container name:
StartTutorialApplication('Rviz','model','ur3','DockerName','YourContainerName');
If workspace location differs:
StartTutorialApplication('Rviz','model','ur3','Workspace','path/to/workspace');
Ubuntu 24 + Docker
If Docker is NOT installed yet (recommended path)
Install everything via script:
git clone -b docker https://github.com/iocroblab/from_code_to_robot_ros2_stack.gitcd from_code_to_robot_ros2_stack/scriptsbashinstall.sh fulldocker
If Docker is already installed
To install Docker manually follow:
https://docs.docker.com/engine/install/ubuntu/
Then run:
git clone -b docker https://github.com/iocroblab/from_code_to_robot_ros2_stack.gitcd from_code_to_robot_ros2_stack/scriptsbashinstall.sh docker
This will:
- Build your custom tutorial Docker image
- Create container
FCTR-container(stopped)
Manually install docker (no script)
Step 1 — Install docker
To install Docker manually follow:
https://docs.docker.com/engine/install/ubuntu/
Step 2 — Clone the Tutorial Repository
git clone -b docker https://github.com/iocroblab/from_code_to_robot_ros2_stack.gitcd from_code_to_robot_ros2_stack
Step 3 — Build the Tutorial Docker Image
Navigate to the Docker folder (location may vary slightly depending on repo structure):
docker build -t from-code-to-robot-tutorial-docker docker
This builds the custom tutorial image containing:
- ROS 2 Jazzy
- Gazebo / ros_gz
- ros2_control stack
- Tutorial workspace
Step 4 — Create the Tutorial Container
Create the container manually:
xhost +``local:docker
docker create \\
--name FCTR-container \\
--env``=``"DISPLAY=``\$DISPLAY``" \\
--env``=``"QT_X11_NO_MITSHM=1" \\
--volume``=``"/tmp/.X11-unix:/tmp/.X11-unix:rw" \\
--device /dev/snd \\
--net``=``host \\
from-code-to-robot-tutorial-docker \\
bash -lc "trap : TERM INT; sleep infinity & wait"
This creates a stopped container named:
FCTR-container
The container:
- Is not running yet
- Will be started automatically by MATLAB
Test in MATLAB (Ubuntu MATLAB)
Add the robotics folder and subfolders to path, then run:
StartTutorialApplication('Rviz','model','ur5e');
JointStatesToRviz([0,-pi/2,0,-pi/2,0,0]);
StopTutorialApplications();
StartTutorialApplication('Simulation','model','ur3e','controller','effort');
StopTutorialApplications();
Extra Docker info
If your container name differs:
StartTutorialApplication('Rviz','model','ur3','DockerName','YourContainerName');
If your workspace path differs:
StartTutorialApplication('Rviz','model','ur3','Workspace','path/to/workspace');
Native Ubuntu Installation (No Docker)
Native installation gives:
- Higher performance
- Lower latency
- Better hardware access
Option 1 — Automatic Native Install (With ROS installation)
Installs ROS + dependencies + workspace.
git clone -b docker https://github.com/iocroblab/from_code_to_robot_ros2_stack.gitcd from_code_to_robot_ros2_stack/scriptsbash install.sh fullnative
Installs:
- ROS 2 Jazzy Desktop
- Gazebo + ros_gz
- ros2_control stack
- DDS middleware
- Workspace dependencies
- Full build
Option 2 — Workspace Only (ROS already installed)
Use this if ROS 2 Jazzy is already installed.
git clone -b docker https://github.com/iocroblab/from_code_to_robot_ros2_stack.gitcd from_code_to_robot_ros2_stack/scriptsbash install.sh native
This will:
- Clone workspace
- Import repositories
- Run rosdep
- Build with colcon
Option 3 — Manual Native Workspace Setup (No Script)
For advanced users who prefer manual setup.
1. Install ROS 2 Jazzy
Follow official guide:
https://docs.ros.org/en/jazzy/Installation/Ubuntu-Install-Debians.html
2. Install Required Tools
sudo apt updatesudo apt install -y \\git \\build-essential \\cmake \\pkg-config \\python3-pip \\python3-venv \\python3-colcon-common-extensions \\python3-rosdep \\python3-vcstool \\python3-argcomplete \\wget curl
3.Install ROS packages
- sudo apt install -y \
- ros-jazzy-desktop \
- ros-jazzy-ros-gz \
- ros-jazzy-gz-ros2-control \
- ros-jazzy-ros2-control \
- ros-jazzy-ros2-controllers \
- ros-jazzy-controller-manager \
- ros-jazzy-turtlebot3-msgs \
- ros-jazzy-rmw-cyclonedds-cpp \
- ros-jazzy-rmw-fastrtps-dynamic-cpp \
- ros-dev-tools
Initialize rosdep:
sudo rosdep initrosdep update
4. Create Workspace
- mkdir -p ~/fctr_ws/src
- cd ~/fctr_ws/src
- git clone -b jazzy https://github.com/iocroblab/from_code_to_robot_ros2_stack.git
- source /opt/ros/jazzy/setup.bash
- cd ..
mkdir-psrc/modified-repositoriesvcsimportsrc/modified-repositories<src/from_code_to_robot_ros2_stack/stack.repos
5. Build Workspace
- source /opt/ros/jazzy/setup.bash
rosdepupdaterosdepinstall--ignore-src--from-pathssrc-ycolconbuild--symlink-install--cmake-args-DCMAKE_BUILD_TYPE=Release
Using Native Mode in MATLAB
When using native Ubuntu:
StartTutorialApplication('Rviz','model','ur5e','Docker',false);
JointStatesToRviz([0,-pi/2,0,-pi/2,0,0];
StopTutorialApplications('Docker',false);
StartTutorialApplication('Simulation','model','ur3e','controller','effort','Docker',false);
StopTutorialApplications('Docker',false);
Troubleshooting
ROS not found
run and try again:
- source /opt/ros/jazzy/setup.bash
rosdep errors
- sudo rosdep init
- rosdep update
Docker permission errors
- sudo usermod -aG docker $USER
Then log out and back in.Recommended Setup
| Use Case | Recommended Mode |
|---|---|
| Students / teaching | Docker |
| MATLAB workflows | Docker |
| Real robots | Native |
| Performance simulation | Native |
| Development | Native |