PlatformGlobalTrajectoryController.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 <atomic>
25#include <map>
26#include <optional>
27#include <string>
28
29#include <Ice/Current.h>
30#include <Ice/Object.h>
31#include <IceUtil/Time.h>
32
33#include <VirtualRobot/VirtualRobot.h>
34
35#include <ArmarXCore/interface/observers/ObserverInterface.h>
37
40#include <RobotAPI/interface/aron/Aron.h>
41#include <RobotAPI/interface/units/RobotUnit/NJointController.h>
42#include <RobotAPI/interface/visualization/DebugDrawerInterface.h>
43
44#include <armarx/control/interface/ConfigurableNJointControllerInterface.h>
47
48namespace armarx
49{
51 class SensorValueHolonomicPlatformWithAbsolutePosition;
52} // namespace armarx
53
55{
60
68
69 struct Twist2D
70 {
71 Eigen::Vector2f linear = Eigen::Vector2f::Zero();
72 float angular = 0;
73
74 void
76 {
77 linear = Eigen::Vector2f::Zero();
78 angular = 0;
79 }
80 };
81
82 using Target = Twist2D;
83
84 struct Debug
85 {
87
91 double orientationError = 0;
92 bool isFinalSegment = false;
93
94 double positionError = 0;
95
96 Eigen::Isometry3f global_T_robot = Eigen::Isometry3f::Identity();
97 };
98
103
104 using NameValueMap = std::map<std::string, float>;
105
107 virtual public NJointControllerWithTripleBuffer<Target>,
108 virtual public armarx::control::ConfigurableNJointControllerInterface
109 {
110 public:
111 using ConfigPtrT = control::ConfigurableNJointControllerConfigPtr;
112
113 Controller(const RobotUnitPtr& robotUnit,
114 const NJointControllerConfigPtr& config,
116
117 ~Controller() override;
118
119 std::string getClassName(const Ice::Current& iceCurrent = Ice::emptyCurrent) const override;
120
121 void rtRun(const IceUtil::Time& sensorValuesTimestamp,
122 const IceUtil::Time& timeSinceLastIteration) override;
123
124 void updateConfig(const ::armarx::aron::data::dto::DictPtr& dto,
125 const Ice::Current& iceCurrent = Ice::emptyCurrent) override;
126
128 getConfig(const ::Ice::Current& = ::Ice::emptyCurrent) override;
129
130 protected:
131 void additionalTask();
132 void onPublish(const SensorAndControl& sac,
133 const DebugDrawerInterfacePrx& debugDrawer,
134 const DebugObserverInterfacePrx& debugObservers) override;
135
136
137 void onInitNJointController() override;
138 void rtPreActivateController() override;
139 void rtPostDeactivateController() override;
140
141 private:
142 struct RobotState
143 {
144 Eigen::Isometry3f global_T_robot;
145 };
146
147 TripleBuffer<Config> configBuffer_updateConfigToAdditionalTask;
148 TripleBuffer<Config> configBuffer_updateConfigToOnPublish;
149 TripleBuffer<Debug> targetBuffer_additionalTaskToOnPublish;
150 TripleBuffer<RobotState> robotStateBuffer_rtToAdditionalTask;
151
152
153 // internal
154 std::atomic_bool rtFirstRun = true;
155 std::atomic_bool rtReady = false;
156
158
159 std::optional<traj_ctrl::global::TrajectoryFollowingController>
160 trajectoryFollowingController;
161
162
163 Devices getDevices(const VirtualRobot::RobotNodeSet& rns);
164
165 // additional task has exclusive access to this variable
166 Twist2D filteredTwist;
167 };
168
169} // namespace armarx::navigation::platform_controller::platform_global_trajectory
Brief description of class ControlTargetHolonomicPlatformVelocity.
NJointControllerWithTripleBuffer(const Target &initialCommands=Target())
A simple triple buffer for lockfree comunication between a single writer and a single reader.
::armarx::aron::data::dto::DictPtr getConfig(const ::Ice::Current &=::Ice::emptyCurrent) override
Controller(const RobotUnitPtr &robotUnit, const NJointControllerConfigPtr &config, const VirtualRobot::RobotPtr &)
void rtPostDeactivateController() override
This function is called after the controller is deactivated.
void rtRun(const IceUtil::Time &sensorValuesTimestamp, const IceUtil::Time &timeSinceLastIteration) override
TODO make protected and use attorneys.
void onPublish(const SensorAndControl &sac, const DebugDrawerInterfacePrx &debugDrawer, const DebugObserverInterfacePrx &debugObservers) override
void updateConfig(const ::armarx::aron::data::dto::DictPtr &dto, const Ice::Current &iceCurrent=Ice::emptyCurrent) override
std::string getClassName(const Ice::Current &iceCurrent=Ice::emptyCurrent) const override
void rtPreActivateController() override
This function is called before the controller is activated.
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