36 #include <jsk_recognition_msgs/Int32Stamped.h>
37 #include <jsk_interactive_marker/IndexRequest.h>
38 #include <jsk_recognition_msgs/BoundingBoxArray.h>
40 #include <boost/algorithm/string.hpp>
43 std::shared_ptr<interactive_markers::InteractiveMarkerServer>
server;
46 jsk_recognition_msgs::BoundingBoxArray::ConstPtr
box_msg;
52 jsk_recognition_msgs::BoundingBoxArray array_msg;
53 array_msg.header =
box_msg->header;
54 array_msg.boxes.push_back(
box_msg->boxes[
msg.data]);
58 void processFeedback(
const visualization_msgs::InteractiveMarkerFeedbackConstPtr &feedback)
61 if (feedback->event_type == visualization_msgs::InteractiveMarkerFeedback::MOUSE_DOWN) {
62 std::string control_name = feedback->control_name;
64 std::list<std::string> splitted_string;
65 boost::split(splitted_string, control_name, boost::is_space());
66 jsk_recognition_msgs::Int32Stamped
index;
67 index.header.stamp.sec = boost::lexical_cast<int>(splitted_string.front());
68 splitted_string.pop_front();
69 index.header.stamp.nsec = boost::lexical_cast<int>(splitted_string.front());
70 splitted_string.pop_front();
71 index.data = boost::lexical_cast<int>(splitted_string.front());
76 bool indexRequest(jsk_interactive_marker::IndexRequest::Request &req,
77 jsk_interactive_marker::IndexRequest::Response &res)
82 void boxCallback(
const jsk_recognition_msgs::BoundingBoxArray::ConstPtr& msg)
87 for (
size_t i = 0; i <
msg->boxes.size(); i++) {
88 jsk_recognition_msgs::BoundingBox box =
msg->boxes[i];
89 visualization_msgs::InteractiveMarker int_marker;
90 int_marker.header.frame_id = box.header.frame_id;
91 int_marker.pose = box.pose;
94 ss <<
"box" <<
"_" << i;
95 int_marker.name = ss.str();
97 visualization_msgs::InteractiveMarkerControl control;
98 control.interaction_mode = visualization_msgs::InteractiveMarkerControl::BUTTON;
101 std::stringstream ss;
103 ss << box.header.stamp.sec <<
" " << box.header.stamp.nsec <<
" " << i;
104 control.name = ss.str();
106 visualization_msgs::Marker
marker;
107 marker.type = visualization_msgs::Marker::CUBE;
108 marker.scale.x = box.dimensions.x + 0.01;
109 marker.scale.y = box.dimensions.y + 0.01;
110 marker.scale.z = box.dimensions.z + 0.01;
115 control.markers.push_back(
marker);
116 control.always_visible =
true;
117 int_marker.controls.push_back(control);
118 server->insert(int_marker);
124 int main(
int argc,
char** argv)
129 pub = pnh.
advertise<jsk_recognition_msgs::Int32Stamped>(
"selected_index", 1);
130 box_pub = pnh.
advertise<jsk_recognition_msgs::BoundingBox>(
"selected_box", 1);