GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: include/sot/pattern-generator/step-queue.h Lines: 0 1 0.0 %
Date: 2023-06-05 08:59:09 Branches: 0 0 - %

Line Branch Exec Source
1
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2
 * Copyright Projet JRL-Japan, 2007
3
 *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4
 *
5
 * File:      StepQueue.h
6
 * Project:   SOT
7
 * Author:    Paul Evrard, Nicolas Mansard
8
 *
9
 * Version control
10
 * ===============
11
 *
12
 *  $Id$
13
 *
14
 * Description
15
 * ============
16
 *
17
 * StepQueue entity: manages a step queue (a series of future steps,
18
 * plus a series of changes in the future steps).
19
 *
20
 * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
21
22
#ifndef __SOT_STEPQUEUE_H__
23
#define __SOT_STEPQUEUE_H__
24
25
/* --------------------------------------------------------------------- */
26
/* --- INCLUDE --------------------------------------------------------- */
27
/* --------------------------------------------------------------------- */
28
29
/* SOT */
30
#include <dynamic-graph/entity.h>
31
32
/* STD */
33
#include <deque>
34
#include <string>
35
36
namespace dynamicgraph {
37
namespace sot {
38
39
/* --------------------------------------------------------------------- */
40
/* --- API ------------------------------------------------------------- */
41
/* --------------------------------------------------------------------- */
42
43
#if defined(WIN32)
44
#if defined(step_queue_EXPORTS)
45
#define StepQueue_EXPORT __declspec(dllexport)
46
#else
47
#define StepQueue_EXPORT __declspec(dllimport)
48
#endif
49
#else
50
#define StepQueue_EXPORT
51
#endif
52
53
/* --------------------------------------------------------------------- */
54
/* --- CLASS ----------------------------------------------------------- */
55
/* --------------------------------------------------------------------- */
56
57
/// Support foot identifier.
58
enum ContactName { CONTACT_LEFT_FOOT, CONTACT_RIGHT_FOOT };
59
60
class StepQueue_EXPORT FootPrint {
61
 public:
62
  FootPrint();
63
  FootPrint(double x, double y, double theta, ContactName contact);
64
65
  double x, y, theta;  ///< The coordinates of the step (landing position of the
66
                       ///< fly foot).
67
  ContactName contact;  ///< Fly foot.
68
};
69
70
/// A step queue in the preview window.
71
72
/// A series of step in the preview window. The first step can be modified.
73
///
74
/// \invariant{The queue always contains 4 steps.}
75
/// \note{This entity class can not be instantiated in a shell since it does not
76
/// register any factory. This behavior is intended.}
77
class StepQueue_EXPORT StepQueue : public Entity {
78
 public:  // Entity name
79
  static const std::string CLASS_NAME;
80
  virtual const std::string &getClassName(void) const { return CLASS_NAME; }
81
82
 private:  // Parameters
83
  static const unsigned int QUEUE_SIZE;
84
  static const double ZERO_STEP_POSITION;
85
  static const FootPrint START_FOOT_PRINT;
86
87
 public:  // Construction
88
  /// Builds a queue containing a starting step and three steps in the preview.
89
  /// The steps correspond to on-place stepping: (0, +/- y, 0), where
90
  /// y == StepQueue::ZERO_STEP_POSITION
91
  StepQueue(const std::string &name);
92
93
 public:  // Queue manipulation
94
  /// Resets the queue to the initial condition (see the constructor,
95
  /// StepQueue::StepQueue).
96
  void startSequence();
97
98
  /// Adds a step at the end of the preview window. The step at the beginning
99
  /// of the preview window is removed. The firstStepChanged flag is reset to
100
  /// false.
101
  void pushStep(double x, double y, double theta);
102
103
  //@{
104
  /// Access to the step queue.
105
  /// \warning{No check is performed on the indices used in these accessors.}
106
  const FootPrint &getStep(unsigned int index) const;
107
  const FootPrint &getFirstStep() const;
108
  const FootPrint &getLastStep() const;
109
  //@}
110
111
  /// Changes the first step.
112
  void changeFirstStep(double x, double y, double dtheta);
113
114
  const FootPrint &getFirstStepChange() const;
115
116
  /// Returns true if the first step has been changed since the last call to
117
  /// pushStep.
118
  bool isFirstStepChanged() const;
119
120
 public:  // Queue properties
121
  //@{
122
  /// Access to the step queue properties (constants).
123
  unsigned int size() const;
124
  const FootPrint &getStartFootPrint() const;
125
  double getZeroStepPosition() const;
126
  //@}
127
128
 public:  // Entity
129
  virtual void display(std::ostream &os) const;
130
  virtual void commandLine(const std::string &cmdLine,
131
                           std::istringstream &cmdArgs, std::ostream &os);
132
133
 private:
134
  std::deque<FootPrint> footPrintList;
135
  FootPrint firstStepChange;
136
  bool firstStepChanged;
137
};
138
139
}  // namespace sot
140
}  // namespace dynamicgraph
141
142
#endif