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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/**
* @file CollisionPercept.h
*
* @author <a href="mailto:krause@informatik.hu-berlin.de">Thomas Krause</a>
* @author <a href="mailto:xu@informatik.hu-berlin.de">Xu, Yuan</a>
* Definition of the class CollisionPercept
*/

#ifndef CollisionPercept_h
#define CollisionPercept_h

#include "Tools/DataStructures/Printable.h"
#include "Tools/DataStructures/Serializer.h"

#include <vector>
#include "Tools/Math/Vector2.h"
#include <Representations/Infrastructure/FrameInfo.h>

/**
* This describes the CollisionPercept
*/
class CollisionPercept : public naoth::Printable
{
public:
  CollisionPercept()<--- Member variable 'CollisionPercept::isLeftFootColliding' is not initialized in the constructor.<--- Member variable 'CollisionPercept::isRightFootColliding' is not initialized in the constructor.<--- Member variable 'CollisionPercept::lastComputedCollisionLeft' is not initialized in the constructor.<--- Member variable 'CollisionPercept::lastComputedCollisionRight' is not initialized in the constructor.<--- Member variable 'CollisionPercept::collision_left_bumper' is not initialized in the constructor.<--- Member variable 'CollisionPercept::collision_right_bumper' is not initialized in the constructor.
    : 
    timeCollisionArmLeft(0), 
    timeCollisionArmRight(0)
  {}

  ~CollisionPercept(){}

  // time stamp of the last collision
  unsigned int timeCollisionArmLeft;
  unsigned int timeCollisionArmRight;

  std::string lastCollisionDirection;

  std::vector<Vector2d> referenceHullLeft;
  std::vector<Vector2d> referenceHullRight;
  std::vector<Vector2d> pointBufferLeft;
  std::vector<Vector2d> pointBufferRight;
  std::vector<Vector2d> newHullLeft;
  std::vector<Vector2d> newHullRight;

  // bumper collision
  bool isLeftFootColliding;  // indicate single button press
  bool isRightFootColliding;  // indicate single button press
  double lastComputedCollisionLeft;
  double lastComputedCollisionRight;

  // indicate real collisoin
  bool collision_left_bumper;
  bool collision_right_bumper;
  
  virtual void print(std::ostream& stream) const
  {
    stream << "Last collision direction: " << lastCollisionDirection << std::endl;
    stream << "timeCollisionArmLeft = " << timeCollisionArmLeft << '\n';
    stream << "timeCollisionArmRight = " << timeCollisionArmRight << '\n';
    stream << "referenceHullLeft: " << "\n";
    for (size_t i = 0; i < referenceHullLeft.size(); i++){
      stream << "x= " << referenceHullLeft[i].x << " y = " << referenceHullLeft[i].y << "\n";
    }
	stream << "referenceHullRight: " << "\n";
	for (size_t i = 0; i < referenceHullRight.size(); i++){
		stream << "x= " << referenceHullRight[i].x << " y = " << referenceHullRight[i].y << "\n";
	}
    stream << "isLeftFootColliding=" << (isLeftFootColliding ? "true" : "false") << std::endl;
    stream << "isRightFootColliding=" << (isRightFootColliding ? "true" : "false") << std::endl;
    stream << "Last computed collision Left: " << lastComputedCollisionLeft << std::endl;
    stream << "Last computed collision Right: " << lastComputedCollisionRight << std::endl;
  }
};

namespace naoth
{
  template<>
  class Serializer<CollisionPercept>
  {
  public:
    static void serialize(const CollisionPercept& representation, std::ostream& stream);
    static void deserialize(std::istream& stream, CollisionPercept& representation);
  };
}

#endif // CollisionPercept_h