geometryPoses.cpp
Go to the documentation of this file.
00001 #include "hardcoded_facts/geometryPoses.h"
00002 #include <fstream>
00003 #include <sstream>
00004 
00005 GeometryPoses::GeometryPoses()
00006 {
00007 }
00008 
00009 GeometryPoses::~GeometryPoses()
00010 {
00011 }
00012 
00013 bool GeometryPoses::load(const std::string & filename)
00014 {
00015    std::ifstream f(filename.c_str());
00016    if(!f.good()) {
00017       return false;
00018    }
00019    std::string line;
00020    while(f.good() && !f.eof()) {
00021       getline(f, line);
00022       size_t pos = line.find_first_not_of(" ");
00023       if(pos == std::string::npos)    // empty line
00024          continue;
00025       if(line[pos] == '#')       // comment line
00026          continue;
00027       // parse the line
00028       std::stringstream ss(line);
00029       std::string name;
00030       ss >> name;
00031       uint32_t tsec, tnsec;
00032       geometry_msgs::PoseStamped pose;
00033       ss >> tsec;
00034       ss >> tnsec;
00035       pose.header.stamp = ros::Time(tsec, tnsec);
00036       ss >> pose.header.frame_id;
00037       // TODO: check this goes through
00038       ss >> pose.pose.position.x;
00039       ss >> pose.pose.position.y;
00040       ss >> pose.pose.position.z;
00041       ss >> pose.pose.orientation.x;
00042       ss >> pose.pose.orientation.y;
00043       ss >> pose.pose.orientation.z;
00044       ss >> pose.pose.orientation.w;
00045       _poses[name] = pose;
00046    }
00047    return true;
00048 }
00049 
00050 std::ostream & operator<<(std::ostream & os, const GeometryPoses & poses)
00051 {
00052    for(std::map<std::string, geometry_msgs::PoseStamped>::const_iterator it = poses._poses.begin(); it != poses._poses.end(); it++) {
00053       os << it->first << " = " << std::endl << it->second << std::endl;
00054    }
00055    return os;
00056 }
00057 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Friends


hardcoded_facts
Author(s): Christian Dornhege
autogenerated on Wed Dec 26 2012 15:46:00