(Archive) Install ROS2 and F1TENTH simulator from source - vaul-ulaval/vaul-wiki GitHub Wiki

ROS installation

Follow these steps to install ROS on your WSL2 Ubuntu 20.04 environment:

Step 1: Set Locale

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

Step 2: Set Up Repositories

sudo apt install software-properties-common
sudo add-apt-repository universe
sudo apt update && sudo apt install curl -y
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 $(. /etc/os-release && echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null

Step 3: Install ROS 2 Packages

sudo apt update
sudo apt upgrade
sudo apt install ros-foxy-desktop python3-argcomplete
sudo apt install ros-dev-tools

Step 4: Environment Setup

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

Step 5: Test ROS Installation

Terminal 1, run a C++ talker

ros2 run demo_nodes_cpp talker

Windows WSL2 User - Windows key - Search for : Ubuntu 20.04 - Open another session

Ubuntu or in the virtual machine - Open another terminal - crtl+alt+t

ros2 run demo_nodes_py listener

You should see the talker saying that it’s Publishing messages and the listener saying I heard those messages. This verifies both the C++ and Python APIs are working properly. Hooray!

Installation of F1TENTH Gym environment

Step 1: Install Pip

sudo apt update
sudo apt install python3-pip

Step 2: Install Gym Dependencies

git clone https://github.com/f1tenth/f1tenth_gym.git
cd f1tenth_gym
pip install -e .

Step 3: Test Run

cd examples
python3 waypoint_follow.py

Installation of F1TENTH Gym ROS

Step 1: Create a Workspace

cd $HOME && mkdir -p sim_ws/src

Step 2: Clone the Repository

cd $HOME/sim_ws/src
git clone https://github.com/f1tenth/f1tenth_gym_ros

Step 3: Update Map Path in sim.yaml

nano $HOME/sim_ws/src/f1tenth_gym_ros/config/sim.yaml

Change the map_path parameter to correct location. I try $HOME and it did not work put an absolute path

'<your_home_dir>/sim_ws/src/f1tenth_gym_ros/maps/levine'

Step 4: Install Dependencies with rosdep

source /opt/ros/foxy/setup.bash
sudo apt update
sudo apt install python3-rosdep2

rosdep

rosdep init
rosdep update --include-eol-distros
cd $HOME/sim_ws
rosdep install -i --from-path src --rosdistro foxy -y -r

Step 5: Build the Workspace

colcon build --symlink-install

Step 6: Source the Workspace in your terminal and add it to .bashrc

source install/setup.bash
echo "source $HOME/sim_ws/install/setup.bash" >> ~/.bashrc

Test run

Step 1: Run the Simulator

ros2 launch f1tenth_gym_ros gym_bridge_launch.py

often bug is a bad path for the map in the sim.yaml

Step 2: Open Another Terminal and Run Teleop

ros2 run teleop_twist_keyboard teleop_twist_keyboard

Check the instruction for driving with the keyboard. Enjoy!