PlatformFollowerController.h
Go to the documentation of this file.
1/**
2 * This file is part of ArmarX.
3 *
4 * ArmarX is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * ArmarX is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * @author Fabian Reister ( fabian dot reister at kit dot edu )
17 * @date 2022
18 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
19 * GNU General Public License
20 */
21
22#pragma once
23
24#include <VirtualRobot/VirtualRobot.h>
25
27
32
33#include <armarx/control/interface/ConfigurableNJointControllerInterface.h>
34#include <armarx/control/njoint_controller/platform/platform_follower_controller/aron/PlatformFollowerControllerConfig.aron.generated.h>
35
36namespace armarx
37{
39 class SensorValueHolonomicPlatformWithAbsolutePosition;
40} // namespace armarx
41
43{
45 {
46 Eigen::Vector3f handPositionRight;
47 Eigen::Vector3f handPositionLeft;
48 Eigen::Vector3f currentVel = Eigen::Vector3f::Zero();
50
51 Eigen::Vector3f
52 direction() const
53 {
54 return (handPositionRight - handPositionLeft).normalized();
55 }
56 };
57
58 struct Config
59 {
60 using Params = platform_follower_controller::arondto::Params;
61
63 };
64
65 struct Target
66 {
67 struct
68 {
69 double x = 0;
70 double y = 0;
71 double yaw = 0;
73
74 void
81 };
82
87
88 using NameValueMap = std::map<std::string, float>;
89
90 class Controller :
91 virtual public armarx::NJointControllerWithTripleBuffer<Target>,
92 virtual public armarx::control::ConfigurableNJointControllerInterface
93 {
94 public:
95 using ConfigPtrT = armarx::control::ConfigurableNJointControllerConfigPtr;
96
97 Controller(const armarx::RobotUnitPtr& robotUnit,
98 const armarx::NJointControllerConfigPtr& config,
100
101 ~Controller() override;
102
103 std::string getClassName(const Ice::Current& iceCurrent = Ice::emptyCurrent) const override;
104
105 void rtRun(const IceUtil::Time& sensorValuesTimestamp,
106 const IceUtil::Time& timeSinceLastIteration) override;
107
108 void updateConfig(const ::armarx::aron::data::dto::DictPtr& dto,
109 const Ice::Current& iceCurrent = Ice::emptyCurrent) override;
110
112 getConfig(const Ice::Current& iceCurrent = Ice::emptyCurrent) override
113 {
114 ARMARX_WARNING << "NYI";
115 return nullptr;
116 }
117
118 protected:
119 void additionalTask();
120 void onPublish(const armarx::SensorAndControl& sac,
121 const armarx::DebugDrawerInterfacePrx& debugDrawer,
122 const armarx::DebugObserverInterfacePrx& debugObservers) override;
123
124
125 void onInitNJointController() override;
126 void rtPreActivateController() override;
127
128 private:
129 // updateConfig -> additionalTask
130 armarx::TripleBuffer<Config> configBuffer;
131
132 // rt -> additionalTask
134
135 // internal
136 std::atomic_bool rtFirstRun = true;
137 std::atomic_bool rtReady = false;
138
140
141 // FIXME add platform sensors here
142 std::vector<const armarx::SensorValue1DoFActuatorVelocity*> velocitySensors;
143
144 Devices getDevices(const VirtualRobot::RobotNodeSet& rns);
145
146 RobotState initialState;
147
148 VirtualRobot::RobotNodePtr tcpRight;
149 VirtualRobot::RobotNodePtr tcpLeft;
150
151 struct
152 {
153 Eigen::Vector2f filteredLinearVel = Eigen::Vector2f::Zero();
156 } additionalTaskData;
157
158 struct OnPublishData
159 {
160 Target target;
161
162 Eigen::Vector3f position_error_left;
163 Eigen::Vector3f position_error_right;
164 };
165
167 };
168
169} // namespace armarx::control::njoint_controller::platform::platform_follower_controller
Brief description of class ControlTargetHolonomicPlatformVelocity.
A simple triple buffer for lockfree comunication between a single writer and a single reader.
Controller(const armarx::RobotUnitPtr &robotUnit, const armarx::NJointControllerConfigPtr &config, const VirtualRobot::RobotPtr &)
void rtRun(const IceUtil::Time &sensorValuesTimestamp, const IceUtil::Time &timeSinceLastIteration) override
TODO make protected and use attorneys.
void updateConfig(const ::armarx::aron::data::dto::DictPtr &dto, const Ice::Current &iceCurrent=Ice::emptyCurrent) override
void onPublish(const armarx::SensorAndControl &sac, const armarx::DebugDrawerInterfacePrx &debugDrawer, const armarx::DebugObserverInterfacePrx &debugObservers) override
std::string getClassName(const Ice::Current &iceCurrent=Ice::emptyCurrent) const override
::armarx::aron::data::dto::DictPtr getConfig(const Ice::Current &iceCurrent=Ice::emptyCurrent) override
void rtPreActivateController() override
This function is called before the controller is activated.
Represents a point in time.
Definition DateTime.h:25
static DateTime Now()
Definition DateTime.cpp:51
#define ARMARX_WARNING
The logging level for unexpected behaviour, but not a serious problem.
Definition Logging.h:193
std::shared_ptr< class Robot > RobotPtr
Definition Bus.h:19
::IceInternal::Handle< Dict > DictPtr
This file offers overloads of toIce() and fromIce() functions for STL container types.
::IceInternal::ProxyHandle<::IceProxy::armarx::DebugObserverInterface > DebugObserverInterfacePrx
IceUtil::Handle< class RobotUnit > RobotUnitPtr
Definition FTSensor.h:34
::IceInternal::ProxyHandle<::IceProxy::armarx::DebugDrawerInterface > DebugDrawerInterfacePrx
detail::ControlThreadOutputBufferEntry SensorAndControl
struct armarx::control::njoint_controller::platform::platform_follower_controller::Target::@350352001161100046225215220012313210071321224313 platformVelocityTargets