39 #include <Eigen/Geometry> 43 QWidget(parent), mouse_x_(-1), mouse_y_(-1), pub_cmd_vel_(pub_cmd_vel)
45 setBackgroundRole(QPalette::Base);
46 setAutoFillBackground(
true);
51 return QSize(300, 300);
56 return QSize(300, 300);
78 QSize widget_size =
size();
80 int width = widget_size.width() - line_width * 2;
81 int height = widget_size.height() - line_width * 2;
83 int radius = std::min(width, height) / 2;
86 QPainter painter(
this);
87 painter.setRenderHint(QPainter::Antialiasing);
89 pen.setColor(QColor(130, 177, 255));
92 painter.drawArc(center_x - radius, center_y - radius,
93 radius * 2, radius * 2, 0, (360 + 1) * 16);
96 inner_pen.setColor(QColor(33, 150, 243));
98 inner_pen.setWidth(inner_size);
99 painter.setPen(inner_pen);
107 painter.drawArc(
mouse_x_ - inner_size / 2,
109 inner_size, inner_size, 0, (360 + 1) * 16);
113 int mouse_x,
int mouse_y,
int cx,
int cy)
115 double diff_x = mouse_x - cx;
116 double diff_y = mouse_y - cy;
117 Eigen::Vector3d ex(0, -1, 0);
118 Eigen::Vector3d vel(diff_x / cx, diff_y / cy, 0);
121 if (ex.cross(vel).dot(Eigen::Vector3d(0, 0, -1)) < 0) {
124 double dot = ex.dot(vel) / ex.norm() / vel.norm();
132 if (!std::isnan(theta)) {
133 Eigen::Vector3d vel_refined(-vel[1], -vel[0], 0);
135 publishCmdVel(vel_refined[0] * 0.2 , vel_refined[1] * 0.2, theta * 0.2);
143 geometry_msgs::Twist twist;
146 twist.angular.z =
theta;
152 return "QPushButton {background-color: #FF5252; color: white; font-size: 30pt;}";
157 return "QPushButton {background-color: white; color: #424242; font-size: 30pt;}";
162 return "QRadioButton {font-size: 20pt; color: #424242;}";
167 return "QListWidget {font-size: 20pt; color: #424242;}";
174 "/Tablet/StartDemo", 1);
176 "/Tablet/MoveToSpot", 1);
180 "/navigation/unsafe_vel", 1);
182 layout_->addStretch();
189 layout_->addSpacing(10);
195 layout_->addSpacing(10);
201 setBackgroundRole(QPalette::Base);
202 setAutoFillBackground(
true);
224 const visualization_msgs::MarkerArray::ConstPtr&
marker)
228 for (
size_t i = 0; i < marker->markers.size(); i++) {
229 std::string
text = marker->markers[i].text;
245 std::vector<std::string> tasks;
246 tasks.push_back(
"/Tablet/other/GetGeorgia");
247 tasks.push_back(
"/Tablet/chen/GoToElevator");
248 tasks.push_back(
"/Tablet/chen/Greeting1");
249 tasks.push_back(
"/Tablet/chen/Greeting2");
250 tasks.push_back(
"/Tablet/chen/Greeting3");
251 tasks.push_back(
"/Tablet/chen/Greeting4");
252 tasks.push_back(
"/Tablet/chen/Greeting5");
253 tasks.push_back(
"/Tablet/chen/HandOver");
254 for (
size_t i = 0; i < tasks.size(); i++) {
255 QRadioButton* task =
new QRadioButton(QString::fromStdString(tasks[i]),
this);
256 task->setMinimumHeight(50);
258 task->setChecked(
true);
295 if (radio->isChecked()) {
296 std::string task = radio->text().toStdString();
299 jsk_rviz_plugins::StringStamped
command;
319 for (
size_t i = 0; i <
spots_.size(); i++) {
320 QListWidgetItem* item =
new QListWidgetItem(
321 QString::fromStdString(
spots_[i]));
322 item->setSizeHint(QSize(item->sizeHint().width(), 30));
354 QListWidgetItem* item =
spot_list_->currentItem();
356 std::string spot = item->text().toStdString();
357 jsk_rviz_plugins::StringStamped spot_command;
358 spot_command.data = spot;
virtual void spotCallback(const visualization_msgs::MarkerArray::ConstPtr &marker)
QVBoxLayout * spot_dialog_layout_
virtual QString executeButtonStyleSheet()
QPushButton * task_execute_button_
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
QPushButton * task_cancel_button_
QHBoxLayout * task_dialog_button_layout_
virtual void load(const rviz::Config &config)
virtual void save(Config config) const
doubleAcc dot(const VectorAcc &lhs, const VectorAcc &rhs)
ros::Subscriber sub_spots_
std::vector< QRadioButton * > task_radio_buttons_
QPushButton * spot_go_button_
PLUGINLIB_EXPORT_CLASS(jsk_rviz_plugins::TabletControllerPanel, rviz::Panel)
TabletCmdVelArea * cmd_vel_area_
void publish(const boost::shared_ptr< M > &message) const
virtual void publishCmdVel(double x, double y, double theta)
virtual QSize sizeHint() const
QPushButton * spot_button_
ROSLIB_DECL std::string command(const std::string &cmd)
virtual QSize minimumSizeHint() const
ros::Publisher pub_cmd_vel_
ros::Publisher pub_start_demo_
virtual QString defaultButtonStyleSheet()
TabletControllerPanel(QWidget *parent=0)
virtual QString listStyleSheet()
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
QPushButton * task_button_
std::vector< std::string > spots_
INLINE Rall1d< T, V, S > acos(const Rall1d< T, V, S > &x)
virtual ~TabletControllerPanel()
virtual void mousePressEvent(QMouseEvent *event)
QVBoxLayout * task_dialog_layout_
virtual void save(rviz::Config config) const
virtual QString radioButtonStyleSheet()
virtual void mouseMoveEvent(QMouseEvent *event)
virtual void load(const Config &config)
virtual void paintEvent(QPaintEvent *event)
TabletCmdVelArea(QWidget *parent, ros::Publisher &pub_cmd_vel)
QPushButton * spot_cancel_button_
ros::Publisher pub_cmd_vel_
virtual void publishVelocity(int mouse_x, int mouse_y, int cx, int cy)
QHBoxLayout * spot_dialog_button_layout_
void taskExecuteClicked()
virtual void mouseReleaseEvent(QMouseEvent *event)