Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

# Representations/Cognition/RobotPoseCollection.cpp

Go to the documentation of this file.

    00001 /**
    00002  * @author Carsten Rohde
    00003  * @author <a href="mailto:Thorsten.Kerkhof@gmx.de">Thorsten Kerkhof</a>
    00004  */
    00005
    00006 //---------------------------------------------------------------------------------------
    00007 #include "RobotPoseCollection.h"
    00008 //---------------------------------------------------------------------------------------
    00009 RobotPoseCollection::RobotPoseCollection()
    00010 :    numberOfPoses(3),
    00011     numberOfUsedPoses(0)
    00012 {
    00013 }
    00014 //---------------------------------------------------------------------------------------
    00015 //int RobotPoseCollection::read(In& stream, int length)
    00016 //{
    00017 //  int s = sizeof(this->poses[0].translation.x)
    00018 //        + sizeof(this->poses[0].translation.y)
    00019 //        + sizeof(this->poses[0].rotation)
    00020 //        + sizeof(this->poses[0].validity);
    00021 //  int n = length/s;
    00022 //  numberOfUsedPoses = n;
    00023 //  int i;
    00024 //  for (i = 0; i < numberOfPoses; i++)
    00025 //    this->poses[i].validity = 0;
    00026 //  for (i = 0; i < numberOfPoses; i++)
    00027 //  {
    00028 //    stream >> this->poses[i].translation.x;
    00029 //    stream >> this->poses[i].translation.y;
    00030 //    stream >> this->poses[i].rotation;
    00031 //    stream >> this->poses[i].validity;
    00032 //  }
    00033 //  return length;
    00034 //}
    00035 ////---------------------------------------------------------------------------------------
    00036 //void RobotPoseCollection::write(Out& stream)
    00037 //{
    00038 //  numberOfUsedPoses = 0;
    00039 //  for (int i = 0; i < numberOfPoses; i++)
    00040 //  {
    00041 //    if (poses[i].validity != 0)
    00042 //    {
    00043 //      numberOfUsedPoses++;
    00044 //      stream << this->poses[i].translation.x;
    00045 //      stream << this->poses[i].translation.y;
    00046 //      stream << this->poses[i].rotation;
    00047 //      stream << this->poses[i].validity;
    00048 //    }
    00049 //  }
    00050 //}
    00051 ////---------------------------------------------------------------------------------------
    00052
    00053 Out& operator<<(Out& stream, const RobotPoseCollection& rpc)
    00054 {
    00055    // find out number of valid poses
    00056    int numberOfUsedPoses = 0;
    00057    for (int i = 0; i < rpc.numberOfPoses; i++)
    00058    {
    00059      if (rpc.poses[i].validity != 0) numberOfUsedPoses++;
    00060    }
    00061    stream << numberOfUsedPoses;
    00062    for (int i = 0; i < rpc.numberOfPoses; i++)
    00063    {
    00064      if (rpc.poses[i].validity != 0)
    00065      {
    00066        stream << rpc.poses[i].translation.x;
    00067        stream << rpc.poses[i].translation.y;
    00068        stream << rpc.poses[i].rotation;
    00069        stream << rpc.poses[i].validity;
    00070      }
    00071    }
    00072    return stream;
    00073 }
    00074
    00075 In& operator>>(In& stream, RobotPoseCollection& rpc)
    00076 {
    00077    stream >> rpc.numberOfUsedPoses;
    00078    for (int i = 0; i < rpc.numberOfPoses; i++) rpc.poses[i].validity = 0;
    00079    for (int i = 0; i < rpc.numberOfUsedPoses; i++)
    00080    {
    00081      stream >> rpc.poses[i].translation.x;
    00082      stream >> rpc.poses[i].translation.y;
    00083      stream >> rpc.poses[i].rotation;
    00084      stream >> rpc.poses[i].validity;
    00085    }
    00086    return stream;
    00087 }