Posted by @txlei:
- Could I understand more on the format of the navigation graph generated by traffic editor and used by fleet adapter API? Referred to
ParseGraph.cpp
but still can’t interpret how the the lanes and vertices information are used. Could you give an overview and also specifically I have a qn below:
- for lanes, the start and end of each lane are not tagged with location information. The number of items in the lanes list and vertices list does not match. So where is this location information be available?
- I believe that there is a piece of code in the
fleet_adapter
library that identifies the robot’s current location from/fleet_states
on its navigation graph. i.e. which lane does the robot occupies. Could you point me to the related files for reference?
Chosen answer
Answer chosen by @Yadunund at 2021-04-01T02:58:39Z.
Answered by @mxgrey:
After calling the parse_graph
function, you will get back a rmf_traffic::agv::Graph
instance, so I’m going to refer to the API of rmf_traffic::agv::Graph
(from now on I’ll just refer to it as Graph
) to explain the graph structure. The yaml format is just an intermediate disk format, so there’s not much need to understand it.
The Graph
API has two important nested classes: Graph::Waypoint
and Graph::Lane
.
Graph::Waypoint
class ties the graph to its real-world locations using Graph::Waypoint::get_map_name()
and Graph::Waypoint::get_location()
.
The Graph::Lane
class connects waypoints by defining an entry and exit node. Each node specifies a waypoint_index
. You can pass that waypoint_index
into Graph::get_waypoint(~)
to see information about the entry/exit waypoint of the lane (such as the waypoint’s position).
Each lane is uni-directional. To put a bi-directional edge into the graph, you simply create two lanes where their entry/exit waypoints are the reverse of each other.
I believe that there is a piece of code in the fleet_adapter library that identifies the robot’s current location from /fleet_states on its navigation graph. i.e. which lane does the robot occupies. Could you point me to the related files for reference?
I think what you’re looking for is the compute_plan_starts
function. I would urge caution when using this function, since it’s not hard for it to get confused about what lane the robot is actually on. This function is the leading cause of this problem, so we’re trying to move away from depending on it as much as possible. If you use that function to pick which lanes to close, you may accidentally end up closing other lanes that you didn’t mean to.
If your goal is to identify which lane is being blocked when a robot gets stuck, then instead of using compute_plan_starts
, I might recommend keeping track of which two waypoints the robot is moving between and then calling Graph::lane_from(from, to)
to find which lane is actually being blocked.