14 #include <jsk_interactive_marker/GetMarkerDimensions.h> 15 #include <jsk_interactive_marker/GetTransformableMarkerFocus.h> 22 TransformableMarkerOperatorAction::TransformableMarkerOperatorAction( QWidget* parent )
28 QHBoxLayout* server_name_layout =
new QHBoxLayout;
29 server_name_layout->addWidget(
new QLabel(
"Server Name:" ));
32 layout->addLayout( server_name_layout );
35 QHBoxLayout* obj_array_topic_layout =
new QHBoxLayout;
36 obj_array_topic_layout->addWidget(
new QLabel(
"ObjectArray Topic:" ));
39 layout->addLayout( obj_array_topic_layout );
42 QTabWidget* tabs =
new QTabWidget();
44 QVBoxLayout* layout1 =
new QVBoxLayout;
45 QVBoxLayout* layout2 =
new QVBoxLayout;
46 QVBoxLayout* layout3 =
new QVBoxLayout;
48 QWidget* tab_1 =
new QWidget();
49 QWidget* tab_2 =
new QWidget();
50 QWidget* tab_3 =
new QWidget();
66 QHBoxLayout* object_layout =
new QHBoxLayout;
67 object_layout->addWidget(
new QLabel(
"Object:" ));
72 layout1->addLayout( object_layout );
74 QHBoxLayout* name_layout =
new QHBoxLayout;
75 name_layout->addWidget(
new QLabel(
"Name:" ));
78 layout1->addLayout( name_layout );
80 QHBoxLayout* description_layout =
new QHBoxLayout;
81 description_layout->addWidget(
new QLabel(
"Description:" ));
84 layout1->addLayout( description_layout );
86 QHBoxLayout* frame_layout =
new QHBoxLayout;
87 frame_layout->addWidget(
new QLabel(
"Frame:" ));
90 layout1->addLayout( frame_layout );
93 QVBoxLayout* transform_layout =
new QVBoxLayout;
94 transform_layout->addWidget(
new QLabel(
"Object Name:" ));
97 transform_layout->addWidget(
new QLabel(
"Dimension X:" ));
100 transform_layout->addWidget(
new QLabel(
"Dimension Y:" ));
103 transform_layout->addWidget(
new QLabel(
"Dimension Z:" ));
106 transform_layout->addWidget(
new QLabel(
"Dimension Radius:" ));
109 transform_layout->addWidget(
new QLabel(
"Dimension Small Radius:" ));
112 layout2->addLayout( transform_layout );
119 QHBoxLayout* id_layout =
new QHBoxLayout;
120 id_layout->addWidget(
new QLabel(
"Id:" ));
123 layout3->addLayout( id_layout );
131 tab_1->setLayout( layout1 );
132 tab_2->setLayout( layout2 );
133 tab_3->setLayout( layout3 );
135 tabs->addTab(tab_1, QString(
"Insert"));
136 tabs->addTab(tab_2, QString(
"Transform"));
137 tabs->addTab(tab_3, QString(
"Erase"));
139 layout->addWidget( tabs );
163 for (
size_t i = 0; i < obj_array_msg->objects.size(); i++) {
164 jsk_recognition_msgs::Object
object =
objects_[i];
166 QPixmap pixmap = QPixmap();
167 if (
object.image_resources.size() > 0)
169 std::string thumbnail =
object.image_resources[0];
172 pixmap.loadFromData(static_cast<unsigned char*>(mem.
data.get()), mem.
size);
175 std::stringstream ss;
176 ss <<
object.id <<
": " <<
object.name;
178 object_editor_->addItem(QIcon(pixmap), QString::fromStdString(ss.str()));
201 for (
size_t i = 0; i < topics.size(); i++) {
202 if (topics[i].datatype ==
"jsk_recognition_msgs/ObjectArray") {
203 topic = topics[i].name;
214 jsk_rviz_plugins::RequestMarkerOperate operator_srv;
215 operator_srv.request.operate.type = jsk_rviz_plugins::TransformableMarkerOperate::BOX;
216 operator_srv.request.operate.action = jsk_rviz_plugins::TransformableMarkerOperate::INSERT;
217 operator_srv.request.operate.name =
name_editor_->text().toStdString();
219 operator_srv.request.operate.frame_id =
frame_editor_->text().toStdString();
224 jsk_rviz_plugins::RequestMarkerOperate operator_srv;
225 operator_srv.request.operate.type = jsk_rviz_plugins::TransformableMarkerOperate::CYLINDER;
226 operator_srv.request.operate.action = jsk_rviz_plugins::TransformableMarkerOperate::INSERT;
227 operator_srv.request.operate.name =
name_editor_->text().toStdString();
229 operator_srv.request.operate.frame_id =
frame_editor_->text().toStdString();
235 if (!(0 <= current_index && current_index <
objects_.size())) {
236 ROS_ERROR(
"Invalid index for object selection: %d. Please select again.", current_index);
239 jsk_recognition_msgs::Object
object =
objects_[current_index];
241 ROS_ERROR(
"Mesh resource of object '%s' is empty, so skipping.",
object.name.c_str());
245 jsk_rviz_plugins::RequestMarkerOperate operator_srv;
246 operator_srv.request.operate.type = jsk_rviz_plugins::TransformableMarkerOperate::MESH_RESOURCE;
247 operator_srv.request.operate.action = jsk_rviz_plugins::TransformableMarkerOperate::INSERT;
248 operator_srv.request.operate.name =
object.name;
250 operator_srv.request.operate.frame_id =
frame_editor_->text().toStdString();
251 operator_srv.request.operate.mesh_resource =
object.mesh_resource;
252 operator_srv.request.operate.mesh_use_embedded_materials =
true;
257 jsk_rviz_plugins::RequestMarkerOperate operator_srv;
258 operator_srv.request.operate.type = jsk_rviz_plugins::TransformableMarkerOperate::TORUS;
259 operator_srv.request.operate.action = jsk_rviz_plugins::TransformableMarkerOperate::INSERT;
260 operator_srv.request.operate.name =
name_editor_->text().toStdString();
262 operator_srv.request.operate.frame_id =
frame_editor_->text().toStdString();
267 jsk_rviz_plugins::RequestMarkerOperate operator_srv;
268 operator_srv.request.operate.action = jsk_rviz_plugins::TransformableMarkerOperate::ERASE;
269 operator_srv.request.operate.name =
id_editor_->text().toStdString();
274 jsk_rviz_plugins::RequestMarkerOperate operator_srv;
275 operator_srv.request.operate.action = jsk_rviz_plugins::TransformableMarkerOperate::ERASEALL;
280 jsk_rviz_plugins::RequestMarkerOperate operator_srv;
281 operator_srv.request.operate.action = jsk_rviz_plugins::TransformableMarkerOperate::ERASEFOCUS;
287 std::string service_name = server_name +
"/request_marker_operate";
294 ROS_ERROR(
"Service call FAIL: %s", service_name.c_str());
300 std::string service_name = server_name +
"/set_dimensions";
303 jsk_interactive_marker::SetMarkerDimensions
srv;
325 if (client.
call(srv)) {
326 ROS_INFO(
"Call success: %s", service_name.c_str());
328 ROS_ERROR(
"Service call fail: %s", service_name.c_str());
340 if (0 <= current_index && current_index <
objects_.size()) {
341 jsk_recognition_msgs::Object
object =
objects_[current_index];
342 name_editor_->setText(QString::fromStdString(
object.name));
353 for (
size_t i=0; i<nodes.size(); i++) {
365 server_name +
"/get_focus",
true);
366 jsk_interactive_marker::GetTransformableMarkerFocus srv_focus;
368 server_name +
"/get_dimensions",
true);
369 jsk_interactive_marker::GetMarkerDimensions srv_dim;
370 if (client_focus.
call(srv_focus) && client_dim.
call(srv_dim)) {
372 dimension_x_editor_->setPlaceholderText(QString::number(srv_dim.response.dimensions.x,
'f', 4));
373 dimension_y_editor_->setPlaceholderText(QString::number(srv_dim.response.dimensions.y,
'f', 4));
374 dimension_z_editor_->setPlaceholderText(QString::number(srv_dim.response.dimensions.z,
'f', 4));
377 QString::number(srv_dim.response.dimensions.small_radius,
'f', 4));
ServiceClient serviceClient(const std::string &service_name, bool persistent=false, const M_string &header_values=M_string())
pointer SIGNAL(context *, int, pointer *)
VisualizationManager * vis_manager_
PLUGINLIB_EXPORT_CLASS(image_publisher::ImagePublisherNodelet, nodelet::Nodelet)
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
bool call(MReq &req, MRes &res)
ROSCPP_DECL bool getTopics(V_TopicInfo &topics)
std::vector< TopicInfo > V_TopicInfo
bool mapGetString(const QString &key, QString *value_out) const
void mapSetValue(const QString &key, QVariant value)
#define ROS_ERROR_THROTTLE(rate,...)
std::vector< std::string > V_string
boost::shared_array< uint8_t > data
MemoryResource get(const std::string &url)
pointer SLOT(context *, int, pointer *)
virtual void save(Config config) const
ROSCPP_DECL bool exists(const std::string &service_name, bool print_failure_reason)
ROSCPP_DECL bool getNodes(V_string &nodes)
virtual void load(const Config &config)
QString getFixedFrame() const