1 |
|
|
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
2 |
|
|
* Copyright Projet JRL-Japan, 2007 |
3 |
|
|
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
4 |
|
|
* |
5 |
|
|
* File: StepComputer.h |
6 |
|
|
* Project: SOT |
7 |
|
|
* Author: Olivier Stasse |
8 |
|
|
* |
9 |
|
|
* Version control |
10 |
|
|
* =============== |
11 |
|
|
* |
12 |
|
|
* $Id$ |
13 |
|
|
* |
14 |
|
|
* Description |
15 |
|
|
* ============ |
16 |
|
|
* |
17 |
|
|
* |
18 |
|
|
* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ |
19 |
|
|
|
20 |
|
|
#ifndef __SOT_StepComputer_JOYSTICK_H__ |
21 |
|
|
#define __SOT_StepComputer_JOYSTICK_H__ |
22 |
|
|
|
23 |
|
|
/* --------------------------------------------------------------------- */ |
24 |
|
|
/* --- INCLUDE --------------------------------------------------------- */ |
25 |
|
|
/* --------------------------------------------------------------------- */ |
26 |
|
|
|
27 |
|
|
/* SOT */ |
28 |
|
|
#include <dynamic-graph/entity.h> |
29 |
|
|
#include <dynamic-graph/signal-ptr.h> |
30 |
|
|
#include <dynamic-graph/signal-time-dependent.h> |
31 |
|
|
#include <sot/pattern-generator/step-checker.h> |
32 |
|
|
#include <sot/pattern-generator/step-computer.h> |
33 |
|
|
#include <sot/pattern-generator/step-observer.h> |
34 |
|
|
|
35 |
|
|
#include <sot/core/matrix-geometry.hh> |
36 |
|
|
|
37 |
|
|
/* STD */ |
38 |
|
|
#include <deque> |
39 |
|
|
#include <fstream> |
40 |
|
|
#include <string> |
41 |
|
|
|
42 |
|
|
/* --------------------------------------------------------------------- */ |
43 |
|
|
/* --- API ------------------------------------------------------------- */ |
44 |
|
|
/* --------------------------------------------------------------------- */ |
45 |
|
|
|
46 |
|
|
#if defined(WIN32) |
47 |
|
|
#if defined(step_computer_joystick_EXPORTS) |
48 |
|
|
#define StepComputerJOYSTICK_EXPORT __declspec(dllexport) |
49 |
|
|
#else |
50 |
|
|
#define StepComputerJOYSTICK_EXPORT __declspec(dllimport) |
51 |
|
|
#endif |
52 |
|
|
#else |
53 |
|
|
#define StepComputerJOYSTICK_EXPORT |
54 |
|
|
#endif |
55 |
|
|
|
56 |
|
|
namespace dynamicgraph { |
57 |
|
|
namespace sot { |
58 |
|
|
|
59 |
|
|
/* --------------------------------------------------------------------- */ |
60 |
|
|
/* --- CLASS ----------------------------------------------------------- */ |
61 |
|
|
/* --------------------------------------------------------------------- */ |
62 |
|
|
|
63 |
|
|
class StepQueue; |
64 |
|
|
|
65 |
|
|
/// Generates footsteps. |
66 |
|
|
class StepComputerJOYSTICK_EXPORT StepComputerJoystick : public Entity, |
67 |
|
|
public StepComputer { |
68 |
|
|
public: |
69 |
|
|
static const std::string CLASS_NAME; |
70 |
|
|
virtual const std::string &getClassName(void) const { return CLASS_NAME; } |
71 |
|
|
|
72 |
|
|
public: // Construction |
73 |
|
|
StepComputerJoystick(const std::string &name); |
74 |
|
|
|
75 |
|
|
public: // Methods |
76 |
|
|
void changeFirstStep(StepQueue &queue, int timeCurr); |
77 |
|
|
void nextStep(StepQueue &queue, int timeCurr); |
78 |
|
|
|
79 |
|
|
public: // Signals |
80 |
|
|
/*! \brief Entry of the joystick (x,y,theta)*/ |
81 |
|
|
SignalPtr<Vector, int> joystickSIN; |
82 |
|
|
/*! \brief Getting the support foot */ |
83 |
|
|
SignalPtr<unsigned, int> contactFootSIN; |
84 |
|
|
/*! \brief Externalize the last step . */ |
85 |
|
|
SignalTimeDependent<Vector, int> laststepSOUT; |
86 |
|
|
|
87 |
|
|
protected: |
88 |
|
|
Vector &getlaststep(Vector &res, int time); |
89 |
|
|
|
90 |
|
|
public: // Entity |
91 |
|
|
virtual void display(std::ostream &os) const; |
92 |
|
|
virtual void commandLine(const std::string &cmdLine, |
93 |
|
|
std::istringstream &cmdArgs, std::ostream &os); |
94 |
|
|
|
95 |
|
|
private: // Reference frame |
96 |
|
|
StepChecker checker; |
97 |
|
|
|
98 |
|
|
void thisIsZero(); |
99 |
|
|
|
100 |
|
|
private: // Debug |
101 |
|
|
std::ofstream logChanges; |
102 |
|
|
std::ofstream logPreview; |
103 |
|
|
|
104 |
|
|
double m_laststep[3]; |
105 |
|
|
}; |
106 |
|
|
|
107 |
|
|
} // namespace sot |
108 |
|
|
} // namespace dynamicgraph |
109 |
|
|
|
110 |
|
|
#endif // #ifndef __SOT_STEPCOMPUTER_H__ |