MMMPlayer.h
Go to the documentation of this file.
1/*
2 * This file is part of ArmarX.
3 *
4 * Copyright (C) 2015-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 RobotComponents::ArmarXObjects::MMMPlayer
19 * @author Mirko Waechter ( mirko dot waechter at kit dot edu )
20 * @date 2014
21 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22 * GNU General Public License
23 */
24
25#pragma once
26
27#include <mutex>
28
30
33
34#include <RobotComponents/interface/components/MMMPlayerInterface.h>
35
36namespace armarx
37{
39 class MotionData;
40
41 /**
42 * \class MMMPlayerPropertyDefinitions
43 * \brief
44 */
46 {
47 public:
49 {
51 "ArmarXProjects",
52 "",
53 "Comma-separated list with names of ArmarXProjects (e.g. 'Armar3,Armar4'). The MMM "
54 "XML File can be specified relatively to a data path of one of these projects.");
55 //defineOptionalProperty<std::string>("MMMFile", "", "Path to MMM XML File");
57 "ApplyButterworthFilter",
58 false,
59 "If true a butterworth filter is applied on the trajectory.");
60 defineOptionalProperty<float>("ButterworthFilterCutOffFreq",
61 20,
62 "Cut off frequency for the butterworth lowpass filter.");
63 }
64 };
65
66 /**
67 * \defgroup Component-MMMPlayer MMMPlayer
68 * \ingroup RobotComponents-Components
69 * \brief Replays an MMM trajectory from a file.
70 *
71 * MMMPlayer reads an MMM trajectory from an MMM XML file (component property) and replays the motion using the KinematicUnit and its currently loaded robot.
72 * The trajectory can be replayed using position control or velocity control.
73 * In the latter case, the control parameters (P, I, D) can be configured via component properties.
74 */
75
76 /**
77 * @ingroup Component-MMMPlayer
78 * @brief The MMMPlayer class
79 */
80 class MMMPlayer : virtual public armarx::Component, public armarx::MMMPlayerInterface
81 {
82 public:
83 /**
84 * @see armarx::ManagedIceObject::getDefaultName()
85 */
86 std::string
87 getDefaultName() const override
88 {
89 return "MMMPlayer";
90 }
91
92 protected:
93 /**
94 * @see armarx::ManagedIceObject::onInitComponent()
95 */
96 void onInitComponent() override;
97
98 /**
99 * @see armarx::ManagedIceObject::onConnectComponent()
100 */
101 void onConnectComponent() override;
102
103 /**
104 * @see armarx::ManagedIceObject::onDisconnectComponent()
105 */
106 void onDisconnectComponent() override;
107
108 /**
109 * @see armarx::ManagedIceObject::onExitComponent()
110 */
111 void onExitComponent() override;
112
113 /**
114 * @see PropertyUser::createPropertyDefinitions()
115 */
117
118 private:
119 void load(const std::string& filename, const std::string& projects);
120
121 std::shared_ptr<MotionFileWrapper> motionWrapper;
122 std::shared_ptr<MotionData> motionData;
123 std::string motionPath;
124
125 std::recursive_mutex mmmMutex;
126
127 public:
128 // MMMPlayerInterface
129 bool loadMMMFile(const std::string& filename,
130 const std::string& projects,
131 const Ice::Current&) override;
132 bool setMotionData(const std::string& motionName, const Ice::Current&) override;
133 int getNumberOfFrames(const Ice::Current&) override;
134 std::string getMotionPath(const Ice::Current&) override;
135 std::string getModelPath(const Ice::Current&) override;
136 Ice::StringSeq getJointNames(const Ice::Current&) override;
137 Ice::StringSeq getMotionNames(const Ice::Current&) override;
138 bool isMotionLoaded(const Ice::Current&) override;
139
140 TrajectoryBasePtr getJointTraj(const Ice::Current&) override;
141 TrajectoryBasePtr getBasePoseTraj(const Ice::Current&) override;
142 };
143
145
146} // namespace armarx
ComponentPropertyDefinitions(std::string prefix, bool hasObjectNameParameter=true)
Definition Component.cpp:46
Baseclass for all ArmarX ManagedIceObjects requiring properties.
Definition Component.h:94
MMMPlayerPropertyDefinitions(std::string prefix)
Definition MMMPlayer.h:48
The MMMPlayer class.
Definition MMMPlayer.h:81
void onInitComponent() override
Definition MMMPlayer.cpp:51
std::string getMotionPath(const Ice::Current &) override
void onDisconnectComponent() override
bool isMotionLoaded(const Ice::Current &) override
Ice::StringSeq getMotionNames(const Ice::Current &) override
bool loadMMMFile(const std::string &filename, const std::string &projects, const Ice::Current &) override
std::string getModelPath(const Ice::Current &) override
int getNumberOfFrames(const Ice::Current &) override
void onConnectComponent() override
Definition MMMPlayer.cpp:57
PropertyDefinitionsPtr createPropertyDefinitions() override
Ice::StringSeq getJointNames(const Ice::Current &) override
TrajectoryBasePtr getJointTraj(const Ice::Current &) override
bool setMotionData(const std::string &motionName, const Ice::Current &) override
void onExitComponent() override
std::string getDefaultName() const override
Definition MMMPlayer.h:87
TrajectoryBasePtr getBasePoseTraj(const Ice::Current &) override
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 file offers overloads of toIce() and fromIce() functions for STL container types.
::IceInternal::Handle<::armarx::MMMPlayer > MMMPlayerPtr
Definition MMMPlayer.h:144
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.