7 #include <boost/format.hpp> 9 #include <std_srvs/Empty.h> 27 QHBoxLayout* layout =
new QHBoxLayout();
29 if (nh.
hasParam(
"robot_command_buttons")) {
32 nh.
param(
"robot_command_buttons", robot_command_buttons_xmlrpc, robot_command_buttons_xmlrpc);
37 for (
size_t i = 0; i < robot_command_buttons_xmlrpc.
size(); i++) {
44 QToolButton* button =
new QToolButton();
46 button->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
49 name = (std::string)button_xmlrpc[
"name"];
54 button->setText(QString(name.c_str()));
58 icon = (std::string)button_xmlrpc[
"icon"];
59 if (icon.find(
"package://") == 0) {
60 icon.erase(0, strlen(
"package://"));
61 size_t package_end = icon.find(
"/");
62 std::string
package = icon.substr(0, package_end);
63 icon.erase(0, package_end);
64 std::string package_path;
66 icon = package_path + icon;
68 button->setIcon(QIcon(QPixmap(QString(icon.c_str()))));
69 button->setIconSize(QSize(80, 80));
70 button->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
74 type = (std::string)button_xmlrpc[
"type"];
76 if (type ==
"euscommand") {
85 else if (type ==
"emptysrv") {
100 layout->addWidget(button);
106 popupDialog((boost::format(
"Malformed ~robot_command_buttons parameter.\n" 108 "See package://jsk_rviz_plugins/config/default_robot_command.yaml")
109 % e.what()).
str().c_str());
113 popupDialog(
"You need to specify ~robot_command_buttons parameter.\n" 114 "See package://jsk_rviz_plugins/launch/robot_command_interface_sample.launch");
116 layout->addStretch();
126 this->setLayout(layout);
131 jsk_rviz_plugins::EusCommand
srv;
132 srv.request.command = command;
133 return client.
call(srv);
151 popupDialog((boost::format(
"Failed to find corresponding command for %d") % i).
str().c_str());
158 msg_box.setText(
"Unexpected error");
159 msg_box.setText(QString(text.c_str()));
ServiceClient serviceClient(const std::string &service_name, bool persistent=false, const M_string &header_values=M_string())
bool callRequestEusCommand(const std::string &command)
PLUGINLIB_EXPORT_CLASS(jsk_rviz_plugins::PictogramArrayDisplay, rviz::Display)
bool call(const std::string &service_name, MReq &req, MRes &res)
std::map< int, std::string > euscommand_mapping_
bool call(MReq &req, MRes &res)
QSignalMapper * signal_mapper_
std::map< int, std::string > emptyservice_mapping_
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
Type const & getType() const
RobotCommandParseException(const std::string &text)
bool hasParam(const std::string &key) const
ROSLIB_DECL std::string getPath(const std::string &package_name)
RobotCommandInterfaceAction(QWidget *parent=0)
void popupDialog(const std::string &text)
void buttonCallback(int i)
bool hasMember(const std::string &name) const