EnvironmentController.cpp
Go to the documentation of this file.
2 #include <string>
3 #include <QFileDialog>
4 #include <VirtualRobot/XML/RobotIO.h>
9 #include "../KinematicSolver.h"
10 #include <QMessageBox>
11 
12 namespace armarx
13 {
15  {
16  environment = std::make_shared<Environment>();
17  ARMARX_INFO << "RobotTrajectoryDesigner: EnvironmentController on init";
18  }
19 
21  {
22  ARMARX_INFO << "RobotTrajectoryDesigner: EnvironmentController on connect";
23  }
24 
26  {
27  ARMARX_INFO << "RobotTrajectoryDesigner: EnvironmentController on disconnect";
28  }
29 
31  {
32  ARMARX_INFO << "RobotTrajectoryDesigner: EnvironmentController on exit";
33  }
34 
36  {
37  std::string robotFile = "/RobotAPI/robots/Armar3/ArmarIII.xml";
38  CMakePackageFinder finder("RobotAPI");
39 
40  if (finder.packageFound())
41  {
42  environment->setRobot(VirtualRobot::RobotIO::loadRobot(finder.getDataDir() + robotFile));
43  }
44  else
45  {
46  ARMARX_WARNING << "ArmarX Package RobotAPI has not been found!";
47  }
48  emit environmentChanged(environment);
49  }
50 
51  void EnvironmentController::loadRobotFromProxy(std::string robotFileName)
52  {
53  environment->setRobot(VirtualRobot::RobotIO::loadRobot(robotFileName));
54  emit environmentChanged(environment);
55  }
56 
58  {
61  }
62 
64  {
65  QMessageBox::StandardButton reply;
66  reply = QMessageBox::question(0, "Select robot", "If you change the robot all trajectories are lost.\nDo you want to change?", QMessageBox::Yes | QMessageBox::No);
67  if (reply == QMessageBox::No)
68  {
69  return;
70  }
71  QFileDialog dialog(0);
72  dialog.setFileMode(QFileDialog::ExistingFiles);
73  dialog.setAcceptMode(QFileDialog::AcceptOpen);
74  dialog.setNameFilter(tr("XML (*.xml)"));
75  QStringList fileNames;
76 
77  if (dialog.exec())
78  {
79  fileNames = dialog.selectedFiles();
80  }
81  if (fileNames.length() > 1)
82  {
83  QMessageBox* toManyFilesSelected = new QMessageBox;
84  toManyFilesSelected->setWindowTitle(QString::fromStdString("Information"));
85  toManyFilesSelected->setText(QString::fromStdString("To many files selected.\nAs default the first file was taken."));
86  toManyFilesSelected->exec();
87  }
88  if (!fileNames.empty())
89  {
90  try
91  {
92  VirtualRobot::RobotPtr robot = VirtualRobot::RobotIO::loadRobot(fileNames[0].toStdString());
93  environment->setRobot(robot);
94  emit environmentChanged(environment);
96  KinematicSolver::getInstance(NULL, robot);
97  }
98  catch (std::exception& e)
99  {
100  QMessageBox* selectRobotFailed = new QMessageBox;
101  selectRobotFailed->setWindowTitle(QString::fromStdString("Error Message"));
102  selectRobotFailed->setText(QString::fromStdString("The selected file is not a robot xml file."));
103  selectRobotFailed->exec();
104  }
105  }
106  }
107 }
armarx::CMakePackageFinder::packageFound
bool packageFound() const
Returns whether or not this package was found with cmake.
Definition: CMakePackageFinder.cpp:485
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:103
armarx::CMakePackageFinder
The CMakePackageFinder class provides an interface to the CMake Package finder capabilities.
Definition: CMakePackageFinder.h:53
armarx::EnvironmentController::onExitComponent
void onExitComponent() override
Definition: EnvironmentController.cpp:30
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:176
armarx::EnvironmentController::onInitComponent
void onInitComponent() override
Definition: EnvironmentController.cpp:14
ArmarXObjectScheduler.h
armarx::EnvironmentController::openRobotFileDialog
void openRobotFileDialog()
open a file dialog to select a robot
Definition: EnvironmentController.cpp:63
armarx::KinematicSolver::getInstance
static std::shared_ptr< KinematicSolver > getInstance(VirtualRobot::ScenePtr scenario, VirtualRobot::RobotPtr robot)
SINGLETON-FEATURES///////////////////////////////////////////////////////////////////////////////////...
Definition: KinematicSolver.cpp:92
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:174
armarx::EnvironmentController::loadArmar3
void loadArmar3()
loads first armar3 in the application
Definition: EnvironmentController.cpp:35
armarx::EnvironmentController::loadRobotFromProxy
void loadRobotFromProxy(std::string robotFileName)
loads the robot from proxy
Definition: EnvironmentController.cpp:51
armarx::EnvironmentController::EnvironmentController
EnvironmentController()
Definition: EnvironmentController.cpp:57
ARMARX_WARNING
#define ARMARX_WARNING
Definition: Logging.h:186
armarx::EnvironmentController::onDisconnectComponent
void onDisconnectComponent() override
Definition: EnvironmentController.cpp:25
ArmarXDataPath.h
armarx::EnvironmentController::onConnectComponent
void onConnectComponent() override
Definition: EnvironmentController.cpp:20
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
Application.h
VirtualRobot::RobotPtr
std::shared_ptr< class Robot > RobotPtr
Definition: Bus.h:18
GfxTL::Yes
OnOff< true > Yes
Definition: OnOff.h:12