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 <VirtualRobot/Robot.h>
25 #include <VirtualRobot/VirtualRobot.h>
26 
31 
32 #include <armarx/control/interface/ConfigurableNJointControllerInterface.h>
35 
36 namespace armarx
37 {
38  class ControlTargetHolonomicPlatformVelocity;
39  class SensorValueHolonomicPlatformWithAbsolutePosition;
40 } // namespace armarx
41 
43 {
44  struct Targets
45  {
47  };
48 
49  struct Config
50  {
52 
55  };
56 
57  struct Twist2D
58  {
59  Eigen::Vector2f linear = Eigen::Vector2f::Zero();
60  float angular = 0;
61 
62  void
64  {
65  linear = Eigen::Vector2f::Zero();
66  angular = 0;
67  }
68  };
69 
70  using Target = Twist2D;
71 
72  struct Devices
73  {
75  };
76 
77  using NameValueMap = std::map<std::string, float>;
78 
79  class Controller :
80  virtual public NJointControllerWithTripleBuffer<Target>,
81  virtual public armarx::control::ConfigurableNJointControllerInterface
82  {
83  public:
84  using ConfigPtrT = control::ConfigurableNJointControllerConfigPtr;
85 
86  Controller(const RobotUnitPtr& robotUnit,
87  const NJointControllerConfigPtr& config,
88  const VirtualRobot::RobotPtr&);
89 
90  ~Controller() override;
91 
92  std::string getClassName(const Ice::Current& iceCurrent = Ice::emptyCurrent) const override;
93 
94  void rtRun(const IceUtil::Time& sensorValuesTimestamp,
95  const IceUtil::Time& timeSinceLastIteration) override;
96 
98  const Ice::Current& iceCurrent = Ice::emptyCurrent) override;
99 
100  ::armarx::aron::data::dto::DictPtr getConfig(const ::Ice::Current& = ::Ice::emptyCurrent) override
101  {
102  ARMARX_ERROR << "NYI";
103  return nullptr;
104  }
105 
106  protected:
107  void additionalTask();
108  void onPublish(const SensorAndControl& sac,
109  const DebugDrawerInterfacePrx& debugDrawer,
110  const DebugObserverInterfacePrx& debugObservers) override;
111 
112 
113  void onInitNJointController() override;
114  void rtPreActivateController() override;
115  void rtPostDeactivateController() override;
116 
117  private:
118  struct RobotState
119  {
120  Eigen::Isometry3f global_T_robot;
121  };
122 
123  TripleBuffer<Config> configBuffer_updateConfigToAdditionalTask;
124  TripleBuffer<Config> configBuffer_updateConfigToOnPublish;
125  TripleBuffer<Target> targetBuffer_additionalTaskToOnPublish;
126  TripleBuffer<RobotState> robotStateBuffer_rtToAdditionalTask;
127 
128  // internal
129  std::atomic_bool rtFirstRun = true;
130  std::atomic_bool rtReady = false;
131 
133 
134  std::optional<traj_ctrl::local::TrajectoryFollowingController>
135  trajectoryFollowingController;
136 
137 
138  Devices getDevices(const VirtualRobot::RobotNodeSet& rns);
139 
140 
141  // additional task has exclusive access to this variable
142  Twist2D filteredTwist;
143  };
144 
145 } // namespace armarx::navigation::platform_controller::platform_local_trajectory
armarx::ControlTargetHolonomicPlatformVelocity
Brief description of class ControlTargetHolonomicPlatformVelocity.
Definition: ControlTargetHolonomicPlatformVelocity.h:38
NJointControllerWithTripleBuffer.h
armarx::navigation::platform_controller::platform_local_trajectory::Config::targets
Targets targets
Definition: PlatformLocalTrajectoryController.h:54
armarx::navigation::platform_controller::platform_local_trajectory::Controller::rtPostDeactivateController
void rtPostDeactivateController() override
This function is called after the controller is deactivated.
Definition: PlatformLocalTrajectoryController.cpp:203
SensorValueHolonomicPlatform.h
armarx::navigation::traj_ctrl::local::TrajectoryFollowingControllerParams
Definition: TrajectoryFollowingController.h:35
armarx::NJointControllerWithTripleBuffer
Definition: NJointControllerWithTripleBuffer.h:10
RobotUnit.h
armarx::navigation::platform_controller::platform_local_trajectory::Config
Definition: PlatformLocalTrajectoryController.h:49
armarx::navigation::platform_controller::platform_local_trajectory::Twist2D::linear
Eigen::Vector2f linear
Definition: PlatformLocalTrajectoryController.h:59
armarx::navigation::platform_controller::platform_local_trajectory::Targets
Definition: PlatformLocalTrajectoryController.h:44
armarx::NJointControllerBase::ConfigPtrT
NJointControllerConfigPtr ConfigPtrT
Definition: NJointControllerBase.h:586
armarx::navigation::platform_controller::platform_local_trajectory::Devices::platformTarget
ControlTargetHolonomicPlatformVelocity * platformTarget
Definition: PlatformLocalTrajectoryController.h:74
armarx::navigation::platform_controller::platform_local_trajectory::Controller
Definition: PlatformLocalTrajectoryController.h:79
armarx::navigation::platform_controller::platform_local_trajectory::Controller::onInitNJointController
void onInitNJointController() override
Definition: PlatformLocalTrajectoryController.cpp:167
armarx::detail::ControlThreadOutputBufferEntry
Definition: ControlThreadOutputBuffer.h:177
armarx::navigation::platform_controller::platform_local_trajectory::Controller::getConfig
::armarx::aron::data::dto::DictPtr getConfig(const ::Ice::Current &=::Ice::emptyCurrent) override
Definition: PlatformLocalTrajectoryController.h:100
armarx::navigation::platform_controller::platform_local_trajectory::Controller::additionalTask
void additionalTask()
Definition: PlatformLocalTrajectoryController.cpp:102
TrajectoryFollowingController.h
armarx::navigation::platform_controller::platform_local_trajectory::Controller::onPublish
void onPublish(const SensorAndControl &sac, const DebugDrawerInterfacePrx &debugDrawer, const DebugObserverInterfacePrx &debugObservers) override
Definition: PlatformLocalTrajectoryController.cpp:145
armarx::navigation::core::LocalTrajectory
Definition: Trajectory.h:167
ControlTarget1DoFActuator.h
armarx::navigation::platform_controller::platform_local_trajectory::Devices
Definition: PlatformLocalTrajectoryController.h:72
armarx::navigation::platform_controller::platform_local_trajectory::Controller::updateConfig
void updateConfig(const ::armarx::aron::data::dto::DictPtr &dto, const Ice::Current &iceCurrent=Ice::emptyCurrent) override
Definition: PlatformLocalTrajectoryController.cpp:81
armarx::navigation::platform_controller::platform_local_trajectory::Controller::getClassName
std::string getClassName(const Ice::Current &iceCurrent=Ice::emptyCurrent) const override
Definition: PlatformLocalTrajectoryController.cpp:57
ARMARX_ERROR
#define ARMARX_ERROR
Definition: Logging.h:189
armarx::armem::Time
armarx::core::time::DateTime Time
Definition: forward_declarations.h:13
armarx::navigation::platform_controller::platform_local_trajectory::Twist2D::reset
void reset()
Definition: PlatformLocalTrajectoryController.h:63
armarx::navigation::platform_controller::platform_local_trajectory::Controller::rtPreActivateController
void rtPreActivateController() override
This function is called before the controller is activated.
Definition: PlatformLocalTrajectoryController.cpp:190
armarx::navigation::platform_controller::platform_local_trajectory::Controller::rtRun
void rtRun(const IceUtil::Time &sensorValuesTimestamp, const IceUtil::Time &timeSinceLastIteration) override
TODO make protected and use attorneys.
Definition: PlatformLocalTrajectoryController.cpp:64
armarx::aron::data::DictPtr
std::shared_ptr< Dict > DictPtr
Definition: Dict.h:41
armarx::navigation::platform_controller::platform_local_trajectory::NameValueMap
std::map< std::string, float > NameValueMap
Definition: PlatformLocalTrajectoryController.h:77
armarx::navigation::platform_controller::platform_local_trajectory::Controller::~Controller
~Controller() override
IceInternal::ProxyHandle<::IceProxy::armarx::DebugDrawerInterface >
armarx::navigation::platform_controller::platform_local_trajectory::Twist2D::angular
float angular
Definition: PlatformLocalTrajectoryController.h:60
armarx::navigation::platform_controller::platform_local_trajectory::Twist2D
Definition: PlatformLocalTrajectoryController.h:57
armarx::navigation::platform_controller::platform_local_trajectory::Targets::trajectory
core::LocalTrajectory trajectory
Definition: PlatformLocalTrajectoryController.h:46
types.h
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::navigation::platform_controller::platform_local_trajectory::Config::params
Params params
Definition: PlatformLocalTrajectoryController.h:53
VirtualRobot::RobotPtr
std::shared_ptr< class Robot > RobotPtr
Definition: Bus.h:18
armarx::TripleBuffer< Config >
armarx::navigation::platform_controller::platform_local_trajectory::Controller::Controller
Controller(const RobotUnitPtr &robotUnit, const NJointControllerConfigPtr &config, const VirtualRobot::RobotPtr &)
Definition: PlatformLocalTrajectoryController.cpp:21
armarx::navigation::platform_controller::platform_local_trajectory
Definition: aron_conversions.cpp:56