Giter Site home page Giter Site logo

f1tenth_quickstart's Introduction

This repository is for providing a quick start on using the f1tenth_gym_ros to launch a F1tenth virtual compeition.

Quick demonstration by using example code

Preparation:

Install Docker see https://docs.docker.com/engine/install/
$ mkdir -p ~/f110_ws/src
$ cd ~/f110_ws/src/
$ git clone https://github.com/cosynus-lix/f1tenth_quickstart.git
$ git clone https://github.com/cosynus-lix/f1tenth_gym_ros

Single vehicle mode:

Step 1 - Launch the simulator

$ cd ~/f110_ws/src/f1tenth_gym_ros/
$ git checkout ros1_add_obstacles_set_pose_SINGLE
$ sudo ./build_docker.sh (it might take several minutes)
$ sudo ./docker.sh

Step 2 - Launch the controller

In another temrinal do:

$ cd ~/f110_ws/
$ catkin_make
$ source devel/setup.bash
$ roslaunch f1tenth_controller_example wall_following_agent_node_SINGLE.launch

You can also use keyboard as the controller to move the ego vehicle:

$ cd ~/f110_ws/
$ catkin_make
$ source devel/setup.bash
$ roslaunch f1tenth_controller_example rviz_with_keyboard_ctrl.launch

Step 3 - Add/remove obstacles and pose reset

To reset vehicle's pose, click 2D Pose Estimate in RVIZ.

To add or remove obstacles, click Publish Point in RVIZ. If you click in a free space, a square obstacle will be added. If you click on an obstacle, the obstacle will be removed. Please keep in mind that obstacles will be added on the fly and will disappear when the simulator is shutdown.

rviz buttons

Head-to-head mode, ego + opp:

Step 1 - Launch the simulator

$ cd ~/f110_ws/src/f1tenth_gym_ros/
$ git checkout multi_node_add_obstacles_set_pose_H2H
$ sudo ./build_docker.sh (it might take several minutes)
$ sudo ./docker.sh

Step 2 - Launch the controller

In another temrinal do :

$ cd ~/f110_ws/
$ catkin_make
$ source devel/setup.bash
$ roslaunch f1tenth_controller_example wall_following_agent_node_H2H.launch

Step 3 - Add/remove obstacles and pose reset

To reset vehicles' pose, click 2D Pose Estimate in RVIZ. The first click will set the pose for the ego vehicle and the second click will set the pose for the opponent vehicle.

To add or remove obstacles, same as in the single vehicle racing mode.

Change the track map

You can use the python script change_map.py to easily change track map by doing:

$ cd ~/f110_ws/
$ sudo python src/f1tenth_quickstart/change_map.py src/f1tenth_quickstart/maps/[map_name] (replace map_name by yourself, see paragraph below)
$ cd ~/f110_ws/src/f1tenth_gym_ros/
$ sudo ./build_docker.sh

We provided two different tracks, with / without obstacles, which is used in F1tenth virtual competition edition IFAC2020 and IROS2020. Their names are: map_name = berlin.png,berlin_OFFICIAL_obstacles.png,vegas.png,vegas_OFFICIAL_obstacles.png. You could find them in the folder maps/.

For more maps, you can have a look here and download chosed ones (with the corresponding .yaml) to maps/ for usage. You can also DIY a map (design a new one or add obstacles on an old one) by drawing pixels on map image (png/pgm/... files) under any picture editor! Just remember: white for free space and black for obstacles. Moreover, in the .yaml file, choose a small value for resolution and set the third coordinate of origin to a null value (e.g. 0).

It should just work perfertly! For more details on changing maps, we refer to the description here.

Write the controller code by yourself!

What to change?

  1. in src/: modify the file wall_following_agent_node.py or write an independent file with similiar structure; you can also write the controller in C++, refer to ROS Tutorial.
  2. the main point is to get environment information from the topic /scan(Message type - sensor_msgs/LaserScan, more details) and(or) /odom(Message type - nav_msgs/Odometry, more details), calculate the controll command and send to the topic /drive (Message type - ackermann_msgs/AckermannDrive, more details).
  3. in Launch/: in case that you write the controller in a new file, write a launch file similiar to wall_following_agent_node.launch.
  4. file package.xml: in case that you use new dependancies (such as ackermann_msgs etc), add them in this file.
  5. file CMakeLists.txt: in case that you write the controller in C++, you need to modify this file.

What is missing in the example code?

  1. in the example code, we only use the information of Lidar via the topic /scan but not /odom. You can use /odom to obtain the ego agent's odometry for your own algorithm!
  2. we have not use the information from the topic /race_info. You can subscript to it for getting both agents' elapsed runtimes, lap count, and the collsion info.
  3. for head-to-head mode, we suppose that the ego and opp vehicle use the same controller and put their controller inside a same file. Of course you can use different controllers for each! In practice, it is better to write their controllers in different files.

f1tenth_quickstart's People

Contributors

nanli42 avatar marialuizacvianna avatar francois-bidet avatar

Stargazers

 avatar  avatar Nicolas.H avatar jingtian ji avatar

Watchers

James Cloos avatar Samuel Mimram avatar Sergio Mover avatar  avatar Aloysio Galvão Lopes avatar Sylvie Putot avatar

f1tenth_quickstart's Issues

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.