Formula-Student-Driverless-Simulator icon indicating copy to clipboard operation
Formula-Student-Driverless-Simulator copied to clipboard

Custom map loading

Open wouter-heerwegh opened this issue 3 years ago • 16 comments

This pull request will try to implement loading of text files and loading this into the unreal engine environment without having to need Unreal engine.

This will allow us to create maps from rosbags and try and test our algorithms on them. It will also allow us to share these maps easily among the community.

Things to do:

  • [x] Read in a file into unreal engine
  • [x] Define format to store map data
  • [x] Add cones to scene
  • [x] Make custom start finish line for custom maps
  • [x] Add field in menu to select specific map
  • [x] Add documentation

Decisions:

  • Car will always start in (0, 0) with the heading 0 degrees

wouter-heerwegh avatar Jul 16 '22 10:07 wouter-heerwegh

As to the format for storing the map data, I know of at least 4 FS-AI teams using .csv files with this schema:

tag,x,y,direction,x_variance,y_variance,xy_covariance
blue,-45.0,1.5,0.0,0.01,0.01,0.0
yellow,20.0,-1.5,0.0,0.01,0.01,0.0
big_orange,25.0,-1.5,0.0,0.01,0.01,0.0
orange,30.0,1.5,0.0,0.01,0.01,0.0
car_start,-53.0,0.0,0.0,0.0,0.0,0.0

I think this is the schema that should be used. The variance and covariance fields can be ignored for now, as they are used for randomly moving cones a little to make the map more realistic (in that cones are never placed perfectly in real world)

mateusz-lichota avatar Jul 19 '22 12:07 mateusz-lichota

@mateusz-lichota Thats maybe a good starting point then, thanks for the suggestion! My other idea was putting everything in a json file, as it easier to structure, but I will stick with the csv format for now.

wouter-heerwegh avatar Jul 19 '22 13:07 wouter-heerwegh

Cones do not get added yet to referee, so I get some error, but I can change the positions of loaded blue and yellow cones

wouter-heerwegh avatar Jul 19 '22 20:07 wouter-heerwegh

One thing about the track format: the x and y values in the csv are in metres, but Unreal Engine uses centimeters so the values need to be multiplied by 100.0 when loading a custom map

mateusz-lichota avatar Jul 19 '22 23:07 mateusz-lichota

If backspace is used to reset the car, the rotation is reset to 0 degrees

wouter-heerwegh avatar Jul 21 '22 18:07 wouter-heerwegh

The location and rotation of the car get overwritten by the location in settings.json. This data is loaded into the VehicleSettings class. Accessing this object makes unreal engine crash. Trying to change the pawn pose by accessing the SimModeBase object.

wouter-heerwegh avatar Jul 21 '22 20:07 wouter-heerwegh

How about ignoring car_start and assuming it is always going to be (0, 0) with no rotation? It's fairly easy to translate the whole track to make car_start 0, and it would massively simplify implementation

mateusz-lichota avatar Jul 21 '22 21:07 mateusz-lichota

Or better yet, remove the car_start from the track definition schema and just make it start at (0,0) always. Users will just have to supply tracks that are already translated. I wouldn't have a problem with that, and in fact, it is wise to take the car starting point to be the point (0, 0)

mateusz-lichota avatar Jul 21 '22 21:07 mateusz-lichota

I was still trying with the SimModeBase, but didn't get it to work. Using (0, 0) seems the best choice for now indeed.

wouter-heerwegh avatar Jul 21 '22 22:07 wouter-heerwegh

Reverted both commits regarding movement of the car

wouter-heerwegh avatar Jul 22 '22 22:07 wouter-heerwegh

Currently I only do a rotation calculation if 2 big orange cones are used. Also, is it okay to assume that all maps loop back to the same point and thus have a start finish line and not a separate finish line like acceleration for instance?

wouter-heerwegh avatar Jul 23 '22 00:07 wouter-heerwegh

I'd say it is reasonable to assume that every custom map will be a loop, because acceleration and skidpad are already predefined

mateusz-lichota avatar Jul 23 '22 13:07 mateusz-lichota

I'll add some documentation explaining the format next week, and then this repo is ready to merge

wouter-heerwegh avatar Jul 23 '22 16:07 wouter-heerwegh

It would also be cool to be able to select the map to be loaded with a command line argument, and skip the menu entirely. I've got a prototype of that implemented, and I'll make finish the work once this is merged

mateusz-lichota avatar Jul 23 '22 17:07 mateusz-lichota

Added 4 big cones angle handling for the start/finish collision box. Will add documentation tomorrow.

wouter-heerwegh avatar Aug 03 '22 21:08 wouter-heerwegh

I added some documentation and tried out the first track from some rosbag I found from my team. It still contains duplicate cones, so I probably will change the map some other day

wouter-heerwegh avatar Aug 04 '22 21:08 wouter-heerwegh