GCC Code Coverage Report


Directory: ./
File: include/dynamic-graph/tutorial/feedback-controller.hh
Date: 2024-11-12 12:07:01
Exec Total Coverage
Lines: 0 5 0.0%
Branches: 0 2 0.0%

Line Branch Exec Source
1 /*
2 * Copyright 2010 CNRS
3 *
4 * Florent Lamiraux
5 */
6
7 #ifndef DG_TUTORIAL_FEEDBACK_CONTROLLER_HH
8 #define DG_TUTORIAL_FEEDBACK_CONTROLLER_HH
9
10 #include <dynamic-graph/entity.h>
11 #include <dynamic-graph/linear-algebra.h>
12 #include <dynamic-graph/signal-ptr.h>
13 #include <dynamic-graph/signal-time-dependent.h>
14
15 namespace dynamicgraph {
16 namespace tutorial {
17 /**
18 \brief Feedback controller for an inverted pendulum
19
20 This class implements a feedback control for the inverted pendulum
21 represented by class InvertedPendulum
22 */
23 class FeedbackController : public Entity {
24 public:
25 /**
26 \brief Constructor by name
27 */
28 FeedbackController(const std::string& inName);
29
30 ~FeedbackController();
31
32 /// Each entity should provide the name of the class it belongs to
33 virtual const std::string& getClassName(void) const { return CLASS_NAME; }
34
35 /// Header documentation of the python class
36 virtual std::string getDocString() const {
37 return "Feedback controller aimed at maintaining the pendulum vertical\n";
38 }
39 /**
40 \name Parameters
41 @{
42 */
43 /**
44 \brief Get feedback gain
45 */
46 void setGain(const ::dynamicgraph::Matrix& inGain) { gain_ = inGain; }
47
48 /**
49 \brief Get feedback gain
50 */
51 ::dynamicgraph::Matrix getGain() const { return gain_; }
52
53 /**
54 @}
55 */
56
57 public:
58 /*
59 \brief Class name
60 */
61 static const std::string CLASS_NAME;
62
63 private:
64 /**
65 Compute the control law
66 */
67 double& computeForceFeedback(double& force, const int& inTime);
68
69 /**
70 \brief State of the inverted pendulum
71 */
72 SignalPtr< ::dynamicgraph::Vector, int> stateSIN;
73 /**
74 \brief Force computed by the control law
75 */
76 SignalTimeDependent<double, int> forceSOUT;
77
78 /// \brief Gain of the controller
79 ::dynamicgraph::Matrix gain_;
80 };
81 } // namespace tutorial
82 } // namespace dynamicgraph
83
84 #endif // DG_TUTORIAL_FEEDBACK_CONTROLLER_HH
85