feedforward.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 <Eigen/Core>
27 #include <Eigen/Geometry>
28 
29 #include <VirtualRobot/IK/GazeIK.h>
30 #include <VirtualRobot/Nodes/RobotNode.h>
31 #include <VirtualRobot/Robot.h>
32 #include <VirtualRobot/RobotNodeSet.h>
33 #include <VirtualRobot/VirtualRobot.h>
34 
37 
40 
41 #include "ReflexCombination.h"
42 #include "reflex.h"
43 
44 namespace armarx
45 {
46  class ReflexCombination;
47 
48  class FeedforwardReflex : virtual public Reflex
49  {
50  public:
52  {
53  stabilizer = NULL;
54  forward_predictor = NULL;
55 
56  optFlow_pred.resize(2);
57  mean_optFl_pred = 0.;
58  gyroscopeRotation_pred.resize(3);
59  onStop();
60  }
61 
62  ~FeedforwardReflex() override
63  {
64  if (stabilizer)
65  {
66  delete stabilizer;
67  }
68 
69  if (forward_predictor)
70  {
71  delete forward_predictor;
72  }
73  }
74 
75  void setRobot(std::string nodeSetName,
76  std::string headIKName,
77  RobotStateComponentInterfacePrx robotStateComponent);
78  void setBools(bool armar4, bool velocityBased);
79  bool update_input_fromArmarX(GazeStabInput* gs_input);
80  void update_output_toArmarX(GazeStabOutput* gs_output);
81 
82  void
83  reportJointAngles(const NameValueMap& values, bool valueChanged, const Ice::Current& c);
84  void
85  reportJointVelocities(const NameValueMap& values, bool valueChanged, const Ice::Current& c);
86  void reportPlatformVelocity(float x, float y, float a);
87 
88  void reportHeadTargetChanged(const NameValueMap& targetJointAngles,
89  const FramedPositionBasePtr& targetPosition);
90 
91  std::string
92  getName() const override
93  {
94  return "FeedforwardReflex";
95  }
96 
97  // optical flow prediction
98  std::vector<float> optFlow_pred; // [x, y] in [deg/s]
99  double mean_optFl_pred; // mean distance of the optical flow [deg/s]
100  std::vector<float>
101  gyroscopeRotation_pred; // head IMU velocity in head attached frame (x,y,z) [rad/s]
102 
103  protected:
104  void onStop() override;
105 
106  void calc() override;
107 
108  private:
110  std::vector<VirtualRobot::RobotNodePtr> allRobotNodeSet;
111  RobotStateComponentInterfacePrx robotStateComponent;
112  std::string headIKName;
113 
114  std::mutex dataMutex;
115 
116  GazeStabilization* stabilizer;
117  ForwardPredictor* forward_predictor;
118 
119  std::vector<std::string> headJointNames;
120 
121  FramedPositionPtr globalPos;
122  IceUtil::Time startTime;
123 
124  bool reportedJointAnglesBool, reportedJointVelocitiesBool;
125  bool armar4, velocityBased;
126  NameValueMap reportedJointAngles, reportedJointVelocities;
127  };
128 } // namespace armarx
RemoteRobot.h
ReflexCombination.h
armarx::FeedforwardReflex::optFlow_pred
std::vector< float > optFlow_pred
Definition: feedforward.h:98
armarx::FeedforwardReflex::FeedforwardReflex
FeedforwardReflex(int interval)
Definition: feedforward.h:51
GazeStabOutput
Definition: GazeStabInputOutput.hh:26
armarx::FeedforwardReflex::onStop
void onStop() override
Definition: feedforward.cpp:287
GazeStabilization
Definition: GazeStabilization.hh:10
ProsthesisInterface.values
values
Definition: ProsthesisInterface.py:190
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:46
forwardPredictor.h
armarx::FeedforwardReflex::reportPlatformVelocity
void reportPlatformVelocity(float x, float y, float a)
Definition: feedforward.cpp:266
armarx::FeedforwardReflex::update_input_fromArmarX
bool update_input_fromArmarX(GazeStabInput *gs_input)
Definition: feedforward.cpp:95
armarx::FeedforwardReflex::update_output_toArmarX
void update_output_toArmarX(GazeStabOutput *gs_output)
Definition: feedforward.cpp:209
armarx::FeedforwardReflex::setBools
void setBools(bool armar4, bool velocityBased)
Definition: feedforward.cpp:235
IceInternal::Handle< FramedPosition >
armarx::FeedforwardReflex
Definition: feedforward.h:48
armarx::Reflex
Definition: reflex.h:37
GazeStabilization.hh
armarx::ctrlutil::a
double a(double t, double a0, double j)
Definition: CtrlUtil.h:45
FramedPose.h
armarx::FeedforwardReflex::reportJointAngles
void reportJointAngles(const NameValueMap &values, bool valueChanged, const Ice::Current &c)
Definition: feedforward.cpp:244
GazeStabInput
Definition: GazeStabInputOutput.hh:6
armarx::armem::Time
armarx::core::time::DateTime Time
Definition: forward_declarations.h:13
armarx::FeedforwardReflex::calc
void calc() override
Definition: feedforward.cpp:29
armarx::FeedforwardReflex::reportJointVelocities
void reportJointVelocities(const NameValueMap &values, bool valueChanged, const Ice::Current &c)
Definition: feedforward.cpp:255
armarx::FeedforwardReflex::getName
std::string getName() const override
Definition: feedforward.h:92
armarx::control::njoint_controller::platform::platform_follower_controller::NameValueMap
std::map< std::string, float > NameValueMap
Definition: PlatformFollowerController.h:88
reflex.h
armarx::FeedforwardReflex::setRobot
void setRobot(std::string nodeSetName, std::string headIKName, RobotStateComponentInterfacePrx robotStateComponent)
Definition: feedforward.cpp:50
IceInternal::ProxyHandle<::IceProxy::armarx::RobotStateComponentInterface >
armarx::FeedforwardReflex::~FeedforwardReflex
~FeedforwardReflex() override
Definition: feedforward.h:62
armarx::FeedforwardReflex::gyroscopeRotation_pred
std::vector< float > gyroscopeRotation_pred
Definition: feedforward.h:101
armarx::FeedforwardReflex::reportHeadTargetChanged
void reportHeadTargetChanged(const NameValueMap &targetJointAngles, const FramedPositionBasePtr &targetPosition)
Definition: feedforward.cpp:274
armarx::Reflex::interval
int interval
Definition: reflex.h:142
armarx::FeedforwardReflex::mean_optFl_pred
double mean_optFl_pred
Definition: feedforward.h:99
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
armarx::ForwardPredictor
Definition: forwardPredictor.h:11
VirtualRobot::RobotPtr
std::shared_ptr< class Robot > RobotPtr
Definition: Bus.h:19