sot-torque-control  1.6.2
Collection of dynamic-graph entities aimed at implementing torque control on different robots.
trace-player.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2017, Andrea Del Prete, LAAS-CNRS
3  *
4  */
5 
6 #ifndef __sot_torque_control_trace_player_H__
7 #define __sot_torque_control_trace_player_H__
8 
9 /* --------------------------------------------------------------------- */
10 /* --- API ------------------------------------------------------------- */
11 /* --------------------------------------------------------------------- */
12 
13 #if defined(WIN32)
14 #if defined(__sot_torque_control_trace_player_H__)
15 #define SOTTRACEPLAYER_EXPORT __declspec(dllexport)
16 #else
17 #define SOTTRACEPLAYER_EXPORT __declspec(dllimport)
18 #endif
19 #else
20 #define SOTTRACEPLAYER_EXPORT
21 #endif
22 
23 /* --------------------------------------------------------------------- */
24 /* --- INCLUDE --------------------------------------------------------- */
25 /* --------------------------------------------------------------------- */
26 
27 #include <vector>
28 #include <map>
29 
30 #include <pinocchio/fwd.hpp>
31 
32 #include <boost/assign.hpp>
33 
34 /* HELPER */
35 #include <dynamic-graph/signal-helper.h>
36 #include <sot/core/matrix-geometry.hh>
37 #include <sot/core/robot-utils.hh>
38 
40 
41 namespace dynamicgraph {
42 namespace sot {
43 namespace torque_control {
44 
45 /* --------------------------------------------------------------------- */
46 /* --- CLASS ----------------------------------------------------------- */
47 /* --------------------------------------------------------------------- */
48 
58 class SOTTRACEPLAYER_EXPORT TracePlayer : public ::dynamicgraph::Entity {
60  DYNAMIC_GRAPH_ENTITY_DECL();
61 
62  public:
63  /* --- CONSTRUCTOR ---- */
64  TracePlayer(const std::string& name);
65 
66  void init(const double& dt);
67 
68  /* --- SIGNALS --- */
69  typedef dynamicgraph::Signal<dynamicgraph::Vector, int> OutputSignalType;
70  std::map<std::string, OutputSignalType*> m_outputSignals;
71  DECLARE_SIGNAL_OUT(trigger, int);
72 
73  /* --- COMMANDS --- */
74  void addOutputSignal(const std::string& fileName, const std::string& signalName);
75  void playNext();
76  void rewind();
77  void clear();
78 
79  /* --- ENTITY INHERITANCE --- */
80  virtual void display(std::ostream& os) const;
81 
82  void sendMsg(const std::string& msg, MsgType t = MSG_TYPE_INFO, const char* = "", int = 0) {
83  logger_.stream(t) << ("[" + name + "] " + msg) << '\n';
84  }
85 
86  protected:
87  typedef dynamicgraph::Vector DataType;
88  typedef std::list<DataType> DataHistoryType;
89  typedef DataHistoryType::const_iterator DataPointerType;
90 
91  std::map<std::string, DataHistoryType> m_data;
92  std::map<std::string, DataPointerType> m_dataPointers;
93 
94 }; // class TraceReader
95 
96 } // namespace torque_control
97 } // namespace sot
98 } // namespace dynamicgraph
99 
100 #endif // #ifndef __sot_torque_control_trace_reader_H__
#define SOTTRACEPLAYER_EXPORT
Definition: trace-player.hh:20
dynamicgraph::Signal< dynamicgraph::Vector, int > OutputSignalType
Definition: trace-player.hh:69
void sendMsg(const std::string &msg, MsgType t=MSG_TYPE_INFO, const char *="", int=0)
Definition: trace-player.hh:82
Entity to play data saved using a Tracer.
Definition: trace-player.hh:58
std::map< std::string, DataPointerType > m_dataPointers
Definition: trace-player.hh:92
std::map< std::string, DataHistoryType > m_data
Definition: trace-player.hh:91
DataHistoryType::const_iterator DataPointerType
Definition: trace-player.hh:89
std::map< std::string, OutputSignalType * > m_outputSignals
Definition: trace-player.hh:70
to read text file
Definition: treeview.dox:22