Coder Social home page Coder Social logo

mavengers / f1tenth_ws Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cl2-uwaterloo/f1tenth_ws

0.0 0.0 0.0 22.47 MB

A repository for autonomous racing written in ROS2, designed for the F1TENTH platform. Code can run both in the physical car, as well as simulation with custom launch files.

License: MIT License

C++ 58.84% Python 33.70% CMake 7.45%

f1tenth_ws's Introduction

f1tenth_ws

This a repository that contains ready-to-run autonomous racing packages for the F1TENTH on ROS2 Foxy. It can be directly be deployed on the physical car. We've also included launch and config files for the simulation environment, which uses slightly different topics for odometry.

Below is a demo of the car running the code from this repository in the E7 building at the University of Waterloo at a top speed of ~25km/h, record on March 30th 2023.

00108_4.mp4

Software Stack Overview

Our current software stack consists of

  • slam_toolbox for mapping (reference the following slides for running it on the physical car)
  • Particle Filter for localization $\rightarrow$ src/particle_filter
  • Pure Pursuit for waypoint following (planning + control) $\rightarrow$ src/pure_pursuit
  • RRT for a pure pursuit algorithm that includes dynamic obstacle avoidance (slightly slower) $\rightarrow$ src/rrt

Racing lines are generated through the Cl2-UWaterloo/Raceline-Optimization repository.

Other algorithms that are not used, but are in this repository include

  • Waypoint Generator for manually generating waypoints in simulation $\rightarrow$ src/waypoint_generator (this has been replaced with a script that automatically generates optimal racelines given a map)
  • A PID controller for staying at a constant distance to the wall $\rightarrow$ src/wall_follow
  • Scan matching $\rightarrow$ src/scan_matching (To be completed)
  • gap_follow $\rightarrow$ src/gap_follow (To be completed)

High-Level Usage Guide

These are the high level steps followed to get the F1TENTH driving in a new location, with accompanying notes:

  1. Run SLAM on the physical car to generate a map with slam_toolbox
  2. Clean up map in Photoshop, and generate a racing line using the Cl2-UWaterloo/Raceline-Optimization repository.
  3. Store the racing lines under src/pure_pursuit/racelines/
  4. Run particle_filter with the new map to localize the car properly
  5. Run pure_pursuit or rrt (for obstacle avoidance) to follow the racing line. Make sure to incrementally increase the velocity_profile inside the config.yaml file.

Getting Started

If you are a complete beginner and want to build an autonomous RC car, you might want to first follow the F1TENTH Course, where they teach you ROS2 and the intuition behind the algorithms in this repository. The official documentation contains information on setting up the hardware and software for the F1TENTH car.

Once you have access to an F1TENTH vehicle, you can consult our accompanying notes for the commands used to deploy the code in this repository: https://stevengong.co/notes/F1TENTH-Field-Usage. Note that they are mainly written for our own personal reference, so the paths will be different in your setup. You'll notice that we clone the repository on our local computer, and upload the code over SSH to the car.

Alternatively, you can try this code out in simulation without a physical car (see below).

Getting Started in Simulation

If you want to try out the ROS nodes in simulation, you can follow the steps below.We've tested these steps on a Ubuntu 20.04 native machine using Docker.

First, we will need to clone the simulation repository by running

git clone https://github.com/f1tenth/f1tenth_gym_ros

Then, build the docker image by running:

cd f1tenth_gym_ros
sudo docker build -t f1tenth_gym_ros -f Dockerfile .

You then need to mount the f1tenth_ws repository into the docker container. You will need to change the path in the command below:

cd <INSERT_PATH_HERE>/f1tenth_ws/src
sudo rocker --nvidia --x11 --volume .:/sim_ws/src -- f1tenth_gym_ros

You will then be entered the docker container. The f1tenth_ws code is mounted under /sim_ws/src/

Now, we need to load/change the default map in the simulation. In the container, modify the map_path parameter inside the sim.yaml file (located at /sim_ws/install/f1tenth_gym_ros/share/f1tenth_gym_ros/config/sim.yaml) to the path of the map you desire.

For example,

map_path: '/sim_ws/src/particle_filter/maps/e7_floor5'

Run the following commands from the /sim_ws directory:

source /opt/ros/foxy/setup.bash
source install/local_setup.bash
ros2 launch f1tenth_gym_ros gym_bridge_launch.py

Other tip: when your vehicle ends up in really bad spots, you can just use the "2D Pose Estimate" button inside rviz and select where you want to respawn the vehicle. Quite convenient!

To run the ROS2 nodes from this repository (ex: pure_pursuit), you need to run these commands from /sim_ws/src/f1tenth_gym_ros in another window (tip: use tmux):

colcon build
. install/setup.bash
ros2 launch pure_pursuit sim_pure_pursuit_launch.py

If you don't know what the above commands do, you probably should get familiar with ROS2 first.

Next Steps

A non-exhaustive list of things we want to do in the future, include

  • Running SLAM + pure pursuit on the fly, without having to do the offline computation. Something like this would be incredible
  • Trying out MPC, something like this is awesome!

About Us

The Control, Learning and Logic (CL2) group at the University of Waterloo works on research that aims to develop methods for reliable decision-making of autonomous systems in the wild, led by professor Yash Vardhan Pant. Current members working on the F1TENTH is composed of Steven Gong, Oluwatofolafun Damilola Opeoluwa-Calebs, and Soham Lakhi.

f1tenth_ws's People

Contributors

hzheng40 avatar gongsta avatar kimnluong avatar nandantumu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.