PlatformLocalTrajectoryController.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 <Eigen/Geometry>
30
31#include <Ice/Current.h>
32#include <Ice/Object.h>
33#include <IceUtil/Time.h>
34
35#include <VirtualRobot/VirtualRobot.h>
36
37#include <ArmarXCore/interface/observers/ObserverInterface.h>
39
42#include <RobotAPI/interface/aron/Aron.h>
43#include <RobotAPI/interface/units/RobotUnit/NJointController.h>
44#include <RobotAPI/interface/visualization/DebugDrawerInterface.h>
45
46#include <armarx/control/interface/ConfigurableNJointControllerInterface.h>
49
50namespace armarx
51{
53 class SensorValueHolonomicPlatformWithAbsolutePosition;
54} // namespace armarx
55
57{
62
70
71 struct Twist2D
72 {
73 Eigen::Vector2f linear = Eigen::Vector2f::Zero();
74 float angular = 0;
75
76 void
78 {
79 linear = Eigen::Vector2f::Zero();
80 angular = 0;
81 }
82 };
83
91
96
97 using NameValueMap = std::map<std::string, float>;
98
99 class Controller :
100 virtual public NJointControllerWithTripleBuffer<Target>,
101 virtual public armarx::control::ConfigurableNJointControllerInterface
102 {
103 public:
104 using ConfigPtrT = control::ConfigurableNJointControllerConfigPtr;
105
106 Controller(const RobotUnitPtr& robotUnit,
107 const NJointControllerConfigPtr& config,
109
110 ~Controller() override;
111
112 std::string getClassName(const Ice::Current& iceCurrent = Ice::emptyCurrent) const override;
113
114 void rtRun(const IceUtil::Time& sensorValuesTimestamp,
115 const IceUtil::Time& timeSinceLastIteration) override;
116
117 void updateConfig(const ::armarx::aron::data::dto::DictPtr& dto,
118 const Ice::Current& iceCurrent = Ice::emptyCurrent) override;
119
121 getConfig(const ::Ice::Current& = ::Ice::emptyCurrent) override;
122
123 protected:
124 void additionalTask();
125 void onPublish(const SensorAndControl& sac,
126 const DebugDrawerInterfacePrx& debugDrawer,
127 const DebugObserverInterfacePrx& debugObservers) override;
128
129
130 void onInitNJointController() override;
131 void rtPreActivateController() override;
132 void rtPostDeactivateController() override;
133
134 private:
135 struct RobotState
136 {
137 Eigen::Isometry3f global_T_robot = Eigen::Isometry3f::Identity();
138 };
139
140 TripleBuffer<Config> configBuffer_updateConfigToAdditionalTask;
141 TripleBuffer<Config> configBuffer_updateConfigToOnPublish;
142 TripleBuffer<Target> targetBuffer_additionalTaskToOnPublish;
143 TripleBuffer<RobotState> robotStateBuffer_rtToAdditionalTask;
144
145 // internal
146 std::atomic_bool rtFirstRun = true;
147 std::atomic_bool rtReady = false;
148
150
151 std::optional<traj_ctrl::local::TrajectoryFollowingController>
152 trajectoryFollowingController;
153
154
155 Devices getDevices(const VirtualRobot::RobotNodeSet& rns);
156
157
158 // additional task has exclusive access to this variable
159 Twist2D filteredTwist;
160 };
161
162} // namespace armarx::navigation::platform_controller::platform_local_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