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,
36  {
37  target = useControlTarget(cfg->platformName, ControlModes::HolonomicPlatformVelocity)
40  << "The actuator " << cfg->platformName << " has no control mode "
41  << ControlModes::HolonomicPlatformVelocity;
42 
43  initialSettings.velocityX = cfg->initialVelocityX;
44  initialSettings.velocityY = cfg->initialVelocityY;
45  initialSettings.velocityRotation = cfg->initialVelocityRotation;
47  }
48 
49  void
51  const IceUtil::Time& sensorValuesTimestamp,
52  const IceUtil::Time&)
53  {
54  auto commandAge = sensorValuesTimestamp - rtGetControlStruct().commandTimestamp;
55 
56  if (commandAge > maxCommandDelay && // command must be recent
57  (rtGetControlStruct().velocityX != 0.0f || rtGetControlStruct().velocityY != 0.0f ||
58  rtGetControlStruct().velocityRotation !=
59  0.0f)) // only throw error if any command is not zero
60  {
61  throw LocalException(
62  "Platform target velocity was not set for a too long time: delay: ")
63  << commandAge.toSecondsDouble()
64  << " s, max allowed delay: " << maxCommandDelay.toSecondsDouble() << " s";
65  }
66  else
67  {
71  }
72  }
73 
76  "NJointHolonomicPlatformUnitVelocityPassThroughController");
77 } // namespace armarx
armarx::NJointControllerWithTripleBuffer< NJointHolonomicPlatformVelocityControllerControlData >::reinitTripleBuffer
void reinitTripleBuffer(const NJointHolonomicPlatformVelocityControllerControlData &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::initialSettings
NJointHolonomicPlatformVelocityControllerControlData initialSettings
Definition: NJointHolonomicPlatformUnitVelocityPassThroughController.h:76
armarx::NJointControllerRegistration
Definition: NJointControllerRegistry.h:74
armarx::NJointControllerWithTripleBuffer< NJointHolonomicPlatformVelocityControllerControlData >::rtGetControlStruct
const NJointHolonomicPlatformVelocityControllerControlData & rtGetControlStruct() const
Definition: NJointControllerWithTripleBuffer.h:32
armarx::NJointHolonomicPlatformVelocityControllerControlData::velocityRotation
float velocityRotation
Definition: NJointHolonomicPlatformVelocityControllerInterface.h:37
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::NJointHolonomicPlatformVelocityControllerControlData::velocityX
float velocityX
Definition: NJointHolonomicPlatformVelocityControllerInterface.h:35
armarx::NJointHolonomicPlatformUnitVelocityPassThroughController::target
ControlTargetHolonomicPlatformVelocity * target
Definition: NJointHolonomicPlatformUnitVelocityPassThroughController.h:75
armarx::ControlTargetHolonomicPlatformVelocity::velocityRotation
float velocityRotation
Definition: ControlTargetHolonomicPlatformVelocity.h:43
armarx::NJointHolonomicPlatformVelocityControllerInterface::maxCommandDelay
IceUtil::Time maxCommandDelay
Definition: NJointHolonomicPlatformVelocityControllerInterface.h:57
armarx::registrationNJointHolonomicPlatformUnitVelocityPassThroughController
NJointControllerRegistration< NJointHolonomicPlatformUnitVelocityPassThroughController > registrationNJointHolonomicPlatformUnitVelocityPassThroughController("NJointHolonomicPlatformUnitVelocityPassThroughController")
armarx::ControlTargetHolonomicPlatformVelocity::velocityX
float velocityX
Definition: ControlTargetHolonomicPlatformVelocity.h:41
armarx::NJointHolonomicPlatformVelocityControllerControlData::velocityY
float velocityY
Definition: NJointHolonomicPlatformVelocityControllerInterface.h:36
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::NJointHolonomicPlatformVelocityControllerControlData::commandTimestamp
IceUtil::Time commandTimestamp
Definition: NJointHolonomicPlatformVelocityControllerInterface.h:38
armarx::RobotUnit
The RobotUnit class manages a robot and its controllers.
Definition: RobotUnit.h:180
armarx::NJointHolonomicPlatformUnitVelocityPassThroughController::rtRun
void rtRun(const IceUtil::Time &, const IceUtil::Time &) override
TODO make protected and use attorneys.
Definition: NJointHolonomicPlatformUnitVelocityPassThroughController.cpp:50
NJointHolonomicPlatformUnitVelocityPassThroughController.h
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