MotionFileWrapper.h
Go to the documentation of this file.
1/*
2 * This file is part of ArmarX.
3 *
4 * Copyright (C) 2020, 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::Libraries::MMM
19 * @author Andre Meixner
20 * @date 2020
21 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22 * GNU General Public License
23 */
24
26
27#ifndef _ARMARX_COMPONENT_RobotComponents_MotionFileWrapper_H
28#define _ARMARX_COMPONENT_RobotComponents_MotionFileWrapper_H
29
30namespace armarx
31{
33 {
34 public:
36 {
37 }
38
39 void
40 setScaling(float value)
41 {
42 double factor = value / scaling;
43 for (auto& data : poseTrajData)
44 {
45 data.second[0] *= factor;
46 data.second[1] *= factor;
47 data.second[2] *= factor;
48 }
49 scaling = value;
50 }
51
52 ::Ice::StringSeq jointNames;
53 DoubleSeqSeqSeq jointTrajData;
54 ::Ice::DoubleSeq timestamp;
55 std::map<double, Ice::DoubleSeq> poseTrajData;
56
57 TrajectoryBasePtr
59 {
60 return TrajectoryBasePtr(new Trajectory(poseTrajData));
61 }
62
63 TrajectoryBasePtr
65 {
66 return TrajectoryBasePtr(new Trajectory(jointTrajData, timestamp, jointNames));
67 }
68
69 std::string modelPath;
70 unsigned int numberOfFrames;
71 float scaling;
72 };
73
74 typedef std::shared_ptr<MotionData> MotionDataPtr;
75
77
78 typedef std::shared_ptr<MotionFileWrapper> MotionFileWrapperPtr;
79
80 class MotionFileWrapper
81 {
82 public:
83 static MotionFileWrapperPtr create(const std::string& motionFilePath,
84 double butterworthFilterCutOffFreq = 0.0,
85 const std::string relativeModelRoot = "mmm");
86
88 MotionDataPtr getMotionDataByModel(const std::string& modelName);
89 MotionDataPtr getMotionData(const std::string& motionName);
90
91 ::Ice::StringSeq getModelNames();
92 ::Ice::StringSeq getMotionNames();
93
94 private:
95 MotionFileWrapper(int butterworthFilterCutOffFreq = 0);
96
97 bool loadMotion(const std::string& motionFilePath,
98 const std::string relativeModelRoot = "mmm");
99 bool loadLegacyMotion(const std::string& motionFilePath,
100 const std::string relativeModelRoot = "mmm");
101
102 ::Ice::DoubleSeq getTrajData(const Eigen::Matrix4f& rootPose);
103 DoubleSeqSeq getTrajData(const Eigen::VectorXf& jointAngles);
104
105 std::map<std::string, MotionDataPtr> motionData;
106 std::vector<std::string> motionNames;
107 double butterworthFilterCutOffFreq;
108 };
109} // namespace armarx
110
111#endif // _ARMARX_COMPONENT_RobotComponents_MotionFileWrapper_H
TrajectoryBasePtr getJointTrajectory()
::Ice::StringSeq jointNames
TrajectoryBasePtr getPoseTrajectory()
std::map< double, Ice::DoubleSeq > poseTrajData
unsigned int numberOfFrames
DoubleSeqSeqSeq jointTrajData
::Ice::DoubleSeq timestamp
void setScaling(float value)
static MotionFileWrapperPtr create(const std::string &motionFilePath, double butterworthFilterCutOffFreq=0.0, const std::string relativeModelRoot="mmm")
MotionDataPtr getMotionData(const std::string &motionName)
MotionDataPtr getMotionDataByModel(const std::string &modelName)
::Ice::StringSeq getMotionNames()
The Trajectory class represents n-dimensional sampled trajectories.
Definition Trajectory.h:77
This file offers overloads of toIce() and fromIce() functions for STL container types.
std::shared_ptr< MotionData > MotionDataPtr
std::shared_ptr< MotionFileWrapper > MotionFileWrapperPtr