TCPInformationController.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 RobotTrajectoryDesigner::gui-plugins::Controller::TCPInformationController
17 * \author Max Beddies
18 * \date 2018
19 * \copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
23 #include <iomanip> // setprecision
24 #include <sstream> // stringstream
25 namespace armarx
26 {
27 
29  {
30  ARMARX_INFO << "RobotTrajectoryDesigner: TCPInformationController on init";
32  }
33 
35  {
36  ARMARX_INFO << "RobotTrajectoryDesigner: TCPInformationController on connect";
37  }
38 
40  {
41  ARMARX_INFO << "RobotTrajectoryDesigner: TCPInformationController on disconnect";
42  }
43 
45  {
46  ARMARX_INFO << "RobotTrajectoryDesigner: TCPInformationController on exit";
47  }
48 
50  guiTCPInformation(guiTCPInformation)
51  {
54  }
55 
57  {
58  return this->guiTCPInformation;
59  }
60 
62  {
63  if (guiTCPInformation != NULL)
64  {
65  this->guiTCPInformation = guiTCPInformation;
66  }
67  }
68 
69 
71  {
72  setLineEditText(guiTCPInformation->getTCPInformationTab()->currentPoseLayout,
73  pose);
74  }
75 
77  {
78  setLineEditText(guiTCPInformation->getTCPInformationTab()->desiredPoseLayout,
79  pose);
80 
81  }
82 
84  {
85  std::string reachableString = "";
86  if (reachable)
87  {
88  reachableString = "Pose reachable!";
89  }
90  else
91  {
92  reachableString = "Pose NOT reachable!";
93  }
94  guiTCPInformation->getTCPInformationTab()->reachableLabel->setText(QString::fromStdString(reachableString));
95  }
96 
98  {
99  Eigen::Matrix4f zero;
100  setLineEditText(guiTCPInformation->getTCPInformationTab()->currentPoseLayout,
101  zero);
102  setLineEditText(guiTCPInformation->getTCPInformationTab()->desiredPoseLayout,
103  zero);
104  }
105 
107  {
108  throw ("not yet implemented");
109  }
110 
111  void TCPInformationController::setLineEditText(QGridLayout* gridLayout, Eigen::Matrix4f pose)
112  {
113  int columns = gridLayout->columnCount();
114  int rows = gridLayout->rowCount();
115 
116  /*
117  * check if pose is empty,
118  * check if pose has correct size
119  */
120  for (int i = 0; i < columns; i++)
121  {
122  for (int j = 0; j < rows; j++)
123  {
124  // get layout item at position
125  QLayoutItem* item = gridLayout->itemAtPosition(j, i);
126  if (item != NULL)
127  {
128  // cast item dynamically to line edit
129  QWidget* widget = item->widget();
130  QLabel* lineEdit = dynamic_cast<QLabel*>(widget);
131 
132  // Parse (i, j) to list index and set text
133  if (lineEdit)
134  {
135  std::stringstream stream;
136  stream << std::fixed << std::setprecision(2) << pose(j, i);
137  std::string s = stream.str();
138  lineEdit->setText(QString::fromStdString(s));
139  }
140  }
141  }
142  }
143  }
144 
145 }
armarx::TCPInformationController::setReachable
void setReachable(bool reachable)
setReachable set the label isReachable to "reachable" if true and "not reachable" if false
Definition: TCPInformationController.cpp:83
armarx::TCPInformationController::onInitComponent
void onInitComponent() override
Definition: TCPInformationController.cpp:28
TCPInformationController.h
armarx::TCPInformationController::setCurrentPose
void setCurrentPose(Eigen::Matrix4f pose)
Sets all values of the current pose.
Definition: TCPInformationController.cpp:70
armarx::TCPInformationController::setGuiTCPInformation
void setGuiTCPInformation(TCPInformationPtr guiTCPInformation)
Setter for the TCPInformationTab pointer to guiTCPInformation.
Definition: TCPInformationController.cpp:61
armarx::TCPInformationController::onExitComponent
void onExitComponent() override
Definition: TCPInformationController.cpp:44
TCPInformationPtr
std::shared_ptr< TCPInformationTab > TCPInformationPtr
Definition: TCPInformationTab.h:50
armarx::TCPInformationController::getGuiTCPInformation
TCPInformationPtr getGuiTCPInformation()
Getter for the TCPInformationTab pointer to guiTCPInformation.
Definition: TCPInformationController.cpp:56
armarx::TCPInformationController::retranslateGui
void retranslateGui()
Retranslates the guiTCPInformation.
Definition: TCPInformationController.cpp:106
armarx::TCPInformationController::TCPInformationController
TCPInformationController(TCPInformationPtr guiTCPInformation)
Creates a new TCPInformationController and assigns a TCPInformationTab to handle.
Definition: TCPInformationController.cpp:49
armarx::TCPInformationController::onConnectComponent
void onConnectComponent() override
Definition: TCPInformationController.cpp:34
armarx::TCPInformationController::setDesiredPose
void setDesiredPose(Eigen::Matrix4f pose)
Sets all values of the desired pose.
Definition: TCPInformationController.cpp:76
GfxTL::Matrix4f
MatrixXX< 4, 4, float > Matrix4f
Definition: MatrixXX.h:601
armarx::TCPInformationController::clearPoseLabels
void clearPoseLabels()
Resets the labels of current and desired pose to zeroes.
Definition: TCPInformationController.cpp:97
ARMARX_INFO
#define ARMARX_INFO
Definition: Logging.h:174
armarx::TCPInformationController::onDisconnectComponent
void onDisconnectComponent() override
Definition: TCPInformationController.cpp:39
armarx::ctrlutil::s
double s(double t, double s0, double v0, double a0, double j)
Definition: CtrlUtil.h:33
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28