RobotPoseUnitDynamicSimulation.h
Go to the documentation of this file.
1/*
2 * This file is part of ArmarX.
3 *
4 * Copyright (C) 2013-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5 *
6 * ArmarX is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * ArmarX is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * @package ArmarXSimulation::units
19 * @author Nikolaus Vahrenkamp (vahrenkamp at kit dot edu)
20 * @date 2016
21 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22 * GNU General Public License
23 */
24
25#pragma once
26
27#include <cmath>
28#include <mutex>
29#include <string>
30
31#include <IceUtil/Time.h>
32
35
38
39#include <ArmarXSimulation/interface/simulator/SimulatorInterface.h>
40
41namespace armarx
42{
43 /**
44 * @class RobotPoseUnitDynamicSimulationPropertyDefinitions
45 * @brief Moves the robot around. Currently only position control is implemented.
46 */
49 {
50 public:
53 {
55 "IntervalMs",
56 100,
57 "The time in milliseconds between two calls to the simulation method.");
58
59 //assures that the RobotPose still gets some amount of velocity when near target
60 //defineOptionalProperty<float>("LinearVelocityMin", 0.5, "Minimum Linear velocity of the RobotPose (unit: m/sec).");
61 //defineOptionalProperty<float>("LinearVelocityMax", 1.5, "Maximum Linear velocity of the RobotPose (unit: m/sec).");
62 //defineOptionalProperty<float>("LinearAccelerationMax", 0.9, "Maximum Linear Acceleration (unit: m/sec^2");
63 //defineOptionalProperty<float>("AngularVelocityMax", 0.8, "Maximum Angular velocity of the RobotPose (unit: rad/sec).");
64 //defineOptionalProperty<float>("AngularAccelerationMax", 1.9, "Maximum Angular Acceleration (unit: rad/sec^2");
65 defineOptionalProperty<std::string>("RobotName", "Armar3", "Name of the Robot to use.");
66 //defineOptionalProperty<std::string>("RobotRootNodeName", "Platform", "Name of the Robot node that is used as root. This node needs to have a model attached.");
68 "SimulatorProxyName", "Simulator", "Name of the simulator proxy to use.");
69 }
70 };
71
72 /**
73 * @class RobotPoseUnitDynamicSimulation
74 * @brief This unit connects to the physics simulator topic (default: "Simulator") and handles RobotPose movements.
75 *
76 * @ingroup SensorActorUnits
77 * @ingroup ArmarXSimulatorComponents
78 */
80 virtual public RobotPoseUnit,
81 virtual public RobotPoseUnitDynamicSimulationInterface
82 {
83 public:
84 // inherited from Component
85 static std::string GetDefaultName();
86 std::string
87 getDefaultName() const override
88 {
89 return GetDefaultName();
90 }
91
92 void onInitRobotPoseUnit() override;
93 void onStartRobotPoseUnit() override;
94 void onStopRobotPoseUnit() override;
95 void onExitRobotPoseUnit() override;
96
97 void simulationFunction();
98
99 // proxy implementation
100
101 void moveTo(const PoseBasePtr& targetPose,
102 Ice::Float positionalAccuracy,
103 Ice::Float orientationalAccuracy,
104 const Ice::Current& c = Ice::emptyCurrent) override;
105
106 void move(const PoseBasePtr& targetVelocity,
107 const Ice::Current& c = Ice::emptyCurrent) override;
108
109 void moveRelative(const PoseBasePtr& relativeTarget,
110 Ice::Float positionalAccuracy,
111 Ice::Float orientationalAccuracy,
112 const Ice::Current& c = Ice::emptyCurrent) override;
113
114 void setMaxVelocities(Ice::Float positionalVelocity,
115 Ice::Float orientationalVelocity,
116 const Ice::Current& c = Ice::emptyCurrent) override;
117
118 void stopMovement(const Ice::Current& c = Ice::emptyCurrent) override;
119
120 /**
121 * @see PropertyUser::createPropertyDefinitions()
122 */
124
125 void updateCurrentPose(const PoseBasePtr& newPose);
126 //void updateCurrentVelocity(const Vector3BasePtr& translationVel, const Vector3BasePtr& rotationVel);
127
128 // implement SimulatorRobotListener to receive robot updates from simulator
129 void reportState(SimulatedRobotState const& state, const Ice::Current&) override;
130
131 void setCurrentPose(const PoseBasePtr& newPose);
132
133
134 Eigen::Vector3f getRPY(PoseBasePtr pose);
135
137 IceUtil::Time lastExecutionTime;
139
140
143 ::Ice::Float positionalAccuracy;
145
146 std::string simulatorPrxName;
147 std::string robotName;
149
150 SimulatorInterfacePrx simulatorPrx;
151
153 };
154} // namespace armarx
constexpr T c
IceUtil::Handle< PeriodicTask< T > > pointer_type
Shared pointer type for convenience.
The Pose class.
Definition Pose.h:243
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
PropertyDefinition< PropertyType > & defineOptionalProperty(const std::string &name, PropertyType defaultValue, const std::string &description="", PropertyDefinitionBase::PropertyConstness constness=PropertyDefinitionBase::eConstant)
This unit connects to the physics simulator topic (default: "Simulator") and handles RobotPose moveme...
void stopMovement(const Ice::Current &c=Ice::emptyCurrent) override
PeriodicTask< RobotPoseUnitDynamicSimulation >::pointer_type simulationTask
void moveRelative(const PoseBasePtr &relativeTarget, Ice::Float positionalAccuracy, Ice::Float orientationalAccuracy, const Ice::Current &c=Ice::emptyCurrent) override
void reportState(SimulatedRobotState const &state, const Ice::Current &) override
PropertyDefinitionsPtr createPropertyDefinitions() override
void moveTo(const PoseBasePtr &targetPose, Ice::Float positionalAccuracy, Ice::Float orientationalAccuracy, const Ice::Current &c=Ice::emptyCurrent) override
void move(const PoseBasePtr &targetVelocity, const Ice::Current &c=Ice::emptyCurrent) override
void setMaxVelocities(Ice::Float positionalVelocity, Ice::Float orientationalVelocity, const Ice::Current &c=Ice::emptyCurrent) override
std::string getDefaultName() const override
Retrieve default name of component.
RobotPoseUnitPropertyDefinitions(std::string prefix)
The RobotPoseUnit class.
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.