Drake
yaml_io.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <iosfwd>
4 
6 
7 namespace drake {
8 namespace maliput {
9 namespace simplerulebook {
10 
11 /// @file
12 /// YAML IO for SimpleRulebook.
13 ///
14 /// The YAML format is a simple literal representation of one record for
15 /// each rule, like so:
16 /// ~~~~~~
17 /// ---
18 /// maliput_simple_rulebook_v1: # rulebook content tag
19 /// speed_limit: # SpeedLimitRule group
20 /// ID1: # ID, as a string
21 /// zone: [LANE_ID, S0, S1] # LaneSRange
22 /// severity: Strict # a Severity enumerator, without the leading 'k'
23 /// limit: [MIN, MAX]
24 /// ID2:
25 /// zone: [LANE_ID, S0, S1]
26 /// severity: Advisory
27 /// limit: MAX # A lone MAX limit implies MIN = 0.
28 /// .
29 /// .
30 /// .
31 /// right_of_way: # RightOfWayRule group
32 /// ID1: # ID, as a string
33 /// zone: # sequence of LaneSRange items
34 /// - [LANE_ID, S0, S1]
35 /// - [LANE_ID, S0, S1]
36 /// - [LANE_ID, S0, S1]
37 /// zone_type: StopExcluded # ...ZoneType enum, without the leading 'k'
38 /// states:
39 /// STATE_ID1:
40 /// type: StopThenGo # ...Type enum, without the leading 'k'
41 /// yield_to:
42 /// - OTHER_RULE_ID
43 /// - OTHER_RULE_ID
44 /// .
45 /// .
46 /// .
47 /// ~~~~~~
48 ///
49 /// Only YAML content within the node tagged with "maliput_simple_rulebook_v1"
50 /// is parsed. All rules are grouped by rule type. Within each group, each
51 /// rule entry is labeled with the rule's ID. The contents of a rule entry
52 /// depend on the rule type, but are generally in 1-to-1 correspondence with
53 /// the arguments to the constructor for that rule type.
54 
55 
56 /// Loads rules parsed from `istream` into `rulebook`.
57 /// See yaml_io.h for a description of the YAML syntax.
58 ///
59 /// This is an additive process, equivalent to calling `AddRule()` on each
60 /// parsed rule. Any pre-existing content in `rulebook` is left as is.
61 ///
62 /// `istream` must yield a YAML document containing a YAML map at its
63 /// root, with an entry bearing the key "maliput_simple_rulebook_v1".
64 /// Only this entry is parsed; any other content is ignored.
65 ///
66 /// Throws `std::runtime_error` on parse errors, or failure of `AddRule()`.
67 /// Internally calls `YAML::Load(std::istream&)`, and thus does whatever
68 /// throwing/asserting which that function does.
69 // TODO(maddog@tri.global) If/when it ever becomes ok to expose YAML::Node
70 // in a public drake/maliput header, this function
71 // should just take a YAML::Node instead of a
72 // std::istream.
73 void LoadYaml(std::istream* istream, SimpleRulebook* rulebook);
74 
75 } // namespace simplerulebook
76 } // namespace maliput
77 } // namespace drake
void LoadYaml(std::istream *istream, SimpleRulebook *rulebook)
Loads rules parsed from istream into rulebook.
Definition: yaml_io.cc:184
Definition: automotive_demo.cc:90