EnvironmentController.cpp
Go to the documentation of this file.
2 
3 #include <string>
4 
5 #include <QFileDialog>
6 #include <QMessageBox>
7 
8 #include <VirtualRobot/XML/RobotIO.h>
9 
14 
15 #include "../KinematicSolver.h"
16 
17 namespace armarx
18 {
19  void
21  {
22  environment = std::make_shared<Environment>();
23  ARMARX_INFO << "RobotTrajectoryDesigner: EnvironmentController on init";
24  }
25 
26  void
28  {
29  ARMARX_INFO << "RobotTrajectoryDesigner: EnvironmentController on connect";
30  }
31 
32  void
34  {
35  ARMARX_INFO << "RobotTrajectoryDesigner: EnvironmentController on disconnect";
36  }
37 
38  void
40  {
41  ARMARX_INFO << "RobotTrajectoryDesigner: EnvironmentController on exit";
42  }
43 
44  void
46  {
47  std::string robotFile = "/RobotAPI/robots/Armar3/ArmarIII.xml";
48  CMakePackageFinder finder("RobotAPI");
49 
50  if (finder.packageFound())
51  {
52  environment->setRobot(
53  VirtualRobot::RobotIO::loadRobot(finder.getDataDir() + robotFile));
54  }
55  else
56  {
57  ARMARX_WARNING << "ArmarX Package RobotAPI has not been found!";
58  }
59  emit environmentChanged(environment);
60  }
61 
62  void
63  EnvironmentController::loadRobotFromProxy(std::string robotFileName)
64  {
65  environment->setRobot(VirtualRobot::RobotIO::loadRobot(robotFileName));
66  emit environmentChanged(environment);
67  }
68 
70  {
73  }
74 
75  void
77  {
78  QMessageBox::StandardButton reply;
79  reply = QMessageBox::question(
80  0,
81  "Select robot",
82  "If you change the robot all trajectories are lost.\nDo you want to change?",
84  if (reply == QMessageBox::No)
85  {
86  return;
87  }
88  QFileDialog dialog(0);
89  dialog.setFileMode(QFileDialog::ExistingFiles);
90  dialog.setAcceptMode(QFileDialog::AcceptOpen);
91  dialog.setNameFilter(tr("XML (*.xml)"));
92  QStringList fileNames;
93 
94  if (dialog.exec())
95  {
96  fileNames = dialog.selectedFiles();
97  }
98  if (fileNames.length() > 1)
99  {
100  QMessageBox* toManyFilesSelected = new QMessageBox;
101  toManyFilesSelected->setWindowTitle(QString::fromStdString("Information"));
102  toManyFilesSelected->setText(QString::fromStdString(
103  "To many files selected.\nAs default the first file was taken."));
104  toManyFilesSelected->exec();
105  }
106  if (!fileNames.empty())
107  {
108  try
109  {
110  VirtualRobot::RobotPtr robot =
111  VirtualRobot::RobotIO::loadRobot(fileNames[0].toStdString());
112  environment->setRobot(robot);
113  emit environmentChanged(environment);
115  KinematicSolver::getInstance(NULL, robot);
116  }
117  catch (std::exception& e)
118  {
119  QMessageBox* selectRobotFailed = new QMessageBox;
120  selectRobotFailed->setWindowTitle(QString::fromStdString("Error Message"));
121  selectRobotFailed->setText(
122  QString::fromStdString("The selected file is not a robot xml file."));
123  selectRobotFailed->exec();
124  }
125  }
126  }
127 } // namespace armarx
armarx::CMakePackageFinder::packageFound
bool packageFound() const
Returns whether or not this package was found with cmake.
Definition: CMakePackageFinder.cpp:511
armarx::KinematicSolver::reset
static void reset()
reset Destroys the current instance of KinematicSolver that a new one can be created via call of getI...
Definition: KinematicSolver.cpp:117
armarx::CMakePackageFinder
The CMakePackageFinder class provides an interface to the CMake Package finder capabilities.
Definition: CMakePackageFinder.h:52
armarx::EnvironmentController::onExitComponent
void onExitComponent() override
Definition: EnvironmentController.cpp:39
EnvironmentController.h
armarx::EnvironmentController::environmentChanged
void environmentChanged(EnvironmentPtr environment)
notifies all controller that the environment has changed
armarx::CMakePackageFinder::getDataDir
std::string getDataDir() const
Definition: CMakePackageFinder.h:194
armarx::EnvironmentController::onInitComponent
void onInitComponent() override
Definition: EnvironmentController.cpp:20
ArmarXObjectScheduler.h
armarx::EnvironmentController::openRobotFileDialog
void openRobotFileDialog()
open a file dialog to select a robot
Definition: EnvironmentController.cpp:76
armarx::KinematicSolver::getInstance
static std::shared_ptr< KinematicSolver > getInstance(VirtualRobot::ScenePtr scenario, VirtualRobot::RobotPtr robot)
SINGLETON-FEATURES///////////////////////////////////////////////////////////////////////////////////...
Definition: KinematicSolver.cpp:105
CMakePackageFinder.h
No
Introduction Thank you for taking interest in our work and downloading this software This library implements the algorithm described in the paper R R R Klein Efficient RANSAC for Point Cloud Shape in Computer Graphics No
Definition: ReadMe.txt:21
ARMARX_INFO
#define ARMARX_INFO
Definition: Logging.h:181
armarx::EnvironmentController::loadArmar3
void loadArmar3()
loads first armar3 in the application
Definition: EnvironmentController.cpp:45
armarx::EnvironmentController::loadRobotFromProxy
void loadRobotFromProxy(std::string robotFileName)
loads the robot from proxy
Definition: EnvironmentController.cpp:63
GfxTL::Yes
OnOff< true > Yes
Definition: OnOff.h:14
armarx::EnvironmentController::EnvironmentController
EnvironmentController()
Definition: EnvironmentController.cpp:69
ARMARX_WARNING
#define ARMARX_WARNING
Definition: Logging.h:193
armarx::EnvironmentController::onDisconnectComponent
void onDisconnectComponent() override
Definition: EnvironmentController.cpp:33
ArmarXDataPath.h
armarx::EnvironmentController::onConnectComponent
void onConnectComponent() override
Definition: EnvironmentController.cpp:27
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
Application.h
VirtualRobot::RobotPtr
std::shared_ptr< class Robot > RobotPtr
Definition: Bus.h:19