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