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