sot-talos-balance  1.6.0
qualisys-client.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2018, Gepetto team, LAAS-CNRS
3  *
4  * This file is part of sot-talos-balance.
5  * sot-talos-balance is free software: you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public License
7  * as published by the Free Software Foundation, either version 3 of
8  * the License, or (at your option) any later version.
9  * sot-talos-balance is distributed in the hope that it will be
10  * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
11  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU Lesser General Public License for more details. You should
13  * have received a copy of the GNU Lesser General Public License along
14  * with sot-talos-balance. If not, see <http://www.gnu.org/licenses/>.
15  */
16 
17 #ifndef __sot_talos_balance_qualisys_client_H__
18 #define __sot_talos_balance_qualisys_client_H__
19 
20 /* --------------------------------------------------------------------- */
21 /* --- API ------------------------------------------------------------- */
22 /* --------------------------------------------------------------------- */
23 
24 #if defined (WIN32)
25 # if defined (position_controller_EXPORTS)
26 # define QUALISYS_CLIENT_EXPORT __declspec(dllexport)
27 # else
28 # define QUALISYS_CLIENT_EXPORT __declspec(dllimport)
29 # endif
30 #else
31 # define QUALISYS_CLIENT_EXPORT
32 #endif
33 
34 
35 /* --------------------------------------------------------------------- */
36 /* --- INCLUDE --------------------------------------------------------- */
37 /* --------------------------------------------------------------------- */
38 
39 #include <dynamic-graph/signal-helper.h>
40 
41 #include <map>
42 #include "boost/assign.hpp"
43 #include <sot/core/robot-utils.hh>
44 #include <boost/thread.hpp>
45 #include <boost/chrono.hpp>
46 
51 
52 namespace dynamicgraph {
53  namespace sot {
54  namespace talos_balance {
55 
56  /* --------------------------------------------------------------------- */
57  /* --- CLASS ----------------------------------------------------------- */
58  /* --------------------------------------------------------------------- */
59 
61  : public ::dynamicgraph::Entity
62  {
63  DYNAMIC_GRAPH_ENTITY_DECL();
64 
65  public:
66  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
67 
68  /* --- CONSTRUCTOR ---- */
69  QualisysClient( const std::string & name );
70 
71  void init();
72 
73  /* --- SIGNALS --- */
74  DECLARE_SIGNAL_IN(dummy, double);
75 
76  /* --- COMMANDS --- */
77  void registerRigidBody(const std::string& RBname);
78  void setMocapIPAdress(const std::string& ipAdress);
79  void getRigidBodyList();
80 
81  /* --- ENTITY INHERITANCE --- */
82  virtual void display( std::ostream& os ) const;
83 
84  protected:
85  bool m_initSucceeded; // true if the entity has been successfully initialized
86  bool m_printRigidBodyList = false;
87  std::vector<std::string> m_RBnames; // vector of names of registered rigid bodies
88  std::vector<dg::Vector> m_RBpositions; // vector of rigid bodies positions
89  void manageNetworkFrame();
90  boost::thread m_thread{&QualisysClient::manageNetworkFrame,this};
91  boost::mutex m_mutex;
92  std::string m_serverAddr = "127.0.0.1";
93  dg::Vector& readGenericRigidBody(const int RBidx, dg::Vector& res, const int& time);
94  }; // class QualisysClient
95 
96  } // namespace talos_balance
97  } // namespace sot
98 } // namespace dynamicgraph
99 
100 
101 
102 #endif // #ifndef __sot_talos_balance_qualisys_client_H__
Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > Vector
Definition: math/fwd.hh:40
#define QUALISYS_CLIENT_EXPORT