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
25#include <VirtualRobot/Robot.h>
26
28
30
31namespace armarx
32{
35 RobotUnit* prov,
36 NJointHolonomicPlatformUnitVelocityPassThroughControllerConfigPtr cfg,
38 {
39 target = useControlTarget(cfg->platformName, ControlModes::HolonomicPlatformVelocity)
42 << "The actuator " << cfg->platformName << " has no control mode "
43 << ControlModes::HolonomicPlatformVelocity;
44
45 initialSettings.velocityX = cfg->initialVelocityX;
46 initialSettings.velocityY = cfg->initialVelocityY;
47 initialSettings.velocityRotation = cfg->initialVelocityRotation;
49 }
50
51 void
53 const IceUtil::Time& sensorValuesTimestamp,
54 const IceUtil::Time&)
55 {
56 auto commandAge = sensorValuesTimestamp - rtGetControlStruct().commandTimestamp;
57
58 if (commandAge > maxCommandDelay && // command must be recent
59 (rtGetControlStruct().velocityX != 0.0f || rtGetControlStruct().velocityY != 0.0f ||
60 rtGetControlStruct().velocityRotation !=
61 0.0f)) // only throw error if any command is not zero
62 {
63 throw LocalException(
64 "Platform target velocity was not set for a too long time: delay: ")
65 << commandAge.toSecondsDouble()
66 << " s, max allowed delay: " << maxCommandDelay.toSecondsDouble() << " s";
67 }
68 else
69 {
70 target->velocityX = rtGetControlStruct().velocityX;
71 target->velocityY = rtGetControlStruct().velocityY;
72 target->velocityRotation = rtGetControlStruct().velocityRotation;
73 }
74 }
75
78 "NJointHolonomicPlatformUnitVelocityPassThroughController");
79} // namespace armarx
Brief description of class ControlTargetHolonomicPlatformVelocity.
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...
void reinitTripleBuffer(const NJointHolonomicPlatformVelocityControllerControlData &initial)
NJointHolonomicPlatformUnitVelocityPassThroughController(RobotUnit *prov, NJointHolonomicPlatformUnitVelocityPassThroughControllerConfigPtr config, const VirtualRobot::RobotPtr &)
void rtRun(const IceUtil::Time &, const IceUtil::Time &) override
TODO make protected and use attorneys.
The RobotUnit class manages a robot and its controllers.
Definition RobotUnit.h:192
#define ARMARX_CHECK_EXPRESSION(expression)
This macro evaluates the expression and if it turns out to be false it will throw an ExpressionExcept...
std::shared_ptr< class Robot > RobotPtr
Definition Bus.h:19
This file offers overloads of toIce() and fromIce() functions for STL container types.
NJointControllerRegistration< NJointHolonomicPlatformUnitVelocityPassThroughController > registrationNJointHolonomicPlatformUnitVelocityPassThroughController("NJointHolonomicPlatformUnitVelocityPassThroughController")