Der Name des default branch ist ab jetzt für neue Repositories main. The name of the default branch for new repositories is from now on main.

Commit 642fb32c authored by Daniel Müller's avatar Daniel Müller
Browse files

Merge branch 'feature/emergency' into 'master'

Feature/emergency

See merge request !10
parents 2d10eb32 2b221486
......@@ -155,6 +155,7 @@ set(RobotFace_SRC
src/RotationLabel.cpp
src/TextProcessor.cpp
src/ImageDisplay.cpp
src/EmergencyButton.cpp
)
# Declare header files (needed to specify all include files for wrapping with QT5)
......@@ -166,6 +167,7 @@ set(RobotFace_INC
#include/homer_robot_face/FestivalGenerator.h
include/homer_robot_face/RotationLabel.h
include/homer_robot_face/ImageDisplay.h
include/homer_robot_face/EmergencyButton.h
)
QT5_WRAP_CPP(RobotFace_MOC_SRC ${RobotFace_INC})
......
/*******************************************************************************
* TalkingHead - A talking head for robots
* Copyright (C) 2014 AG Aktives Sehen <agas@uni-koblenz.de>
* Universitaet Koblenz-Landau
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA or see <http://www.gnu.org/licenses/>.
*******************************************************************************/
#ifndef TALKING_HEAD_INCLUDE_EMERGENCYBUTTON_H_
#define TALKING_HEAD_INCLUDE_EMERGENCYBUTTON_H_
#include <memory>
#include <queue>
#include <string>
#include <QPainter>
#include <QColor>
#include <QTimer>
#include <QWidget>
#include <cv.h>
#include <cv_bridge/cv_bridge.h>
#include <ros/ros.h>
#undef Bool // Qt does stupid things
#include <std_msgs/Bool.h>
class EmergencyButton : public QWidget
{
Q_OBJECT
public:
/** Constructor */
EmergencyButton(const unsigned int max_width, const unsigned int max_height, QWidget* parent);
/** Destructor */
~EmergencyButton();
/** @brief callback for sensorMsgs::Images encapsulated in an ImageDisplay msg*/
void callbackEmergencyButton(const std_msgs::Bool::ConstPtr& emergency_msg);
protected:
void paintEvent(QPaintEvent*);
private:
const unsigned int max_width_; // in px
const unsigned int max_height_; // in px
};
#endif // TALKING_HEAD_INCLUDE_EMERGENCYBUTTON_H_
......@@ -34,6 +34,7 @@
#include <homer_robot_face/ImageDisplay.h>
#include <homer_robot_face/TalkingHead.h>
#include <homer_robot_face/TextOutDisplay.h>
#include <homer_robot_face/EmergencyButton.h>
#include <sstream>
#include <string>
......@@ -73,6 +74,8 @@ public:
std::shared_ptr<ImageDisplay> getImageStream();
// ImageDisplay* getImageDisplayer();
std::shared_ptr<EmergencyButton> getEmergencyButton();
private slots:
......@@ -91,6 +94,8 @@ private:
#endif
std::shared_ptr<ImageDisplay> image_stream_display_;
std::shared_ptr<EmergencyButton> emergency_display_;
QBoxLayout* center_layout;
QBoxLayout* main_layout;
QBoxLayout* h_layout;
......
......@@ -29,6 +29,8 @@
#include <ros/callback_queue.h>
#include <ros/ros.h>
#include <std_msgs/String.h>
#undef Bool // Qt does stupid things
#include <std_msgs/Bool.h>
#include <image_transport/image_transport.h>
......@@ -37,6 +39,7 @@
#include <homer_robot_face/MainWindow.h>
#include <homer_robot_face/TalkingHead.h>
#include <homer_robot_face/EmergencyButton.h>
class MainWindow;
......@@ -85,6 +88,7 @@ private:
std::shared_ptr<ros::NodeHandle> node_handle_;
std::unique_ptr<ros::NodeHandle> text_out_node_handle_;
std::unique_ptr<ros::NodeHandle> tf_node_handle_;
std::unique_ptr<ros::NodeHandle> emergency_node_handle_;
ros::CallbackQueue text_out_callback_queue_;
ros::CallbackQueue tf_callback_queue_;
......@@ -107,6 +111,8 @@ private:
ros::Subscriber image_mat_subscriber;
image_transport::Subscriber face_mat_image_display_show_subscriber_;
ros::Subscriber emergency_pressed_subscriber_;
std::string tf_text_;
......
/*******************************************************************************
* TalkingHead - A talking head for robots
* Copyright (C) 2014 AG Aktives Sehen <agas@uni-koblenz.de>
* Universitaet Koblenz-Landau
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA or see <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include <homer_robot_face/EmergencyButton.h>
EmergencyButton::EmergencyButton(const unsigned int max_width,
const unsigned int max_height, QWidget* parent)
: QWidget(parent)
, max_width_(max_width)
, max_height_(max_height)
{
this->setVisible(false);
}
EmergencyButton::~EmergencyButton()
{
}
void EmergencyButton::paintEvent(QPaintEvent*)
{
QRectF rectangle(0, 0, max_width_, max_height_);
QColor color(255,0,0);
QPainter painter(this);
painter.fillRect(rectangle, color);
}
void EmergencyButton::callbackEmergencyButton(const std_msgs::Bool::ConstPtr& emergency_msg)
{
if (emergency_msg->data)
{
this->setVisible(true);
this->update();
}
else
{
this->setVisible(false);
}
}
......@@ -133,6 +133,9 @@ MainWindow::MainWindow(QWidget* parent)
text_rec_display_->setPalette(custom_palette);
text_rec_display_->setMaximumSize(width, height);
emergency_display_ = std::make_shared<EmergencyButton>(800, 30, this);
emergency_display_->setMinimumSize(800, 30);
// Layout ------------------------------------------------
main_layout->setSpacing(0);
......@@ -143,6 +146,8 @@ MainWindow::MainWindow(QWidget* parent)
center_layout->addWidget(text_out_display_.get());
center_layout->addStretch();
center_layout->addWidget(text_rec_display_.get());
center_layout->addStretch();
center_layout->addWidget(emergency_display_.get());
center_layout->setStretchFactor(text_out_display_.get(), 1);
......@@ -306,3 +311,8 @@ std::shared_ptr<ImageDisplay> MainWindow::getImageStream()
{
return image_stream_display_;
}
std::shared_ptr<EmergencyButton> MainWindow::getEmergencyButton()
{
return emergency_display_;
}
......@@ -35,6 +35,8 @@ QtRosNode::QtRosNode(
tf_node_handle_->setCallbackQueue(&tf_callback_queue_);
tf_text_ = "talking_finished";
emergency_node_handle_ = std::make_unique<ros::NodeHandle>();
subscribeTopics();
quit_from_gui = false;
......@@ -84,6 +86,10 @@ void QtRosNode::subscribeTopics()
image_stream_subscriber_
= node_handle_->subscribe<homer_robot_face::DisplayImage>("/robot_face/ImageDisplay", 5,
&ImageDisplay::callbackImageDisplay, main_window_->getImageStream().get());
emergency_pressed_subscriber_
= emergency_node_handle_->subscribe<std_msgs::Bool>("/emergency_button_pressed", 1,
&EmergencyButton::callbackEmergencyButton, main_window_->getEmergencyButton().get());
}
void QtRosNode::quitNow()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment