-
Notifications
You must be signed in to change notification settings - Fork 0
Installing ROS
- Separate Pages
The Robot Operating System (ROS) is one of the most popular frameworks to program robots.
Even though most computation can be handled on the board of our robots, it's still very useful to set up ROS on your computer for development, testing, and visualization. ROS used to only be available for Linux (at least painlessly), specifically, on Ubuntu. However, thanks to recent developments on RoboStack it can now run on Windows and Mac too. RoboStack builds a ROS environment on Conda; Other methods include using a VM like Parallel or Docker.
What’s Conda? It’s a Python environment similar to Anaconda but more barebones. It provides fast access to Python/Conda commands without a ton of extra packages pre-installed.
We’ll be using this Github by RoboStack and this installation guide..
This process involves two steps: configuring Mamba and installing Robostack-noetic. Mamba is the C++ equivalent of Conda (Python), being quicker to execute and more efficient. Mamba should be set up in your base environment.
If you already have Conda installed on your base environment, run the following on the command line to install Mamba:
conda install mamba -c conda-forge
Otherwise, Mamba can be obtained differently depending on your computer's OS:
The approach for Windows OS is to use Miniforge to install Conda, and then use the Conda command given above to acquire Mamba. This multi-step process may seem inefficient but is a much safer option with fewer complications compared to installing Mambaforge (and the other methods mentioned on Conda-Forge's GitHub page).
Download the Miniforge3 installer for Windows x86_64. Double-click on the .exe file in File Explorer and follow the Installation extension until Miniforge3 is completely set up. Microsoft Defender SmartScreen may prevent the program from running, be sure to click "Run anyway".
Search for "Miniforge Prompt" in the Start menu, and open it. As previously mentioned, Miniforge3 installed the Conda package onto your base environment (this can be confirmed by typing conda info into the terminal, which should return a list of data pertaining to the installation). From here, we use the command conda install mamba -c conda-forge to install Mamba. The Prompt will download and extract a large collection of Conda packages. Respond with "y" when the Prompt asks if it should proceed.
Mambaforge should be able to operate ROS properly. However, if you experience any complications (or you desire a platform that is more supportive of the command line) you can set up a Linux environment on your Windows computer by installing WSL. A lot of robotics research is currently conducted on Linux systems, and there are some commands/processes that do not translate cleanly when using Window's Command Prompt. Therefore, using WSL will reduce minor hiccups when using ROS.
Setting up WSL only takes two steps. First, enable Windows Subsystem for Linux by searching "Turn Windows features on or off" on the Start Menu. Next, download Ubuntu 20.04 LTS from the Microsoft Store. When you launch the Ubuntu Terminal for the first time, you will be directed to create a UNIX username and password. Then, run sudo apt update and sudo apt upgrade to load and install any updates to the various packages the Linux environment utilizes.
The following commands are taken from the Mambaforge installer. Execute them in the Ubuntu Terminal:
curl -L -O "https://github.com/conda-forge/miniforge/releases/latest/download/Mambaforge-$(uname)-$(uname -m).sh"bash Mambaforge-$(uname)-$(uname -m).sh
After bashing the Mambaforge installer, you will want to follow the instructions displayed on the terminal, until the installation completes.
Navigate to the conda-forge website, a community project with a more barebones structure: Conda Forge
Once here, follow the installation instructions at the bottom, using either the curl or wget commands in your terminal.
Follow the instruction commands in your terminal. Repeatedly press enter in order to read through the license, before accepting it. It should install the correct form of mambaforge for your specific operating system.
Note: Even if you have Conda already installed, it’s common to face issues with M1/M2 computers. In this case, we suggest you use the MambaForge installer as written above.
Great! Now after using either approach, you should be able to use mamba commands. To test this, run mamba info.
If you have a command not found error, try running this command:
export PATH=~/mambaforge/bin:$PATH
If you have any other errors, try troubleshooting using this link: https://robostack.github.io/FAQ.html
NOTE: The rest of the directions are identical regardless of which OS your computer runs. Be sure to run these commands in the appropriate terminal applications (specifically, continue to use the Miniforge Prompt for Windows).
Now that Mamba is installed, navigate to the appropriate directory (the fork of this project). Do not install Robostack in your main folder.
Then, create a Virtual Environment using mamba:
mamba create -n ros_env
mamba activate ros_env
To properly set up the environment, run the following commands:
# this adds the conda-forge channel to the new created environment configuration
conda config --env --add channels conda-forge
# and the robostack channel
conda config --env --add channels robostack-staging
# remove the defaults channel just in case. This might return an error if it is not in the list which is ok
conda config --env --remove channels defaults
Now that your environment is set up, install ros-noetic into the environment (ROS1)
mamba install ros-noetic-desktop
Then, deactivate the environment using mamba deactivate so that it installs before reactivating it using mamba activate ros_env
Finally, install additional compilers/packages:
mamba install compilers cmake pkg-config make ninja colcon-common-extensions
And you're done! Ensure your ROS is set up correctly with the following commands (perform on separate terminals):
mamba activate ros_env
roscore
and
mamba activate ros_env
rviz
While running rviz or similar programs, you may come across an error mentioning "Qt platform plugin"; this is especially likely if you are using Ubuntu via WSL on a Windows computer, in which case you will need to set up X11 Forwarding. This is a tool that runs graphic applications on a remote server. The first step is to edit the SSH configuration file. On the terminal, run nano /etc/ssh/ssh_config to open Ubuntu's in-terminal text editor. Set the parameters ForwardX11 and ForwardX11Trusted to "yes". Next, download the Xming X Server; any program that has a visual interface will be represented on the X Server. You will also need to download PuTTY, an application that creates SSH clients to connect your computer to the X Server.
Open the app "XLaunch" to configure an X Server. You want to select the following settings:
- Multiple Windows
- Start no client
- Disable access control
After launching the X Server, you should see an X-shaped icon on your device's taskbar. Hovering over the icon will display the number of "clients" (i.e., graphic applications) that are running on the server. The final step is to configure PuTTY, which connects your computer to the X Server; any visual programs (such as rviz will be sent to the X Server and displayed). When opening PuTTY, provide your computer's hostname (which can be found by typing hostname on the command line interface). Select "SSH" as the connection type, and then enable X11 forwarding (found under the "X11" category nested under SSH (SSH --> Auth --> X11)).
When you complete the configuration for PuTTY, it may show an unsuccessful connection. However, you can check if the X Server works by running a visual application such as xcalc or xclock. You're now ready to run visual simulations for your robot!
Even after setting up the X Server, rviz may fail to open. If you are experiencing a segmentation fault error, then you will need to:
- Edit your ".profile" file, which can be done by using the command
nano ~/.profileon Terminal - At the very end of the file, you'll want to add the following lines:
export LIBGL_ALWAYS_INDIRECT=0, andexport LIBGL_ALWAYS_SOFTWARE=1.Ctrl + OandCtrl + Xto save and exit.