frames.cpp
Go to the documentation of this file.
1 #include <ram_qt_guis/frames.hpp>
2 
3 namespace ram_qt_guis
4 {
5 Frames::Frames(QWidget* parent) :
6  rviz::Panel(parent)
7 {
8  setObjectName("Frame");
9  setName(objectName());
10 
11  trajectory_frame_ = new Pose(QString::fromStdString("trajectory_frame"));
12  trajectory_frame_->setText("Enter the robot trajectory frame:");
13  start_pose_ = new Pose(QString::fromStdString("start_pose"));
14  start_pose_->setText("Enter the start pose:");
15  tool_ = new Pose(QString::fromStdString("tool"));
17  tool_->setText("Enter the tool orientation:");
18 
19  QLabel* label(new QLabel("Display must be updated to see tool orientation changes when axis"
20  " are displayed on the trajectory."));
21  label->setWordWrap(true);
22 
23  // Scroll area
24  QVBoxLayout *scroll_widget_layout = new QVBoxLayout();
25  QWidget *scroll_widget = new QWidget;
26  scroll_widget->setLayout(scroll_widget_layout);
27  QScrollArea *scroll_area = new QScrollArea;
28  scroll_area->setWidget(scroll_widget);
29  scroll_area->setWidgetResizable(true);
30  scroll_area->setFrameShape(QFrame::NoFrame);
31 
32  QVBoxLayout* main_layout = new QVBoxLayout(this);
33  main_layout->addWidget(scroll_area);
34  scroll_widget_layout->addLayout(trajectory_frame_->getLayout());
35  scroll_widget_layout->addStretch(1);
36  scroll_widget_layout->addLayout(start_pose_->getLayout());
37  scroll_widget_layout->addStretch(1);
38  scroll_widget_layout->addLayout(tool_->getLayout());
39  scroll_widget_layout->addWidget(label);
40  scroll_widget_layout->addStretch(2);
41 
42  connect(this, SIGNAL(displayErrorMessageBox(const QString, const QString, const QString)), this,
43  SLOT(displayErrorBoxHandler(const QString, const QString, const QString)));
44 
45  trajectory_frame_pub_ = nh_.advertise<geometry_msgs::Pose>("ram/trajectory_frame", 1);
46  start_pose_pub_ = nh_.advertise<geometry_msgs::Pose>("ram/start_pose", 1);
47  tool_pub_ = nh_.advertise<geometry_msgs::Pose>("ram/tool", 1);
48 
49  trajectory_frame_pose_.orientation.x = 0;
50  trajectory_frame_pose_.orientation.y = 0;
51  trajectory_frame_pose_.orientation.z = 0;
52  trajectory_frame_pose_.orientation.w = 1;
53 
54  start_pose_pose_.orientation.x = 0;
55  start_pose_pose_.orientation.y = 0;
56  start_pose_pose_.orientation.z = 0;
57  start_pose_pose_.orientation.w = 1;
58 
59  tool_pose_.orientation.x = 0;
60  tool_pose_.orientation.y = 0;
61  tool_pose_.orientation.z = 0;
62  tool_pose_.orientation.w = 1;
63 }
64 
66 {
67 }
68 
70 {
74 }
75 
77 {
80  {
82  "Published message will be lost: ",
83  QString::fromStdString(trajectory_frame_pub_.getTopic() + " has no subscriber"), "");
84  }
86  ros::spinOnce();
87 }
88 
90 {
93  {
95  "Published message will be lost: ",
96  QString::fromStdString(start_pose_pub_.getTopic() + " has no subscriber"), "");
97  }
99  ros::spinOnce();
100 }
101 
103 {
105  if (tool_pub_.getNumSubscribers() == 0)
106  {
107  Q_EMIT displayErrorMessageBox(
108  "Published message will be lost: ",
109  QString::fromStdString(tool_pub_.getTopic() + " has no subscriber"), "");
110  }
112  ros::spinOnce();
113 }
114 
115 void Frames::load(const rviz::Config& config)
116 {
117  trajectory_frame_->load(config);
118  start_pose_->load(config);
119  tool_->load(config);
120  rviz::Panel::load(config);
121  QtConcurrent::run(this, &Frames::sendLoadedInformation);
122 }
123 
125 {
126  Q_EMIT setEnabled(false);
127 
128  ros::Duration(1).sleep();
129  while (nh_.ok())
130  {
134  break;
135  else
137  "RViz panel " << objectName().toStdString() + " did not connect to all the subscribers");
138  }
139 
140  ROS_INFO_STREAM("RViz panel " << objectName().toStdString() << " subscribers connections have been made");
141 
145 
146  connect(trajectory_frame_, SIGNAL(valueChanged()), this, SLOT(sendTrajectoryFrameInformation()));
147  connect(start_pose_, SIGNAL(valueChanged()), this, SLOT(sendStartPoseInformation()));
148  connect(tool_, SIGNAL(valueChanged()), this, SLOT(sendToolInformation()));
149 
150  // Connect with configChanged signal
151  connect(trajectory_frame_, SIGNAL(valueChanged()), this, SIGNAL(configChanged()));
152  connect(start_pose_, SIGNAL(valueChanged()), this, SIGNAL(configChanged()));
153  connect(tool_, SIGNAL(valueChanged()), this, SIGNAL(configChanged()));
154 
155  Q_EMIT setEnabled(true);
156 }
157 
158 void Frames::save(rviz::Config config) const
159  {
160  trajectory_frame_->save(config);
161  start_pose_->save(config);
162  tool_->save(config);
163  rviz::Panel::save(config);
164 }
165 
166 void Frames::displayErrorBoxHandler(const QString title,
167  const QString message,
168  const QString info_msg)
169 {
170  bool old_state(isEnabled());
171  Q_EMIT setEnabled(false);
172  QMessageBox msg_box;
173  msg_box.setWindowTitle(title);
174  msg_box.setText(message);
175  msg_box.setInformativeText(info_msg);
176  msg_box.setIcon(QMessageBox::Critical);
177  msg_box.setStandardButtons(QMessageBox::Ok);
178  msg_box.exec();
179  Q_EMIT setEnabled(old_state);
180 }
181 
182 }
183 
ros::Publisher tool_pub_
Definition: frames.hpp:62
void save(rviz::Config config) const
Definition: frames.cpp:158
void publish(const boost::shared_ptr< M > &message) const
void sendLoadedInformation()
Definition: frames.cpp:124
void poseEigenToMsg(const Eigen::Affine3d &e, geometry_msgs::Pose &m)
virtual ~Frames()
Definition: frames.cpp:65
bool sleep() const
void load(const rviz::Config &config)
Definition: frames.cpp:115
ros::Publisher trajectory_frame_pub_
Definition: frames.hpp:58
void updateInternalParameters()
Definition: frames.cpp:69
void configChanged()
void getPose(Eigen::Affine3d &pose)
void setTranslationEnabled(const bool)
virtual void setName(const QString &name)
Pose * trajectory_frame_
Definition: frames.hpp:52
geometry_msgs::Pose tool_pose_
Definition: frames.hpp:63
void save(rviz::Config)
Definition: pose_widget.cpp:81
void sendToolInformation()
Definition: frames.cpp:102
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
geometry_msgs::Pose trajectory_frame_pose_
Definition: frames.hpp:59
QVBoxLayout * getLayout()
#define ROS_WARN_STREAM_THROTTLE(rate, args)
geometry_msgs::Pose start_pose_pose_
Definition: frames.hpp:61
ros::Publisher start_pose_pub_
Definition: frames.hpp:60
void displayErrorBoxHandler(const QString title, const QString message, const QString info_msg)
Definition: frames.cpp:166
void sendStartPoseInformation()
Definition: frames.cpp:89
uint32_t getNumSubscribers() const
#define ROS_INFO_STREAM(args)
Pose * start_pose_
Definition: frames.hpp:53
ros::NodeHandle nh_
Definition: frames.hpp:56
void load(const rviz::Config &)
Definition: pose_widget.cpp:92
virtual void save(Config config) const
void setText(const QString name)
std::string getTopic() const
bool ok() const
virtual void load(const Config &config)
void sendTrajectoryFrameInformation()
Definition: frames.cpp:76
ROSCPP_DECL void spinOnce()
Frames(QWidget *parent=NULL)
Definition: frames.cpp:5
#define PLUGINLIB_EXPORT_CLASS(class_type, base_class_type)
void displayErrorMessageBox(const QString, const QString, const QString)


ram_qt_guis
Author(s): Victor Lamoine - Institut Maupertuis
autogenerated on Mon Jun 10 2019 14:50:11