ocra-recipes
Doxygen documentation for the ocra-recipes repository
ControllerServer.h
Go to the documentation of this file.
1 #ifndef CONTROLLER_SERVER_H
2 #define CONTROLLER_SERVER_H
3 
4 #include <iostream>
5 #include <memory>
6 
7 #include <ocra/util/Macros.h>
9 #include <ocra/control/Model.h>
11 
13 #include <wocra/WocraController.h>
14 #include <hocra/HocraController.h>
15 
16 #include <Eigen/Dense>
17 #include <Eigen/Lgsm>
18 
19 
20 // TODO: Should put in defines for yarp independent builds
21 #include <yarp/os/Bottle.h>
22 #include <yarp/os/Port.h>
23 
26 
27 namespace ocra_recipes
28 {
29 
31 {
35 };
36 
38 {
39  QUADPROG = 1,
41 };
42 
44 {
46 protected:
47  virtual std::shared_ptr<Model> loadRobotModel() = 0;
48  virtual void getRobotState(Eigen::VectorXd& q, Eigen::VectorXd& qd, Eigen::Displacementd& H_root, Eigen::Twistd& T_root) = 0;
49 
50 public:
51  ControllerServer(CONTROLLER_TYPE ctrlType/*=WOCRA_CONTROLLER*/,
52  SOLVER_TYPE solver/*=QUADPROG*/,
53  bool usingInterprocessCommunication=true,
54  bool useOdometry=false);
55 
56  virtual ~ControllerServer();
57 
58  bool initialize();
59  const Eigen::VectorXd& computeTorques();
60  void computeTorques(Eigen::VectorXd& torques);
61 
62 
63  const std::shared_ptr<ocra::Controller> getController(){return controller;}
64  const std::shared_ptr<ocra::Model> getRobotModel(){return model;}
65 
66  bool addTasksFromXmlFile(const std::string& filePath);
67  bool addTasks(std::vector<ocra::TaskBuilderOptions>& tmOpts);
68 
74  bool initializeOdometry();
75  void updateModel();
76 
77  void setRegularizationTermWeights(double wDdq, double wTau, double wFc);
78 
79 protected:
80 
81  ocra::Model::Ptr model;
82  ocra::Controller::Ptr controller;
83  ocra::Solver::Ptr internalSolver;
84 
85  bool firstRun;
86 
87  ServerCommunications::Ptr serverComs;
88 
89  Eigen::VectorXd tau;
91  Eigen::VectorXd qdPrevious;
92  Eigen::VectorXd qPrevious;
93  // Eigen::VectorXd q;
94  // Eigen::VectorXd qd;
95  // Eigen::Displacementd H_root;
96  // Eigen::Twistd T_root;
97 
100  bool usingComs;
102 
103  yarp::os::Bottle statesBottle;
104  yarp::os::Port statesPort;
105 
106  //Odometry options
107  std::string modelFile;
108  std::string initialFixedFrame;
109 };
110 
111 } // namespace ocra_recipes
112 #endif // CONTROLLER_SERVER_H
ControllerServer(CONTROLLER_TYPE ctrlType, SOLVER_TYPE solver, bool usingInterprocessCommunication=true, bool useOdometry=false)
ocra::Controller::Ptr controller
Define the LQP-based controller developped during my PhD thesis with ocra framework.
Define the internal solver class that can be used in the wOcra controller.
Declaration file of the Model class.
const std::shared_ptr< ocra::Model > getRobotModel()
ServerCommunications::Ptr serverComs
void setRegularizationTermWeights(double wDdq, double wTau, double wFc)
const Eigen::VectorXd & computeTorques()
#define DEFINE_CLASS_POINTER_TYPEDEFS(Class)
Definition: Macros.h:8
bool addTasks(std::vector< ocra::TaskBuilderOptions > &tmOpts)
virtual std::shared_ptr< Model > loadRobotModel()=0
virtual void getRobotState(Eigen::VectorXd &q, Eigen::VectorXd &qd, Eigen::Displacementd &H_root, Eigen::Twistd &T_root)=0
const std::shared_ptr< ocra::Controller > getController()
Controller interface.
bool addTasksFromXmlFile(const std::string &filePath)
A portable class for sending robot state information over yarp.
Definition: RobotState.h:26