At this stage, you should already installed Ubuntu 22.04 and ROS2 humble.
You need both Autonomous and FSAE-Unity-Simulation repository, under same directory.
Don't forget to switch to correct branches !
mkdir projects
cd projects/
git clone https://github.com/UOA-FSAE/autonomous.git
git clone https://github.com/UOA-FSAE/FSAE-Unity-Simulation.git
cd autonomous/
git checkout nightly
Build all packages at Root of Autonomous Repo with colcon build
, It should finish without error.
- Use
colcon build --parallel-workers Number
to avoid machine freeze/crash. - Some packages/msgs we used are not included in default installation of ROS2. Some of them are listed below:
sudo apt install ros-$ROS_DISTRO-foxglove-bridge \
ros-$ROS_DISTRO-foxglove-msgs \
ros-$ROS_DISTRO-ackermann-msgs
Follow the instructions to install Unity Hub and Foxglove on linux. You also need to creat an individual/student account to use them free.
-
Launch Unity Hub just installed and Log in
-
Go to Projects -> Add Projects, then select FSAE-Unity-Simulation folder
-
A recommended Unity Editor version will be suggested, install.
-
Double click to open the project. You should see a window like this
-
In the lower left corner, There is a content library. Scroll down and click on Scenes.
-
Drag the TrackSimulator scene into hierachy in the upper left region. Then right click the Untitled scene and remove it.
- Click the play button (Little Triangle) in the Unity Editor. Wait for it to fully load.
- Open a terminal and type:
ros2 topic list
- The output should be this:
/parameter_events
/race_controller/create
/race_controller/race_stats
/race_controller/reset
/rosout
- Go the root of Autonomus repo, open a terminal and run:
. unity_qucik_start.sh
- After several terminal windows pop up, the Simulation should start running. If not, check each of the window for any error messages.
If the terminal only shows /parameter_events
and /rosout
, it means the connection between Unity and ROS2 is not established.
A likely reason is that the ROS Domain IDs don't match. Unity uses ROS Domain ID 0. You can open .bashrc
file in home directory and add the following to the end.
export ROS_DOMAIN_ID=0
Some members also find launching Unityhub from terminal can be helpful
unityhub