$search
00001 #ifndef HALFSTEPS_PATTERN_YAML_HH 00002 # define HALFSTEPS_PATTERN_YAML_HH 00003 # include <utility> 00004 # include <walk_interfaces/pattern-generator.hh> 00005 # include <walk_interfaces/yaml.hh> 00006 00007 # include <halfsteps_pattern_generator.hh> 00008 00009 namespace walk 00010 { 00011 inline YAML::Emitter& 00012 operator<< (YAML::Emitter& out, 00013 const HalfStepsPatternGenerator::footprint_t& footprint) 00014 { 00015 out << YAML::BeginMap 00016 << YAML::Key << "beginTime" 00017 << YAML::Value 00018 << to_iso_string (footprint.beginTime) 00019 << YAML::Key << "duration" 00020 << YAML::Value 00021 << (0. + footprint.duration.total_nanoseconds () / 1e9) 00022 << YAML::Key << "position" 00023 << YAML::Value << footprint.position 00024 << YAML::Key << "slide-up" 00025 << YAML::Value 00026 << footprint.slideUp 00027 << YAML::Key << "slide-down" 00028 << YAML::Value 00029 << footprint.slideDown 00030 << YAML::Key << "horizontal-distance" 00031 << YAML::Value 00032 << footprint.horizontalDistance 00033 << YAML::Key << "step-height" 00034 << YAML::Value 00035 << footprint.stepHeight 00036 << YAML::EndMap; 00037 return out; 00038 } 00039 00040 inline YAML::Emitter& 00041 operator<< (YAML::Emitter& out, 00042 const WALK_INTERFACES_EIGEN_STL_VECTOR 00043 (HalfStepsPatternGenerator::footprint_t)& footprints) 00044 { 00045 out << YAML::BeginSeq; 00046 typedef HalfStepsPatternGenerator::footprint_t a_t; 00047 BOOST_FOREACH (const a_t& footprint, footprints) 00048 out << footprint; 00049 out << YAML::EndSeq; 00050 return out; 00051 } 00052 00053 inline void 00054 operator>> (const YAML::Node& node, 00055 HalfStepsPatternGenerator::footprint_t& footprint) 00056 { 00057 checkYamlType (node, YAML::NodeType::Map, "footprint"); 00058 00059 using namespace boost::posix_time; 00060 using namespace boost::gregorian; 00061 00062 std::string beginTimeStr; 00063 node["beginTime"] >> beginTimeStr; 00064 footprint.beginTime = walk::Time (from_iso_string (beginTimeStr)); 00065 double d = 0; 00066 node["duration"] >> d; 00067 footprint.duration = milliseconds (d * 1e3); 00068 node["position"] >> footprint.position; 00069 00070 node["slide-up"] >> footprint.slideUp; 00071 node["slide-down"] >> footprint.slideDown; 00072 node["horizontal-distance"] >> footprint.horizontalDistance; 00073 node["step-height"] >> footprint.stepHeight; 00074 } 00075 00076 } // end of namespace walk. 00077 00078 #endif //! HALFSTEPS_PATTERN_YAML_HH