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 std::string
86 getDefaultName() const override
87 {
88 return "RobotPoseUnit";
89 }
90
91 void onInitRobotPoseUnit() override;
92 void onStartRobotPoseUnit() override;
93 void onStopRobotPoseUnit() override;
94 void onExitRobotPoseUnit() override;
95
96 void simulationFunction();
97
98 // proxy implementation
99
100 void moveTo(const PoseBasePtr& targetPose,
101 Ice::Float positionalAccuracy,
102 Ice::Float orientationalAccuracy,
103 const Ice::Current& c = Ice::emptyCurrent) override;
104
105 void move(const PoseBasePtr& targetVelocity,
106 const Ice::Current& c = Ice::emptyCurrent) override;
107
108 void moveRelative(const PoseBasePtr& relativeTarget,
109 Ice::Float positionalAccuracy,
110 Ice::Float orientationalAccuracy,
111 const Ice::Current& c = Ice::emptyCurrent) override;
112
113 void setMaxVelocities(Ice::Float positionalVelocity,
114 Ice::Float orientationalVelocity,
115 const Ice::Current& c = Ice::emptyCurrent) override;
116
117 void stopMovement(const Ice::Current& c = Ice::emptyCurrent) override;
118
119 /**
120 * @see PropertyUser::createPropertyDefinitions()
121 */
123
124 void updateCurrentPose(const PoseBasePtr& newPose);
125 //void updateCurrentVelocity(const Vector3BasePtr& translationVel, const Vector3BasePtr& rotationVel);
126
127 // implement SimulatorRobotListener to receive robot updates from simulator
128 void reportState(SimulatedRobotState const& state, const Ice::Current&) override;
129
130 void setCurrentPose(const PoseBasePtr& newPose);
131
132
133 Eigen::Vector3f getRPY(PoseBasePtr pose);
134
136 IceUtil::Time lastExecutionTime;
138
139
142 ::Ice::Float positionalAccuracy;
144
145 std::string simulatorPrxName;
146 std::string robotName;
148
149 SimulatorInterfacePrx simulatorPrx;
150
152 };
153} // 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.