sot-torque-control  1.5.2
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 #include "boost/assign.hpp"
30 /* HELPER */
31 #include <dynamic-graph/signal-helper.h>
32 #include <sot/core/matrix-geometry.hh>
33 #include <sot/core/robot-utils.hh>
35 
36 namespace dynamicgraph {
37 namespace sot {
38 namespace torque_control {
39 
40 /* --------------------------------------------------------------------- */
41 /* --- CLASS ----------------------------------------------------------- */
42 /* --------------------------------------------------------------------- */
43 
53 class SOTTRACEPLAYER_EXPORT TracePlayer : public ::dynamicgraph::Entity {
55  DYNAMIC_GRAPH_ENTITY_DECL();
56 
57  public:
58  /* --- CONSTRUCTOR ---- */
59  TracePlayer(const std::string& name);
60 
61  void init(const double& dt);
62 
63  /* --- SIGNALS --- */
64  typedef dynamicgraph::Signal<dynamicgraph::Vector, int> OutputSignalType;
65  std::map<std::string, OutputSignalType*> m_outputSignals;
66  DECLARE_SIGNAL_OUT(trigger, int);
67 
68  /* --- COMMANDS --- */
69  void addOutputSignal(const std::string& fileName, const std::string& signalName);
70  void playNext();
71  void rewind();
72  void clear();
73 
74  /* --- ENTITY INHERITANCE --- */
75  virtual void display(std::ostream& os) const;
76 
77  void sendMsg(const std::string& msg, MsgType t = MSG_TYPE_INFO, const char* = "", int = 0) {
78  logger_.stream(t) << ("[" + name + "] " + msg) << '\n';
79  }
80 
81  protected:
82  typedef dynamicgraph::Vector DataType;
83  typedef std::list<DataType> DataHistoryType;
84  typedef DataHistoryType::const_iterator DataPointerType;
85 
86  std::map<std::string, DataHistoryType> m_data;
87  std::map<std::string, DataPointerType> m_dataPointers;
88 
89 }; // class TraceReader
90 
91 } // namespace torque_control
92 } // namespace sot
93 } // namespace dynamicgraph
94 
95 #endif // #ifndef __sot_torque_control_trace_reader_H__
dynamicgraph::sot::torque_control::TracePlayer::m_dataPointers
std::map< std::string, DataPointerType > m_dataPointers
Definition: trace-player.hh:87
dynamicgraph::sot::torque_control::TracePlayer::m_data
std::map< std::string, DataHistoryType > m_data
Definition: trace-player.hh:86
dynamicgraph
to read text file
Definition: treeview.dox:22
dynamicgraph::sot::torque_control::TracePlayer::DataPointerType
DataHistoryType::const_iterator DataPointerType
Definition: trace-player.hh:84
vector-conversions.hh
SOTTRACEPLAYER_EXPORT
#define SOTTRACEPLAYER_EXPORT
Definition: trace-player.hh:20
dynamicgraph::sot::torque_control::TracePlayer::m_outputSignals
std::map< std::string, OutputSignalType * > m_outputSignals
Definition: trace-player.hh:65
dynamicgraph::sot::torque_control::TracePlayer::DataType
dynamicgraph::Vector DataType
Definition: trace-player.hh:82
dynamicgraph::sot::torque_control::TracePlayer::DataHistoryType
std::list< DataType > DataHistoryType
Definition: trace-player.hh:83
dynamicgraph::sot::torque_control::TracePlayer
Entity to play data saved using a Tracer.
Definition: trace-player.hh:53
torque_control
Definition: __init__.py:1
dynamicgraph::sot::torque_control::EntityClassName
AdmittanceController EntityClassName
Definition: admittance-controller.cpp:44
dynamicgraph::sot::torque_control::TracePlayer::OutputSignalType
dynamicgraph::Signal< dynamicgraph::Vector, int > OutputSignalType
Definition: trace-player.hh:64
dynamicgraph::sot::torque_control::TracePlayer::sendMsg
void sendMsg(const std::string &msg, MsgType t=MSG_TYPE_INFO, const char *="", int=0)
Definition: trace-player.hh:77