Pavement Drive Assist

by Arcitos

Introduces a driver assistance system that autonomously follows paved roads, while maintaining a preset cruise speed if desired.

Utilities
4 years ago
0.14 - 0.18
182

i What about a tree-avoidance assist?

7 years ago
(updated 7 years ago)

Could you make a variation of this mod that makes vehicles avoid trees?

It could use a lot of the same code, but would look for tiles that don't have a tree, rock, or wall on them. Players could also add tiles to watch out for to the list. It would mark highest preference for tiles that are empty and also surrounded by empty tiles. Mid preference would go to tiles that are empty but adjacent to an item on the avoid list. Lowest preference would go to tiles with anything on the list. This way the vehicle would prefer a wider path but would take a narrow path over heading directly into trees.

It should maintain control while at low speed, since it's not going to do very well at avoiding trees at full speed. There's still some work on the driver's part in terms of avoiding thick clumps of trees as well as biter bases, but if the driver moves slowish and drives into sparsely wooded areas, the TAA should be able to (mostly) avoid trees. This would be extremely useful for navigating in the flimsy car as well as any weak-armored mod vehicles.

If trees, rocks, and walls were the only things on the avoid list, it could work great alongside PDA for navigating: you simply put walls near your base entrances, keep paved roads on the interior, and use TAA to navigate outside the walls.

7 years ago

Very cool suggestion! Its basicaly a (tree) collision avoidance system, isn't it?

This might be feasable. The new routine would scan the area for entities (or more precisely: their collision boxes) instead of tiles. But if we assume that the entities/collision boxes we aim to avoid are spread over on an two-dimensional area we need to scan the whole area to calculate a proper vector for the car's movement. This will inevitably lead to a horrific amount of load because the routine will process about 20-30 tiles every n ticks.

But i will try it nevertheless, because the difficulty of avoiding trees bothers me too. Maybe there is a solution that doesn't roast my CPU :D

Thanks again for your idea!

I was thinking try to make it seek tiles rather than collision boxes. If it can verify a tile doesn't have X items, it can give that tile a rating. Should the tile have one of the items, it gives it a different rating. Then it just seeks tiles the same way it seeks paved tiles, by rating.

It might be possible to check if a tile has any hit box at all in it, and rate them accordingly, then have it avoid all tiles with a hitbox. The issue then would be that not all hitboxes are aligned perfectly with the tile, but the player can choose driving paths with more room to grant a larger margin of error. It doesn't need to be perfect, the occasional tree collision is fine, simply reducing them by a good fraction would be impressive.

7 years ago

Hmmm... maybe you can use LuaSurace.count_entities_filtered or LuaSurface.find_non_colliding_position. I think for a collision-avoidance it would be enough to scan a fixed area in front of the car (say 3 2x2 rectangles for straight ahead, slightly left and slightly right), instead of a whole "ray". I think it should be enough just to know that there are trees/entities and avoid them, so counting and comparing scores, as in the pavement-following logic, will probably be an overkill...

7 years ago
(updated 7 years ago)

I tested LuaSurface.find-non-colliding-position aswell as LuaSurface.can_place_entity and experienced a quite big amount of load (testing 8 tiles every two ticks). The former was not as precise as i expected, the latter seems to be more precise and faster. But you're right - scanning tile by tile is overkill. The width of the vehicle is also variable. Scanning multiple collision boxes of the car in front of it (like 3-5 times) seems to be the right way. On collision detection it will trigger additional scans on the left or the right to determine the new vector of the car (or initiate braking). The scanner also needs to distiguish between entities that will collide with a car and entities that will not (like belts, rails, signals and so on).

New response