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 "reflex.h"
27 #include "ReflexCombination.h"
28 
29 
30 namespace armarx
31 {
32  class ReflexCombination;
33  class OKR : virtual public Reflex
34  {
35  public:
37  {
38  flow_time = 0.;
39  }
40  ~OKR() override {}
41 
42  std::string getName() const override
43  {
44  return "OKR";
45  }
46 
47  // Reflex interface
48  private:
49  void calc() override;
50 
51  void onStop() override;
52  std::vector<float> pid(std::vector<float> error, std::vector<float> kp, std::vector<float> ki, std::vector<float> kd);
53  void removeSelfInducedOpticalFlow();
54 
55  private:
56  std::mutex dataMutex;
57 
58  bool reportedSensorValues, reportedJointAnglesBool, reportedJointVelocitiesBool;
59  bool armar4, velocityBased, newFlow;
60  float kp, ki, kd;
61  float flowX, flowY, flowT;
62  float errorX, errorY;
63  std::vector<float> err_old = std::vector<float>(3);
64  std::vector<float> err_sum = std::vector<float>(3);
65  NameValueMap reportedJointAngles, reportedJointVelocities;
66  std::string eye_pitch_left, eye_pitch_right, eye_yaw_left, eye_yaw_right, neck_roll;
67 
68  long flow_time;
69  std::map<long, NameValueMap> jointVelocities;
70 
71  public:
72  void reportJointAngles(const NameValueMap& values, bool valueChanged, const Ice::Current& c);
73  void reportJointVelocities(const NameValueMap& values, bool valueChanged, long timestamp, const Ice::Current& c);
74 
75  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);
76  void setPIDValues(float kp, float ki, float kd);
77  void setBools(bool armar4, bool velocityBased);
78  void reportNewOpticalFlow(float x, float y, float deltaT, long timestamp);
79  void reportNewTrackingError(Ice::Float pixelX, Ice::Float pixelY, Ice::Float angleX, Ice::Float angleY);
80  };
81 }
82 
ReflexCombination.h
armarx::VariantType::Float
const VariantTypeId Float
Definition: Variant.h:918
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:156
armarx::OKR::reportNewTrackingError
void reportNewTrackingError(Ice::Float pixelX, Ice::Float pixelY, Ice::Float angleX, Ice::Float angleY)
Definition: okr.cpp:239
armarx::OKR::setPIDValues
void setPIDValues(float kp, float ki, float kd)
Definition: okr.cpp:166
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:214
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:43
armarx::Reflex
Definition: reflex.h:36
armarx::OKR::reportNewOpticalFlow
void reportNewOpticalFlow(float x, float y, float deltaT, long timestamp)
Definition: okr.cpp:227
armarx::OKR::OKR
OKR(int interval)
Definition: okr.h:36
armarx::OKR::~OKR
~OKR() override
Definition: okr.h:40
armarx::control::njoint_controller::platform::platform_follower_controller::NameValueMap
std::map< std::string, float > NameValueMap
Definition: PlatformFollowerController.h:91
reflex.h
armarx::OKR::setBools
void setBools(bool armar4, bool velocityBased)
Definition: okr.cpp:175
armarx::OKR::reportJointAngles
void reportJointAngles(const NameValueMap &values, bool valueChanged, const Ice::Current &c)
Definition: okr.cpp:205
armarx::Reflex::interval
int interval
Definition: reflex.h:134
armarx::OKR::getName
std::string getName() const override
Definition: okr.h:42
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28