flipper_control.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011, Dirk Thomas, TU Darmstadt
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * * Redistributions in binary form must reproduce the above
12  * copyright notice, this list of conditions and the following
13  * disclaimer in the documentation and/or other materials provided
14  * with the distribution.
15  * * Neither the name of the TU Darmstadt nor the names of its
16  * contributors may be used to endorse or promote products derived
17  * from this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
22  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23  * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
24  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
25  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
29  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  * POSSIBILITY OF SUCH DAMAGE.
31  */
32 
34 
36 #include <sensor_msgs/JointState.h>
37 
38 #include <QMessageBox>
39 
40 namespace rqt_flipper_control {
41 
43  : rqt_gui_cpp::Plugin()
44  , widget_(0)
45 {
46  setObjectName("FlipperControl");
47 }
48 
50 {
51  // access standalone command line arguments
52  QStringList argv = context.argv();
53  // create QWidget
54  widget_ = new QWidget();
55  // extend the widget with all attributes and children from UI file
56  ui_.setupUi(widget_);
57  // add widget to the user interface
58  context.addWidget(widget_);
59 
61 
62  // flipperFrontSubs = n.subscribe("/flipper/state/front", 1000, &FlipperControl::frontFlipperCallback, this);
63  // flipperRearSubs = n.subscribe("/flipper/state/rear", 1000, &FlipperControl::rearFlipperCallback, this);
64 
65  connect(ui_.sliderFront,SIGNAL(valueChanged(int)),this,SLOT(sliderFrontChanged(int)));
66  connect(ui_.sliderRear,SIGNAL(valueChanged(int)),this,SLOT(sliderRearChanged(int)));
67 
68  this->jointStatePub = n.advertise<sensor_msgs::JointState>("/jointstate_cmd", 100);
69 
70 }
71 
73 {
74  // TODO unregister all publishers here
75 }
76 
77 void FlipperControl::saveSettings(qt_gui_cpp::Settings& plugin_settings, qt_gui_cpp::Settings& instance_settings) const
78 {
79  // TODO save intrinsic configuration, usually using:
80  // instance_settings.setValue(k, v)
81 }
82 
83 void FlipperControl::restoreSettings(const qt_gui_cpp::Settings& plugin_settings, const qt_gui_cpp::Settings& instance_settings)
84 {
85 
86 }
87 
88 void FlipperControl::frontFlipperCallback(const std_msgs::Float64::ConstPtr& msg){
89  this->setFlipperFrontPose(msg->data);
90 }
91 
92 void FlipperControl::rearFlipperCallback(const std_msgs::Float64::ConstPtr& msg){
93  this->setFlipperRearPose(msg->data);
94 }
95 
97  ui_.lcdNumFrontGoal->display(goal);
98 }
99 
101  ui_.lcdNumRearGoal->display(goal);
102 }
103 
104 
106  ui_.lcdNumFrontPose->display(pose);
107 }
108 
110  ui_.lcdNumRearPose->display(pose);
111 }
112 
113 
115  float fvalue = value /1000.0;
116  sensor_msgs::JointState msg;
117  msg.name.push_back("flipper_front");
118  msg.position.push_back(fvalue);
119  this->jointStatePub.publish(msg);
120 }
121 
123 
124 }
125 
127 
128 }
129 
130 }
131 
Ui::FlipperControlWidget ui_
void publish(const boost::shared_ptr< M > &message) const
void frontFlipperCallback(const std_msgs::Float64::ConstPtr &msg)
virtual void initPlugin(qt_gui_cpp::PluginContext &context)
void addWidget(QWidget *widget)
virtual void sliderFrontChanged(int value)
void rearFlipperCallback(const std_msgs::Float64::ConstPtr &msg)
const QStringList & argv() const
virtual void sliderRearChanged(int value)
virtual void saveSettings(qt_gui_cpp::Settings &plugin_settings, qt_gui_cpp::Settings &instance_settings) const
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
virtual void restoreSettings(const qt_gui_cpp::Settings &plugin_settings, const qt_gui_cpp::Settings &instance_settings)
void setFlipperFrontGoal(const int goal)
#define PLUGINLIB_EXPORT_CLASS(class_type, base_class_type)


hector_rqt_plugins
Author(s): Dirk Thomas, Thorsten Graber, Gregor Gebhardt
autogenerated on Mon Jun 10 2019 13:36:34