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 
28 
32 
33 #include <ArmarXSimulation/interface/simulator/SimulatorInterface.h>
34 
35 #include <IceUtil/Time.h>
36 
37 #include <string>
38 #include <mutex>
39 #include <cmath>
40 
41 namespace armarx
42 {
43  /**
44  * @class RobotPoseUnitDynamicSimulationPropertyDefinitions
45  * @brief Moves the robot around. Currently only position control is implemented.
46  */
49  {
50  public:
53  {
54  defineOptionalProperty<int>("IntervalMs", 100, "The time in milliseconds between two calls to the simulation method.");
55 
56  //assures that the RobotPose still gets some amount of velocity when near target
57  //defineOptionalProperty<float>("LinearVelocityMin", 0.5, "Minimum Linear velocity of the RobotPose (unit: m/sec).");
58  //defineOptionalProperty<float>("LinearVelocityMax", 1.5, "Maximum Linear velocity of the RobotPose (unit: m/sec).");
59  //defineOptionalProperty<float>("LinearAccelerationMax", 0.9, "Maximum Linear Acceleration (unit: m/sec^2");
60  //defineOptionalProperty<float>("AngularVelocityMax", 0.8, "Maximum Angular velocity of the RobotPose (unit: rad/sec).");
61  //defineOptionalProperty<float>("AngularAccelerationMax", 1.9, "Maximum Angular Acceleration (unit: rad/sec^2");
62  defineOptionalProperty<std::string>("RobotName", "Armar3", "Name of the Robot to use.");
63  //defineOptionalProperty<std::string>("RobotRootNodeName", "Platform", "Name of the Robot node that is used as root. This node needs to have a model attached.");
64  defineOptionalProperty<std::string>("SimulatorProxyName", "Simulator", "Name of the simulator proxy to use.");
65  }
66  };
67 
68  /**
69  * @class RobotPoseUnitDynamicSimulation
70  * @brief This unit connects to the physics simulator topic (default: "Simulator") and handles RobotPose movements.
71  *
72  * @ingroup SensorActorUnits
73  * @ingroup ArmarXSimulatorComponents
74  */
76  virtual public RobotPoseUnit,
77  virtual public RobotPoseUnitDynamicSimulationInterface
78  {
79  public:
80 
81  // inherited from Component
82  std::string getDefaultName() const override
83  {
84  return "RobotPoseUnit";
85  }
86 
87  void onInitRobotPoseUnit() override;
88  void onStartRobotPoseUnit() override;
89  void onStopRobotPoseUnit() override;
90  void onExitRobotPoseUnit() override;
91 
92  void simulationFunction();
93 
94  // proxy implementation
95 
96  void moveTo(const PoseBasePtr& targetPose, Ice::Float positionalAccuracy, Ice::Float orientationalAccuracy, const Ice::Current& c = Ice::emptyCurrent) override;
97 
98  void move(const PoseBasePtr& targetVelocity, const Ice::Current& c = Ice::emptyCurrent) override;
99 
100  void moveRelative(const PoseBasePtr& relativeTarget, Ice::Float positionalAccuracy, Ice::Float orientationalAccuracy, const Ice::Current& c = Ice::emptyCurrent) override;
101 
102  void setMaxVelocities(Ice::Float positionalVelocity, Ice::Float orientationalVelocity, const Ice::Current& c = Ice::emptyCurrent) override;
103 
104  void stopMovement(const Ice::Current& c = Ice::emptyCurrent) override;
105 
106  /**
107  * @see PropertyUser::createPropertyDefinitions()
108  */
110 
111  void updateCurrentPose(const PoseBasePtr& newPose);
112  //void updateCurrentVelocity(const Vector3BasePtr& translationVel, const Vector3BasePtr& rotationVel);
113 
114  // implement SimulatorRobotListener to receive robot updates from simulator
115  void reportState(SimulatedRobotState const& state, const Ice::Current&) override;
116 
117  void setCurrentPose(const PoseBasePtr& newPose);
118 
119 
120  Eigen::Vector3f getRPY(PoseBasePtr pose);
121 
122  std::mutex currentPoseMutex;
125 
126 
131 
132  std::string simulatorPrxName;
133  std::string robotName;
134  ControlMode RobotPoseControlMode;
135 
136  SimulatorInterfacePrx simulatorPrx;
137 
139  };
140 }
141 
armarx::RobotPoseUnitDynamicSimulation::setCurrentPose
void setCurrentPose(const PoseBasePtr &newPose)
Definition: RobotPoseUnitDynamicSimulation.cpp:201
armarx::RobotPoseUnitDynamicSimulation::currentPose
Pose currentPose
Definition: RobotPoseUnitDynamicSimulation.h:127
armarx::VariantType::Float
const VariantTypeId Float
Definition: Variant.h:918
armarx::RobotPoseUnitDynamicSimulation::getRPY
Eigen::Vector3f getRPY(PoseBasePtr pose)
Definition: RobotPoseUnitDynamicSimulation.cpp:146
armarx::RobotPoseUnitDynamicSimulation::moveRelative
void moveRelative(const PoseBasePtr &relativeTarget, Ice::Float positionalAccuracy, Ice::Float orientationalAccuracy, const Ice::Current &c=Ice::emptyCurrent) override
Definition: RobotPoseUnitDynamicSimulation.cpp:161
armarx::RobotPoseUnitDynamicSimulation
This unit connects to the physics simulator topic (default: "Simulator") and handles RobotPose moveme...
Definition: RobotPoseUnitDynamicSimulation.h:75
Pose.h
armarx::RobotPoseUnitDynamicSimulationPropertyDefinitions
Moves the robot around. Currently only position control is implemented.
Definition: RobotPoseUnitDynamicSimulation.h:47
armarx::RobotPoseUnitDynamicSimulation::lastExecutionTime
IceUtil::Time lastExecutionTime
Definition: RobotPoseUnitDynamicSimulation.h:123
armarx::PropertyDefinitionContainer::prefix
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
Definition: PropertyDefinitionContainer.h:333
armarx::RobotPoseUnitDynamicSimulation::getDefaultName
std::string getDefaultName() const override
Retrieve default name of component.
Definition: RobotPoseUnitDynamicSimulation.h:82
PeriodicTask.h
armarx::RobotPoseUnitDynamicSimulation::onStartRobotPoseUnit
void onStartRobotPoseUnit() override
Definition: RobotPoseUnitDynamicSimulation.cpp:87
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:43
armarx::RobotPoseUnitDynamicSimulation::setMaxVelocities
void setMaxVelocities(Ice::Float positionalVelocity, Ice::Float orientationalVelocity, const Ice::Current &c=Ice::emptyCurrent) override
Definition: RobotPoseUnitDynamicSimulation.cpp:177
armarx::RobotPoseUnitDynamicSimulation::simulatorPrxName
std::string simulatorPrxName
Definition: RobotPoseUnitDynamicSimulation.h:132
RobotPoseUnit.h
armarx::RobotPoseUnitDynamicSimulation::robotName
std::string robotName
Definition: RobotPoseUnitDynamicSimulation.h:133
armarx::RobotPoseUnitDynamicSimulation::simulationTask
PeriodicTask< RobotPoseUnitDynamicSimulation >::pointer_type simulationTask
Definition: RobotPoseUnitDynamicSimulation.h:138
armarx::RobotPoseUnitDynamicSimulation::simulationFunction
void simulationFunction()
Definition: RobotPoseUnitDynamicSimulation.cpp:115
armarx::RobotPoseUnitDynamicSimulation::RobotPoseControlMode
ControlMode RobotPoseControlMode
Definition: RobotPoseUnitDynamicSimulation.h:134
armarx::RobotPoseUnitDynamicSimulation::orientationalAccuracy
::Ice::Float orientationalAccuracy
Definition: RobotPoseUnitDynamicSimulation.h:130
armarx::RobotPoseUnitDynamicSimulationPropertyDefinitions::RobotPoseUnitDynamicSimulationPropertyDefinitions
RobotPoseUnitDynamicSimulationPropertyDefinitions(std::string prefix)
Definition: RobotPoseUnitDynamicSimulation.h:51
armarx::RobotPoseUnitDynamicSimulation::targetPose
Pose targetPose
Definition: RobotPoseUnitDynamicSimulation.h:128
armarx::RobotPoseUnitDynamicSimulation::createPropertyDefinitions
PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: RobotPoseUnitDynamicSimulation.cpp:215
armarx::RobotPoseUnit
The RobotPoseUnit class.
Definition: RobotPoseUnit.h:69
armarx::armem::Time
armarx::core::time::DateTime Time
Definition: forward_declarations.h:13
armarx::RobotPoseUnitDynamicSimulation::updateCurrentPose
void updateCurrentPose(const PoseBasePtr &newPose)
Definition: RobotPoseUnitDynamicSimulation.cpp:184
armarx::RobotPoseUnitDynamicSimulation::onExitRobotPoseUnit
void onExitRobotPoseUnit() override
Definition: RobotPoseUnitDynamicSimulation.cpp:101
armarx::Pose
The Pose class.
Definition: Pose.h:242
armarx::RobotPoseUnitDynamicSimulation::onStopRobotPoseUnit
void onStopRobotPoseUnit() override
Definition: RobotPoseUnitDynamicSimulation.cpp:79
armarx::RobotPoseUnitDynamicSimulation::currentPoseMutex
std::mutex currentPoseMutex
Definition: RobotPoseUnitDynamicSimulation.h:122
armarx::RobotPoseUnitPropertyDefinitions
Defines all necessary properties for armarx::RobotPoseUnit.
Definition: RobotPoseUnit.h:42
IceUtil::Handle
Definition: forward_declarations.h:29
armarx::RobotPoseUnitDynamicSimulation::onInitRobotPoseUnit
void onInitRobotPoseUnit() override
Definition: RobotPoseUnitDynamicSimulation.cpp:38
armarx::RobotPoseUnitDynamicSimulation::move
void move(const PoseBasePtr &targetVelocity, const Ice::Current &c=Ice::emptyCurrent) override
Definition: RobotPoseUnitDynamicSimulation.cpp:155
armarx::RobotPoseUnitDynamicSimulation::simulatorPrx
SimulatorInterfacePrx simulatorPrx
Definition: RobotPoseUnitDynamicSimulation.h:136
armarx::RobotPoseUnitDynamicSimulation::intervalMs
int intervalMs
Definition: RobotPoseUnitDynamicSimulation.h:124
armarx::RobotPoseUnitDynamicSimulation::positionalAccuracy
::Ice::Float positionalAccuracy
Definition: RobotPoseUnitDynamicSimulation.h:129
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::RobotPoseUnitDynamicSimulation::reportState
void reportState(SimulatedRobotState const &state, const Ice::Current &) override
Definition: RobotPoseUnitDynamicSimulation.cpp:196
armarx::RobotPoseUnitDynamicSimulation::stopMovement
void stopMovement(const Ice::Current &c=Ice::emptyCurrent) override
Definition: RobotPoseUnitDynamicSimulation.cpp:106
armarx::RobotPoseUnitDynamicSimulation::moveTo
void moveTo(const PoseBasePtr &targetPose, Ice::Float positionalAccuracy, Ice::Float orientationalAccuracy, const Ice::Current &c=Ice::emptyCurrent) override
Definition: RobotPoseUnitDynamicSimulation.cpp:129
ImportExportComponent.h