Skip to content

AcresRouteGuide.h#

Acres/Source/Acres/AcresRouteGuide.h Generated

The route guide of a piloted session: the lane and road graph of the scouting map (Content/Simulation/ACRE/Scouting/scouting_map.json, the key "graph") and the shortest route over it from the vehicle to a destination. The route is a guide for a human driver. It sends no command to a vehicle.

The route rule is that of TransitGraph.shortest_path of the learning stack (acres_learn.tasks.scouting. map_products): Dijkstra on the edge lengths of the undirected graph. The direction of the vehicle and the cost tables of the planner have no effect.

Positions are world metres with X east and Y south (Unreal without the factor 100). Game thread, but the file is read on a worker thread: IsReady() tells when the graph is there.

Name Type Unit Default Description
Kind FString junction, end, entry or home.
Kind FString lane, road, us52_crossing or connector.
Line TArray<FVector2D> The polyline from node A to node B, and the arc length at each point.
Name FString F01 to F59, RF001 to RF100.
Label FVector2D FVector2D::ZeroVector The place of the name on the map: the point of the field that is farthest from its boundary (the centre of the largest circle in the field), which is in the field also for a bent or ring shape; and the radius of that circle, m. A map shows the name only where this circle has room for it.
EntryNode int -1 The graph node of the first entry of the field (-1: the graph does not reach the field).
Outline TArray<FVector2D> The boundary of the field, for the map.
MapRequest int -1 A request of the control channel for the map of the HUD: 1 open, 0 close, -1 none. The HUD takes it.

Get#

The one guide of the process. The first call starts the read of the map file.

static FAcresRouteGuide& Get();

Exists#

True after the first call of Get(): before it, a session has no cost from the guide.

static bool Exists() ;

WaitReady#

Waits for the read of the map file. The caller thread sleeps during the wait: use this only for an action of the user that needs the graph immediately (the optimizer of the menu).

Returns: True when the graph is there. False when the file could not be read, or after TimeoutS.

bool WaitReady(double TimeoutS = 30.) const;

Error#

The cause when the file could not be read (then IsReady() stays false).

FString Error() const ;

FieldsByLabelRoom#

The fields from the largest label circle to the smallest: the order in which a map places the names.

const TArray<int>& FieldsByLabelRoom() const ;

NearestNode#

The graph node nearest to a point (-1 without a graph), and its distance.

int NearestNode(const FVector2D& P, double* OutDistanceM = nullptr) const;

RouteLengthM#

The length of the shortest route between two nodes, m (negative: no route), and optionally its nodes.

double RouteLengthM(int From, int To, TArray<int>* OutNodes = nullptr) const;

RouteLengthsM#

The length of the shortest route from one node to each node of the graph, m. A node with no route from From has a negative value. The list is empty without a graph or for a node that is not in the graph.

void RouteLengthsM(int From, TArray<double>& OutLengthM) const;

RouteLineM#

The line of the shortest route between two nodes: the points of its edges, from the node From to the node To.

Returns: The length of the route, m. Negative when there is no route: then the line is empty.

double RouteLineM(int From, int To, TArray<FVector2D>& OutLine) const;

FindField#

The field with this name ("F39", "RF042"; the case has no effect), or null.

const FField* FindField(const FString& Name) const;

SetDestination#

Sets the destination to a graph node, with a name for the HUD. False for a node that is not in the graph.

bool SetDestination(int Node, const FString& Name);

SetDestinationField#

Sets the destination to the entry of a field ("F39", "RF042"). False for an unknown field or one with no entry.

bool SetDestinationField(const FString& Name);

Update#

Makes the route from a vehicle position again (call it some times each second). The route goes from the vehicle to the nearest point of the graph and then along the graph. It clears itself within ArrivalM of the destination: then the result is true.

bool Update(const FVector2D& VehicleM, double ArrivalM = 12.);

Route#

The route of the last Update: its points from the vehicle to the destination, and its length, m.

const TArray<FVector2D>& Route() const ;