sot-torque-control  1.6.5
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 <boost/assign.hpp>
28 #include <map>
29 #include <pinocchio/fwd.hpp>
30 #include <vector>
31 
32 /* HELPER */
33 #include <dynamic-graph/signal-helper.h>
34 
35 #include <sot/core/matrix-geometry.hh>
36 #include <sot/core/robot-utils.hh>
38 
39 namespace dynamicgraph {
40 namespace sot {
41 namespace torque_control {
42 
43 /* --------------------------------------------------------------------- */
44 /* --- CLASS ----------------------------------------------------------- */
45 /* --------------------------------------------------------------------- */
46 
56 class SOTTRACEPLAYER_EXPORT TracePlayer : public ::dynamicgraph::Entity {
58  DYNAMIC_GRAPH_ENTITY_DECL();
59 
60  public:
61  /* --- CONSTRUCTOR ---- */
62  TracePlayer(const std::string& name);
63 
64  void init(const double& dt);
65 
66  /* --- SIGNALS --- */
67  typedef dynamicgraph::Signal<dynamicgraph::Vector, int> OutputSignalType;
68  std::map<std::string, OutputSignalType*> m_outputSignals;
69  DECLARE_SIGNAL_OUT(trigger, int);
70 
71  /* --- COMMANDS --- */
72  void addOutputSignal(const std::string& fileName,
73  const std::string& signalName);
74  void playNext();
75  void rewind();
76  void clear();
77 
78  /* --- ENTITY INHERITANCE --- */
79  virtual void display(std::ostream& os) const;
80 
81  void sendMsg(const std::string& msg, MsgType t = MSG_TYPE_INFO,
82  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__
dynamicgraph::sot::torque_control::TracePlayer::m_dataPointers
std::map< std::string, DataPointerType > m_dataPointers
Definition: trace-player.hh:92
dynamicgraph::sot::torque_control::TracePlayer::m_data
std::map< std::string, DataHistoryType > m_data
Definition: trace-player.hh:91
dynamicgraph
to read text file
Definition: treeview.dox:22
dynamicgraph::sot::torque_control::TracePlayer::DataPointerType
DataHistoryType::const_iterator DataPointerType
Definition: trace-player.hh:89
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:68
dynamicgraph::sot::torque_control::TracePlayer::DataType
dynamicgraph::Vector DataType
Definition: trace-player.hh:87
dynamicgraph::sot::torque_control::TracePlayer::DataHistoryType
std::list< DataType > DataHistoryType
Definition: trace-player.hh:88
dynamicgraph::sot::torque_control::TracePlayer
Entity to play data saved using a Tracer.
Definition: trace-player.hh:56
torque_control
Definition: __init__.py:1
dynamicgraph::sot::torque_control::EntityClassName
AdmittanceController EntityClassName
Definition: admittance-controller.cpp:51
dynamicgraph::sot::torque_control::TracePlayer::OutputSignalType
dynamicgraph::Signal< dynamicgraph::Vector, int > OutputSignalType
Definition: trace-player.hh:67
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:81