Skip to content

Napattnpp/F110th

Repository files navigation

First setup

Clone this project: cd ~ && git clone -b humble-dev https://github.com/Napattnpp/F110th.git
Auto setup: cd ~/F110th && ./setup_jetson_host.sh


ROS 2

Local setup

1. Install ROS 2

Make sure you have a locale which supports UTF-8

locale  # check for UTF-8

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  # verify settings

First ensure that the Ubuntu Universe repository is enabled.

sudo apt install software-properties-common
sudo add-apt-repository universe

Installing the ros2-apt-source package will configure ROS 2 repositories for your system

sudo apt update && sudo apt install curl -y
export ROS_APT_SOURCE_VERSION=$(curl -s https://api.github.com/repos/ros-infrastructure/ros-apt-source/releases/latest | grep -F "tag_name" | awk -F'"' '{print $4}')
curl -L -o /tmp/ros2-apt-source.deb "https://github.com/ros-infrastructure/ros-apt-source/releases/download/${ROS_APT_SOURCE_VERSION}/ros2-apt-source_${ROS_APT_SOURCE_VERSION}.$(. /etc/os-release && echo ${UBUNTU_CODENAME:-${VERSION_CODENAME}})_all.deb"
sudo dpkg -i /tmp/ros2-apt-source.deb

Development tools: Compilers and other tools to build ROS packages
sudo apt install ros-dev-tools

Update your apt repository caches after setting up the repositories.
sudo apt update && sudo apt upgrade

Desktop Install (Recommended): ROS, RViz, demos, tutorials.
sudo apt install ros-humble-desktop

Add sourcing to your shell startup script.
echo "source /opt/ros/humble/setup.bash" >> ~/.bashrc

The ROS_DOMAIN_ID variable.
echo "export ROS_DOMAIN_ID=<22>" >> ~/.bashrc

Install the turtlesim package for your ROS 2 distro

sudo apt update
sudo apt install ros-humble-turtlesim
sudo apt update
sudo apt install ros-humble-rqt ros-humble-rqt-common-plugins

sudo apt install python3-colcon-common-extensions


2. Additional require package for F1tenth

sudo apt install ros-$ROS_DISTRO-ackermann-msgs
sudo apt install ros-$ROS_DISTRO-serial-driver
sudo apt install ros-$ROS_DISTRO-asio-cmake-module
sudo apt install ros-$ROS_DISTRO-joy

Foxglove bridge

sudo apt install ros-$ROS_DISTRO-foxglove-bridge

tmux

sudo apt install tmux

Now Once you have a ROS 2 installation in the computer or docker, follow these steps to install the micro-ROS build system:

cd ~

# Source the ROS 2 installation
source /opt/ros/$ROS_DISTRO/setup.bash

# Create a workspace and download the micro-ROS tools
mkdir microros_ws
cd microros_ws
git clone -b $ROS_DISTRO https://github.com/micro-ROS/micro_ros_setup.git src/micro_ros_setup

# Update dependencies using rosdep
sudo apt update && rosdep update
rosdep install --from-paths src --ignore-src -y

# Install pip
sudo apt-get install python3-pip

# Build micro-ROS tools and source them
colcon build
source install/local_setup.bash

To install the micro-ros Agent follow the steps below:

# Download micro-ROS agent packages
ros2 run micro_ros_setup create_agent_ws.sh

We will now build the agent packages and, when this is done, source the installation:

# Build step
ros2 run micro_ros_setup build_agent.sh
source install/local_setup.bash

Docker setup

With Docker compose

When you are on the Jetson, you run:

  • docker compose --profile jetson up -d

When you are on your laptop, you run:

  • docker compose --profile macbook up -d

Without Docker compose

Jetson

xhost +local:root

docker run -it \
    --name f1tenth_jetson \
    --runtime nvidia \
    --restart unless-stopped \
    --network host \
    --ipc host \
    --pid host \
    --privileged \
    -v /dev:/dev \
    -v /run/udev:/run/udev:ro \
    -v /var/run/dbus/system_bus_socket:/var/run/dbus/system_bus_socket \
    -v /tmp/argus_socket:/tmp/argus_socket \
    -v /tmp/.X11-unix:/tmp/.X11-unix \
    -e DISPLAY=$DISPLAY \
    -v ~/F110th:/F110th \
    -v ~/f1tenth_logs:/logs
    napattnpp/f110th_img:humble-jetson \
    /bin/bash

Build for Jetson docker build -f Dockerfile.jetson -t humble-jetson .


Other general board

xhost +local:root

docker run -it \
    --name f1tenth_general \
    --network host \
    --ipc host \
    --pid host \
    --privileged \
    -v /dev:/dev \
    -v /run/udev:/run/udev:ro \
    -v /var/run/dbus/system_bus_socket:/var/run/dbus/system_bus_socket \
    -v /tmp/.X11-unix:/tmp/.X11-unix \
    -e DISPLAY=$DISPLAY \
    -v ~/F110th:/F110th \
    napattnpp/f110th_img:humble-general-a \
    /bin/bash

MacBook

xhost +

docker run -it \
    --name f1tenth_general \
    --privileged \
    -v /dev:/dev \
    -v ~/F110th:/F110th \
    -e DISPLAY=host.docker.internal:0 \
    napattnpp/f110th_img:humble-general-a \
    /bin/bash

Launching the Robot

  • Run F1 tenth stack: ros2 launch f1tenth_stack bringup_launch.py

  • Run micro ros: ros2 run micro_ros_agent micro_ros_agent serial --dev /dev/sensors/micro_ros

  • Run Foxglove bridge / ROS bridge

    • Foxglove bridge: ros2 launch foxglove_bridge foxglove_bridge_launch.xml
    • ROS bridge: ros2 launch rosbridge_server rosbridge_websocket_launch.xml
    • Fix ROS bridge error: sudo fuser -k 9090/tcp
  • Recording data

    • MCAP: ros2 bag record -s mcap -o <file_name> -a
    • .db3: ros2 bag record -o <file_name> -a
  • SLAM

    • Create a map: ros2 launch slam_toolbox online_async_launch.py params_file:=/F110th/src/f1tenth_system/f1tenth_stack/config/f1tenth_online_async.yaml
    • Save a map: ros2 run nav2_map_server map_saver_cli -f <map_name>

Algorithm

  • AEB: ros2 run safety_node safety_node_cpp
  • Wall following: ros2 run wall_follow wall_follow_node_cpp
  • Follow the gap: ros2 run gap_follow reactive_node_cpp
  • Waypoint generator: ros2 run waypoint_generator waypoint_generator
  • Pure pursuit: ros2 launch pure_pursuit sim_pure_pursuit_launch.py

Option

  • Dynamic Reconfigure: rqt -s rqt_reconfigure