okr.h
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5  *
6  * ArmarX is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  *
10  * ArmarX is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * @package
19  * @author
20  * @date
21  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22  * GNU General Public License
23  */
24 #pragma once
25 
26 #include "ReflexCombination.h"
27 #include "reflex.h"
28 
29 namespace armarx
30 {
31  class ReflexCombination;
32 
33  class OKR : virtual public Reflex
34  {
35  public:
37  {
38  flow_time = 0.;
39  }
40 
41  ~OKR() override
42  {
43  }
44 
45  std::string
46  getName() const override
47  {
48  return "OKR";
49  }
50 
51  // Reflex interface
52  private:
53  void calc() override;
54 
55  void onStop() override;
56  std::vector<float> pid(std::vector<float> error,
57  std::vector<float> kp,
58  std::vector<float> ki,
59  std::vector<float> kd);
60  void removeSelfInducedOpticalFlow();
61 
62  private:
63  std::mutex dataMutex;
64 
65  bool reportedSensorValues, reportedJointAnglesBool, reportedJointVelocitiesBool;
66  bool armar4, velocityBased, newFlow;
67  float kp, ki, kd;
68  float flowX, flowY, flowT;
69  float errorX, errorY;
70  std::vector<float> err_old = std::vector<float>(3);
71  std::vector<float> err_sum = std::vector<float>(3);
72  NameValueMap reportedJointAngles, reportedJointVelocities;
73  std::string eye_pitch_left, eye_pitch_right, eye_yaw_left, eye_yaw_right, neck_roll;
74 
75  long flow_time;
76  std::map<long, NameValueMap> jointVelocities;
77 
78  public:
79  void
80  reportJointAngles(const NameValueMap& values, bool valueChanged, const Ice::Current& c);
82  bool valueChanged,
83  long timestamp,
84  const Ice::Current& c);
85 
86  void setJointNames(std::string eye_pitch_left,
87  std::string eye_pitch_right,
88  std::string eye_yaw_left,
89  std::string eye_yaw_right,
90  std::string neck_roll);
91  void setPIDValues(float kp, float ki, float kd);
92  void setBools(bool armar4, bool velocityBased);
93  void reportNewOpticalFlow(float x, float y, float deltaT, long timestamp);
95  Ice::Float pixelY,
96  Ice::Float angleX,
97  Ice::Float angleY);
98  };
99 } // namespace armarx
ReflexCombination.h
armarx::VariantType::Float
const VariantTypeId Float
Definition: Variant.h:919
armarx::OKR::setJointNames
void setJointNames(std::string eye_pitch_left, std::string eye_pitch_right, std::string eye_yaw_left, std::string eye_yaw_right, std::string neck_roll)
Definition: okr.cpp:157
armarx::OKR::reportNewTrackingError
void reportNewTrackingError(Ice::Float pixelX, Ice::Float pixelY, Ice::Float angleX, Ice::Float angleY)
Definition: okr.cpp:254
armarx::OKR::setPIDValues
void setPIDValues(float kp, float ki, float kd)
Definition: okr.cpp:172
armarx::OKR
Definition: okr.h:33
ProsthesisInterface.values
values
Definition: ProsthesisInterface.py:190
armarx::OKR::reportJointVelocities
void reportJointVelocities(const NameValueMap &values, bool valueChanged, long timestamp, const Ice::Current &c)
Definition: okr.cpp:226
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:46
armarx::Reflex
Definition: reflex.h:37
armarx::OKR::reportNewOpticalFlow
void reportNewOpticalFlow(float x, float y, float deltaT, long timestamp)
Definition: okr.cpp:241
armarx::OKR::OKR
OKR(int interval)
Definition: okr.h:36
timestamp
std::string timestamp()
Definition: CartographerAdapter.cpp:85
armarx::OKR::~OKR
~OKR() override
Definition: okr.h:41
armarx::control::njoint_controller::platform::platform_follower_controller::NameValueMap
std::map< std::string, float > NameValueMap
Definition: PlatformFollowerController.h:88
reflex.h
armarx::OKR::setBools
void setBools(bool armar4, bool velocityBased)
Definition: okr.cpp:182
armarx::OKR::reportJointAngles
void reportJointAngles(const NameValueMap &values, bool valueChanged, const Ice::Current &c)
Definition: okr.cpp:217
armarx::Reflex::interval
int interval
Definition: reflex.h:142
armarx::OKR::getName
std::string getName() const override
Definition: okr.h:46
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27