TrajectoryExporter.cpp
Go to the documentation of this file.
1/*
2 * This file is part of ArmarX.
3 *
4 * ArmarX is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * ArmarX is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * @package ArmarXGuiPlugins::RobotTrajectoryDesigner::ImportExport
17 * @author Liran Dattner
18 * @date 2018
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22#include "TrajectoryExporter.h"
23
24#include <fstream>
25#include <iostream>
26
27#include <Ice/CommunicatorF.h>
28
29#include <ArmarXCore/interface/observers/Serialization.h>
30#include <ArmarXCore/interface/serialization/JSONSerialization.h>
32
34
35//@Liran ich (Tim) habe es von DesignerTrajectory zu DesignerTrajectoryPtr geƤndert. Ich bekomme es so von dem Model
36//fps habe ich wie besprochen entfernt
37void
38armarx::TrajectoryExporter::exportTrajectory(std::vector<DesignerTrajectoryPtr> trajectories,
39 const std::string file)
40{
41 const Ice::Current& c = Ice::emptyCurrent;
42 auto communicator = c.adapter.get()->getCommunicator();
44 JSONObject jsonSerializer = JSONObject(ic);
45 //Serialize the trajectory using jsonSerializer
46 //trajectory->getFinalTrajectory()->serialize(&jsonSerializer);
47 //Output the serialized Trajectory as a string
48 const std::string jsonString = jsonSerializer.toString();
49
50 //Stream the string to a file
51 std::ofstream output;
52 output.open(file);
53 output << jsonString;
54 output.close();
55}
constexpr T c
The JSONObject class is used to represent and (de)serialize JSON objects.
Definition JSONObject.h:44
std::string toString(const ::Ice::Current &=Ice::emptyCurrent) const override
void exportTrajectory(std::vector< DesignerTrajectoryPtr > trajectories, const std::string file)
Exports a trajectory to the target file as a serialized instance of the Trajectory class.
::IceInternal::Handle<::Ice::Communicator > CommunicatorPtr
Definition IceManager.h:49