This repository is for providing a quick start on using the f1tenth_gym_ros to launch a F1tenth virtual compeition.
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
$ 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
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
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.
$ 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
In another temrinal do :
$ cd ~/f110_ws/
$ catkin_make
$ source devel/setup.bash
$ roslaunch f1tenth_controller_example wall_following_agent_node_H2H.launch
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.
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.
- in
src/
: modify the filewall_following_agent_node.py
or write an independent file with similiar structure; you can also write the controller in C++, refer to ROS Tutorial. - 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). - in
Launch/
: in case that you write the controller in a new file, write a launch file similiar towall_following_agent_node.launch
. - file
package.xml
: in case that you use new dependancies (such asackermann_msgs
etc), add them in this file. - file
CMakeLists.txt
: in case that you write the controller in C++, you need to modify this file.
- 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! - 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. - 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.