-
Notifications
You must be signed in to change notification settings - Fork 8
/
yaml.hh
72 lines (64 loc) · 1.92 KB
/
yaml.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#ifndef HALFSTEPS_PATTERN_YAML_HH
# define HALFSTEPS_PATTERN_YAML_HH
# include <utility>
# include <walk_interfaces/pattern-generator.hh>
# include <walk_interfaces/yaml.hh>
namespace walk
{
inline YAML::Emitter&
operator<< (YAML::Emitter& out, const footprint_t& footprint)
{
out << YAML::BeginMap
<< YAML::Key << "beginTime"
<< YAML::Value
<< to_iso_string (footprint.beginTime)
<< YAML::Key << "duration"
<< YAML::Value
<< (0. + footprint.duration.total_nanoseconds () / 1e9)
<< YAML::Key << "position"
<< YAML::Value << footprint.position
<< YAML::Key << "slide-up"
<< YAML::Value
<< footprint.slideUp
<< YAML::Key << "slide-down"
<< YAML::Value
<< footprint.slideDown
<< YAML::Key << "horizontal-distance"
<< YAML::Value
<< footprint.horizontalDistance
<< YAML::Key << "step-height"
<< YAML::Value
<< footprint.stepHeight
<< YAML::EndMap;
return out;
}
inline YAML::Emitter&
operator<< (YAML::Emitter& out,
const WALK_INTERFACES_EIGEN_STL_VECTOR(footprint_t)& footprints)
{
out << YAML::BeginSeq;
BOOST_FOREACH (const footprint_t& footprint, footprints)
out << footprint;
out << YAML::EndSeq;
return out;
}
inline void
operator>> (const YAML::Node& node, footprint_t& footprint)
{
checkYamlType (node, YAML::NodeType::Map, "footprint");
using namespace boost::posix_time;
using namespace boost::gregorian;
std::string beginTimeStr;
node["beginTime"] >> beginTimeStr;
footprint.beginTime = walk::Time (from_iso_string (beginTimeStr));
double d = 0;
node["duration"] >> d;
footprint.duration = milliseconds (d * 1e3);
node["position"] >> footprint.position;
node["slide-up"] >> footprint.slideUp;
node["slide-down"] >> footprint.slideDown;
node["horizontal-distance"] >> footprint.horizontalDistance;
node["step-height"] >> footprint.stepHeight;
}
} // end of namespace walk.
#endif //! HALFSTEPS_PATTERN_YAML_HH