NJointHolonomicPlatformUnitVelocityPassThroughController.cpp
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  * @package RobotAPI::ArmarXObjects::NJointHolonomicPlatformUnitVelocityPassThroughController
17  * @author Raphael Grimm ( raphael dot grimm at kit dot edu )
18  * @date 2017
19  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20  * GNU General Public License
21  */
22 
24 
26 
28 
29 namespace armarx
30 {
33  RobotUnit* prov,
34  NJointHolonomicPlatformUnitVelocityPassThroughControllerConfigPtr cfg,
35  const VirtualRobot::RobotPtr&) :
36  maxCommandDelay(IceUtil::Time::milliSeconds(500))
37  {
38  target = useControlTarget(cfg->platformName, ControlModes::HolonomicPlatformVelocity)
41  << "The actuator " << cfg->platformName << " has no control mode "
42  << ControlModes::HolonomicPlatformVelocity;
43 
44  initialSettings.velocityX = cfg->initialVelocityX;
45  initialSettings.velocityY = cfg->initialVelocityY;
46  initialSettings.velocityRotation = cfg->initialVelocityRotation;
48  }
49 
50  void
52  const IceUtil::Time& sensorValuesTimestamp,
53  const IceUtil::Time&)
54  {
55  auto commandAge = sensorValuesTimestamp - rtGetControlStruct().commandTimestamp;
56 
57  if (commandAge > maxCommandDelay && // command must be recent
58  (rtGetControlStruct().velocityX != 0.0f || rtGetControlStruct().velocityY != 0.0f ||
59  rtGetControlStruct().velocityRotation !=
60  0.0f)) // only throw error if any command is not zero
61  {
62  throw LocalException(
63  "Platform target velocity was not set for a too long time: delay: ")
64  << commandAge.toSecondsDouble()
65  << " s, max allowed delay: " << maxCommandDelay.toSecondsDouble() << " s";
66  }
67  else
68  {
72  }
73  }
74 
75  void
77  float velocityY,
78  float velocityRotation)
79  {
81  getWriterControlStruct().velocityX = velocityX;
82  getWriterControlStruct().velocityY = velocityY;
83  getWriterControlStruct().velocityRotation = velocityRotation;
84  getWriterControlStruct().commandTimestamp = IceUtil::Time::now();
86  }
87 
90  {
91  return maxCommandDelay;
92  }
93 
94  void
96  const IceUtil::Time& value)
97  {
99  }
100 
103  "NJointHolonomicPlatformUnitVelocityPassThroughController");
104 } // namespace armarx
armarx::NJointControllerWithTripleBuffer< NJointHolonomicPlatformUnitVelocityPassThroughControllerControlData >::reinitTripleBuffer
void reinitTripleBuffer(const NJointHolonomicPlatformUnitVelocityPassThroughControllerControlData &initial)
Definition: NJointControllerWithTripleBuffer.h:68
armarx::ControlTargetHolonomicPlatformVelocity
Brief description of class ControlTargetHolonomicPlatformVelocity.
Definition: ControlTargetHolonomicPlatformVelocity.h:38
armarx::ControlTargetBase::asA
const T * asA() const
Definition: ControlTargetBase.h:76
armarx::NJointHolonomicPlatformUnitVelocityPassThroughController::setMaxCommandDelay
void setMaxCommandDelay(const IceUtil::Time &value)
Definition: NJointHolonomicPlatformUnitVelocityPassThroughController.cpp:95
armarx::NJointControllerRegistration
Definition: NJointControllerRegistry.h:74
armarx::NJointControllerWithTripleBuffer< NJointHolonomicPlatformUnitVelocityPassThroughControllerControlData >::rtGetControlStruct
const NJointHolonomicPlatformUnitVelocityPassThroughControllerControlData & rtGetControlStruct() const
Definition: NJointControllerWithTripleBuffer.h:32
armarx::NJointControllerBase::useControlTarget
ControlTargetBase * useControlTarget(const std::string &deviceName, const std::string &controlMode)
Declares to calculate the ControlTarget for the given ControlDevice in the given ControlMode when rtR...
Definition: NJointController.cpp:410
armarx::NJointHolonomicPlatformUnitVelocityPassThroughController::NJointHolonomicPlatformUnitVelocityPassThroughController
NJointHolonomicPlatformUnitVelocityPassThroughController(RobotUnit *prov, NJointHolonomicPlatformUnitVelocityPassThroughControllerConfigPtr config, const VirtualRobot::RobotPtr &)
Definition: NJointHolonomicPlatformUnitVelocityPassThroughController.cpp:32
armarx::NJointHolonomicPlatformUnitVelocityPassThroughController::maxCommandDelay
IceUtil::Time maxCommandDelay
Definition: NJointHolonomicPlatformUnitVelocityPassThroughController.h:91
armarx::NJointHolonomicPlatformUnitVelocityPassThroughController::target
ControlTargetHolonomicPlatformVelocity * target
Definition: NJointHolonomicPlatformUnitVelocityPassThroughController.h:93
armarx::NJointHolonomicPlatformUnitVelocityPassThroughControllerControlData::velocityRotation
float velocityRotation
Definition: NJointHolonomicPlatformUnitVelocityPassThroughController.h:53
IceUtil
Definition: Instance.h:21
armarx::NJointControllerWithTripleBuffer< NJointHolonomicPlatformUnitVelocityPassThroughControllerControlData >::getWriterControlStruct
NJointHolonomicPlatformUnitVelocityPassThroughControllerControlData & getWriterControlStruct()
Definition: NJointControllerWithTripleBuffer.h:54
armarx::NJointControllerWithTripleBuffer< NJointHolonomicPlatformUnitVelocityPassThroughControllerControlData >::LockGuardType
std::lock_guard< std::recursive_mutex > LockGuardType
Definition: NJointControllerWithTripleBuffer.h:14
armarx::ControlTargetHolonomicPlatformVelocity::velocityRotation
float velocityRotation
Definition: ControlTargetHolonomicPlatformVelocity.h:43
armarx::NJointHolonomicPlatformUnitVelocityPassThroughController::getMaxCommandDelay
IceUtil::Time getMaxCommandDelay() const
Definition: NJointHolonomicPlatformUnitVelocityPassThroughController.cpp:89
cxxopts::value
std::shared_ptr< Value > value()
Definition: cxxopts.hpp:926
armarx::registrationNJointHolonomicPlatformUnitVelocityPassThroughController
NJointControllerRegistration< NJointHolonomicPlatformUnitVelocityPassThroughController > registrationNJointHolonomicPlatformUnitVelocityPassThroughController("NJointHolonomicPlatformUnitVelocityPassThroughController")
armarx::NJointHolonomicPlatformUnitVelocityPassThroughController::initialSettings
NJointHolonomicPlatformUnitVelocityPassThroughControllerControlData initialSettings
Definition: NJointHolonomicPlatformUnitVelocityPassThroughController.h:94
armarx::NJointHolonomicPlatformUnitVelocityPassThroughControllerControlData::commandTimestamp
IceUtil::Time commandTimestamp
Definition: NJointHolonomicPlatformUnitVelocityPassThroughController.h:54
armarx::NJointControllerWithTripleBuffer< NJointHolonomicPlatformUnitVelocityPassThroughControllerControlData >::writeControlStruct
void writeControlStruct()
Definition: NJointControllerWithTripleBuffer.h:44
armarx::NJointControllerWithTripleBuffer< NJointHolonomicPlatformUnitVelocityPassThroughControllerControlData >::controlDataMutex
MutexType controlDataMutex
Definition: NJointControllerWithTripleBuffer.h:73
armarx::ControlTargetHolonomicPlatformVelocity::velocityX
float velocityX
Definition: ControlTargetHolonomicPlatformVelocity.h:41
armarx::armem::Time
armarx::core::time::DateTime Time
Definition: forward_declarations.h:13
armarx::ControlTargetHolonomicPlatformVelocity::velocityY
float velocityY
Definition: ControlTargetHolonomicPlatformVelocity.h:42
ExpressionException.h
ARMARX_CHECK_EXPRESSION
#define ARMARX_CHECK_EXPRESSION(expression)
This macro evaluates the expression and if it turns out to be false it will throw an ExpressionExcept...
Definition: ExpressionException.h:73
armarx::RobotUnit
The RobotUnit class manages a robot and its controllers.
Definition: RobotUnit.h:180
armarx::NJointHolonomicPlatformUnitVelocityPassThroughControllerControlData::velocityX
float velocityX
Definition: NJointHolonomicPlatformUnitVelocityPassThroughController.h:51
armarx::NJointHolonomicPlatformUnitVelocityPassThroughController::rtRun
void rtRun(const IceUtil::Time &, const IceUtil::Time &) override
TODO make protected and use attorneys.
Definition: NJointHolonomicPlatformUnitVelocityPassThroughController.cpp:51
NJointHolonomicPlatformUnitVelocityPassThroughController.h
armarx::NJointHolonomicPlatformUnitVelocityPassThroughControllerControlData::velocityY
float velocityY
Definition: NJointHolonomicPlatformUnitVelocityPassThroughController.h:52
armarx::NJointHolonomicPlatformUnitVelocityPassThroughController::setVelocites
void setVelocites(float velocityX, float velocityY, float velocityRotation)
Definition: NJointHolonomicPlatformUnitVelocityPassThroughController.cpp:76
NJointControllerRegistry.h
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
VirtualRobot::RobotPtr
std::shared_ptr< class Robot > RobotPtr
Definition: Bus.h:18