This guide will walk you through setting up the simulation environment including Unity and ROS.
Start with a Ubuntu 20.04 desktop installation.
To install the Unity Editor, we need to (1) download Unity Hub, (2) create Unity Account and login, and (3) install the correct Unity Version. Besides our tutorial, you can follow the Unity Getting Started Guide.
Following the guide, run the following command to add the Unity Hub repository:
sudo sh -c 'echo "deb https://hub.unity3d.com/linux/repos/deb stable main" > /etc/apt/sources.list.d/unityhub.list'
To add the public signing key, run the following command:
wget -qO - https://hub.unity3d.com/linux/keys/public | sudo apt-key add -
Then update the package cache and install the package using:
sudo apt update sudo apt-get install unityhub
- If you do not have an account, create a Unity account now.
Note: signing up for a student account, though not required, will give you access to some free assets: https://assetstore.unity.com/browse/student-plan-pack
- Login to UnityHub.
Note: UnityHub can have trouble when Firefox is set to the default browser on Ubuntu 20.04. Installing the Google Chrome browser can fix this:
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb && sudo apt install ./google-chrome-stable_current_amd64.deb. You may also need to set Chrome as the default browser.
If prompted, accept the defaults to install Unity and optionally install any target build environments that you may want to build for in the future.
- Clone the unity project—the location of this project is not important, but we'll clone it to the home directory:
git clone --recurse-submodules https://github.com/yale-sean/social_sim_unity.git ~/social_sim_unity
In Unity Hub, add the project you just cloned by clicking the "Add" button. Choose the folder named "social_sim_unity" in the home directory. Once that folder is selected, click the "Ok" button to confirm your selection.
Note: if you are unable to add the project, create a new, blank project by clicking the "New" button, restart Unity Hub, and then try adding
Install ROS and Use Preconfigured Workspace.
Install by following the ROS Noetic Setup Guide. If you run into any problem or want to learn more about ROS Noetic, see ROS Noetic. Then, you can use the sim_ws as a starting point for your catkin workspace. Start by checking out the repository.
git clone https://github.com/yale-sean/sim_ws ~/sim_ws
Then, run the installer scripts to install all required packages:
cd ~/sim_ws/ ./scripts/setup.sh
After you are done, make sure you add
source commands in your
.bashrc file so ROS knows where your installed ROS packages are every time you open a terminal:
echo "source /opt/ros/noetic/setup.bash" >> $HOME/.bashrc echo "source ~/sim_ws/devel/setup.bash" >> $HOME/.bashrc source $HOME/.bashrc
You will see an error like
-bash: $HOME/sim_ws/devel/setup.bash: No such file or directory, which is fine. You can now build the workspace:
cd $HOME/sim_ws catkin_make
Then you can source the .bashrc file again without error:
cd $HOME/sim_ws catkin_make
(Optional) Docker Setup
Instead of creating and installing a workspace from scratch, you can use our Docker configuration to create a set of virtual machines in which the simulation platform can be run.
An advantage of this is that we also provide tools like a Tmuxinator configuration to easily start the necessary ROS components.
The Docker configuration is only tested on an Ubuntu 18.04 host machine with an CUDA compatible NVIDIA graphics card.
First, install the dependencies:
Also, don't forget to add your user to the docker group, as described in the Docker documentation post-install instructions for linux: https://docs.docker.com/engine/install/linux-postinstall/.
To use the Docker configuration:
- Clone the workspace into your home folder and
cdinto the workspace:
git clone --recurse-submodules https://github.com/yale-sean/sim_ws.git ~/sim_ws cd ~/sim_ws
- Build the Docker containers
./container build ros
- Start the containers with
./container start ros
- Enter a shell in the Docker Virtual Machine in your ROS workspace
./container shell ros
- Then within a container, run the checkout script to checkout the required repositories
- Build the workspace:
(Optional) Catkin Workspace From Scratch
If you installed ROS and have trouble using the preconfigured workspace, it's also possible to setup your workspace in
~/sim_ws from scratch.
sim_ws directory, run the commands found in the checkout.sh script.
Build the Workspace
source /opt/ros/noetic/setup.bash source ~/sim_ws/devel/setup.bash catkin_make -DCMAKE_BUILD_TYPE=Release
It is also recommended to add the
source commands to your
echo "source /opt/ros/noetic/setup.bash" >> $HOME/.bashrc echo "source ~/sim_ws/devel/setup.bash" >> $HOME/.bashrc