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
44namespace armarx
45{
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
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);
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
constexpr T c
std::string getName() const override
Definition feedforward.h:92
void reportJointAngles(const NameValueMap &values, bool valueChanged, const Ice::Current &c)
void reportHeadTargetChanged(const NameValueMap &targetJointAngles, const FramedPositionBasePtr &targetPosition)
FeedforwardReflex(int interval)
Definition feedforward.h:51
std::vector< float > optFlow_pred
Definition feedforward.h:98
bool update_input_fromArmarX(GazeStabInput *gs_input)
std::vector< float > gyroscopeRotation_pred
void update_output_toArmarX(GazeStabOutput *gs_output)
void reportPlatformVelocity(float x, float y, float a)
void reportJointVelocities(const NameValueMap &values, bool valueChanged, const Ice::Current &c)
void setBools(bool armar4, bool velocityBased)
void setRobot(std::string nodeSetName, std::string headIKName, RobotStateComponentInterfacePrx robotStateComponent)
Brief description of class ReflexCombination.
Reflex(int interval)
Definition reflex.h:40
std::shared_ptr< class Robot > RobotPtr
Definition Bus.h:19
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceInternal::Handle< FramedPosition > FramedPositionPtr
Definition FramedPose.h:149
::IceInternal::ProxyHandle<::IceProxy::armarx::RobotStateComponentInterface > RobotStateComponentInterfacePrx