$search
00001 /****************************************************************************** 00002 * \file 00003 * 00004 * $Id: interaction_primitives_service_server.cpp 676 2012-04-19 18:32:07Z xlokaj03 $ 00005 * 00006 * Copyright (C) Brno University of Technology 00007 * 00008 * This file is part of software developed by Robo@FIT group. 00009 * 00010 * Author: Tomas Lokaj (xlokaj03@stud.fit.vutbr.cz) 00011 * Supervised by: Michal Spanel (spanel@fit.vutbr.cz) 00012 * Date: 9/12/2011 00013 * 00014 * This file is free software: you can redistribute it and/or modify 00015 * it under the terms of the GNU Lesser General Public License as published by 00016 * the Free Software Foundation, either version 3 of the License, or 00017 * (at your option) any later version. 00018 * 00019 * This file is distributed in the hope that it will be useful, 00020 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00021 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00022 * GNU Lesser General Public License for more details. 00023 * 00024 * You should have received a copy of the GNU Lesser General Public License 00025 * along with this file. If not, see <http://www.gnu.org/licenses/>. 00026 */ 00027 00028 #include <srs_interaction_primitives/service_server.h> 00029 00030 using namespace std; 00031 using namespace interactive_markers; 00032 using namespace visualization_msgs; 00033 using namespace geometry_msgs; 00034 using namespace std_msgs; 00035 00036 namespace srs_interaction_primitives 00037 { 00038 00039 // Container with primitives 00040 typedef std::map<std::string, Primitive*> tPrimitives; 00041 tPrimitives primitives; 00042 00043 // Interactive Marker server 00044 InteractiveMarkerServerPtr imServer; 00045 00046 bool addPlane(AddPlane::Request &req, AddPlane::Response &res) 00047 { 00048 ROS_INFO("ADDING PLANE"); 00049 00050 InteractiveMarker tmp; 00051 if ((imServer->get(req.name, tmp)) || (primitives.count(req.name) != 0)) 00052 { 00053 ROS_ERROR("Object with that name already exists! Please remove it first."); 00054 return false; 00055 } 00056 00057 Plane *plane = new Plane(imServer, req.frame_id, req.name); 00058 plane->setPoseType(req.pose_type); 00059 plane->setPose(req.pose); 00060 plane->setScale(req.scale); 00061 plane->setColor(req.color); 00062 plane->insert(); 00063 imServer->applyChanges(); 00064 00065 primitives.insert(make_pair(req.name, plane)); 00066 00067 ROS_INFO("..... DONE"); 00068 return true; 00069 } 00070 00071 bool addPlanePolygon(AddPlanePolygon::Request &req, AddPlanePolygon::Response &res) 00072 { 00073 ROS_INFO("ADDING PLANE POLYGON"); 00074 00075 InteractiveMarker tmp; 00076 if ((imServer->get(req.name, tmp)) || (primitives.count(req.name) != 0)) 00077 { 00078 ROS_ERROR("Object with that name already exists! Please remove it first."); 00079 return false; 00080 } 00081 00082 PlanePolygon *plane = new PlanePolygon(imServer, req.frame_id, req.name); 00083 plane->setPolygon(req.polygon); 00084 plane->setNormal(req.normal); 00085 plane->setColor(req.color); 00086 plane->insert(); 00087 imServer->applyChanges(); 00088 00089 primitives.insert(make_pair(req.name, plane)); 00090 00091 ROS_INFO("..... DONE"); 00092 return true; 00093 } 00094 00095 bool addBillboard(AddBillboard::Request &req, AddBillboard::Response &res) 00096 { 00097 ROS_INFO("ADDING BILLBOARD"); 00098 00099 InteractiveMarker tmp; 00100 if ((imServer->get(req.name, tmp)) || (primitives.count(req.name) != 0)) 00101 { 00102 ROS_ERROR("Object with that name already exists! Please remove it first."); 00103 return false; 00104 } 00105 00106 Billboard *billboard = new Billboard(imServer, req.frame_id, req.name); 00107 billboard->setType(req.type); 00108 billboard->setPoseType(req.pose_type); 00109 billboard->setPose(req.pose); 00110 billboard->setScale(req.scale); 00111 billboard->setDescription(req.description); 00112 billboard->setDirection(req.direction); 00113 billboard->setVelocity(req.velocity); 00114 billboard->insert(); 00115 imServer->applyChanges(); 00116 00117 primitives.insert(make_pair(req.name, billboard)); 00118 00119 ROS_INFO("..... DONE"); 00120 return true; 00121 } 00122 00123 bool addBoundingBox(AddBoundingBox::Request &req, AddBoundingBox::Response &res) 00124 { 00125 ROS_INFO("ADDING BOUNDING BOX"); 00126 00127 InteractiveMarker tmp; 00128 if ((imServer->get(req.name, tmp)) || (primitives.count(req.name) != 0)) 00129 { 00130 ROS_ERROR("Object with that name already exists! Please remove it first."); 00131 return false; 00132 } 00133 00134 BoundingBox * boundingBox = new BoundingBox(imServer, req.frame_id, req.name); 00135 boundingBox->setAttachedObjectName(req.object_name); 00136 boundingBox->setPoseType(req.pose_type); 00137 boundingBox->setPose(req.pose); 00138 boundingBox->setScale(req.scale); 00139 boundingBox->setColor(req.color); 00140 boundingBox->setDescription(req.description); 00141 boundingBox->insert(); 00142 imServer->applyChanges(); 00143 00144 primitives.insert(make_pair(req.name, boundingBox)); 00145 00146 ROS_INFO("..... DONE"); 00147 return true; 00148 } 00149 00150 bool addObject(AddObject::Request &req, AddObject::Response &res) 00151 { 00152 ROS_INFO("ADDING OBJECT"); 00153 00154 InteractiveMarker tmp; 00155 if ((imServer->get(req.name, tmp)) || (primitives.count(req.name) != 0)) 00156 { 00157 ROS_ERROR("Object with that name already exists! Please remove it first."); 00158 return false; 00159 } 00160 00161 Object * object = new Object(imServer, req.frame_id, req.name); 00162 if (req.resource == "") 00163 { 00164 object->setShape(req.shape); 00165 } 00166 else 00167 { 00168 object->setResource(req.resource); 00169 object->setUseMaterial(req.use_material); 00170 } 00171 // object->setPose(req.pose); 00172 object->setPoseType(req.pose_type); 00173 object->setPoseLWH(req.pose, req.bounding_box_lwh); 00174 object->setColor(req.color); 00175 object->setDescription(req.description); 00176 object->setAllowPregrasp(req.allow_pregrasp); 00177 object->insert(); 00178 imServer->applyChanges(); 00179 00180 primitives.insert(make_pair(req.name, object)); 00181 00182 ROS_INFO("..... DONE"); 00183 return true; 00184 } 00185 00186 bool addUnknownObject(AddUnknownObject::Request &req, AddUnknownObject::Response &res) 00187 { 00188 ROS_INFO("ADDING UNKNOWN OBJECT"); 00189 00190 InteractiveMarker tmp; 00191 if ((imServer->get(req.name, tmp)) || (primitives.count(req.name) != 0)) 00192 { 00193 ROS_ERROR("Object with that name already exists! Please remove it first."); 00194 return false; 00195 } 00196 00197 UnknownObject * unknownObject = new UnknownObject(imServer, req.frame_id, req.name); 00198 unknownObject->setPoseType(req.pose_type); 00199 unknownObject->setPose(req.pose); 00200 unknownObject->setScale(req.scale); 00201 unknownObject->setDescription(req.description); 00202 unknownObject->useMaterial((req.disable_material != 0) ? false : true); 00203 unknownObject->insert(); 00204 imServer->applyChanges(); 00205 00206 primitives.insert(make_pair(req.name, unknownObject)); 00207 00208 ROS_INFO("..... DONE"); 00209 return true; 00210 } 00211 00212 bool addMarker(AddMarker::Request &req, AddMarker::Response &res) 00213 { 00214 ROS_INFO("ADDING MARKER"); 00215 00216 InteractiveMarker tmp; 00217 if ((imServer->get(req.name, tmp)) || (primitives.count(req.name) != 0)) 00218 { 00219 ROS_ERROR("Object with that name already exists! Please remove it first."); 00220 return false; 00221 } 00222 00223 InteractiveMarker object; 00224 Marker marker; 00225 marker.type = req.type; 00226 marker.color = req.color; 00227 marker.scale = req.scale; 00228 object.header.frame_id = req.frame_id; 00229 object.header.stamp = ros::Time::now(); 00230 object.name = req.name; 00231 object.description = req.description; 00232 object.pose = req.pose; 00233 InteractiveMarkerControl control; 00234 control.name = object.name + "_control"; 00235 control.interaction_mode = InteractiveMarkerControl::NONE; 00236 control.always_visible = true; 00237 control.markers.push_back(marker); 00238 object.controls.push_back(control); 00239 imServer->insert(object); 00240 imServer->applyChanges(); 00241 00242 ROS_INFO("..... DONE"); 00243 return true; 00244 } 00245 00246 bool removePrimitive(RemovePrimitive::Request &req, RemovePrimitive::Response &res) 00247 { 00248 ROS_INFO("REMOVING PRIMITIVE"); 00249 00250 InteractiveMarker tmp; 00251 if (!imServer->get(req.name, tmp)) 00252 { 00253 ROS_ERROR("Primitive with that name doesn't exist!"); 00254 return false; 00255 } 00256 00257 tPrimitives::iterator it = primitives.find(req.name); 00258 if (it != primitives.end()) 00259 { 00260 delete it->second; 00261 primitives.erase(it); 00262 } 00263 imServer->applyChanges(); 00264 00265 ROS_INFO("..... DONE"); 00266 return true; 00267 } 00268 00269 bool setPreGraspPosition(SetPreGraspPosition::Request &req, SetPreGraspPosition::Response &res) 00270 { 00271 ROS_INFO("SETTING PRE-GRASP POSITION"); 00272 00273 InteractiveMarker tmp; 00274 if ((!imServer->get(req.name, tmp)) || (primitives.count(req.name) != 1)) 00275 { 00276 ROS_ERROR("Primitive with that name doesn't exist!"); 00277 return false; 00278 } 00279 if (primitives[req.name]->getPrimitiveType() != PrimitiveType::OBJECT) 00280 { 00281 ROS_ERROR("Primitive is not of type Object"); 00282 return false; 00283 } 00284 00285 ((Object*)primitives[req.name])->addPreGraspPosition(req.pos_id, req.pose); 00286 primitives[req.name]->insert(); 00287 imServer->applyChanges(); 00288 00289 ROS_INFO("..... DONE"); 00290 return true; 00291 } 00292 00293 bool removePreGraspPosition(RemovePreGraspPosition::Request &req, RemovePreGraspPosition::Response &res) 00294 { 00295 ROS_INFO("REMOVING PRE-GRASP POSITION"); 00296 00297 InteractiveMarker tmp; 00298 if ((!imServer->get(req.name, tmp)) || (primitives.count(req.name) != 1)) 00299 { 00300 ROS_ERROR("Primitive with that name doesn't exist!"); 00301 return false; 00302 } 00303 if (primitives[req.name]->getPrimitiveType() != PrimitiveType::OBJECT) 00304 { 00305 ROS_ERROR("Primitive is not of type Object"); 00306 return false; 00307 } 00308 00309 ((Object*)primitives[req.name])->removePreGraspPosition(req.pos_id); 00310 primitives[req.name]->insert(); 00311 imServer->applyChanges(); 00312 00313 ROS_INFO("..... DONE"); 00314 return true; 00315 } 00316 00317 bool changeDescription(ChangeDescription::Request &req, ChangeDescription::Response &res) 00318 { 00319 ROS_INFO("CHANGING DESCRIPTION"); 00320 00321 InteractiveMarker tmp; 00322 if ((!imServer->get(req.name, tmp)) || (primitives.count(req.name) != 1)) 00323 { 00324 ROS_ERROR("Primitive with that name doesn't exist!"); 00325 return false; 00326 } 00327 00328 primitives[req.name]->setDescription(req.description); 00329 primitives[req.name]->insert(); 00330 imServer->applyChanges(); 00331 00332 ROS_INFO("..... DONE"); 00333 return true; 00334 } 00335 00336 bool changePose(ChangePose::Request &req, ChangePose::Response &res) 00337 { 00338 ROS_INFO("CHANGING POSE"); 00339 00340 InteractiveMarker tmp; 00341 if ((!imServer->get(req.name, tmp)) || (primitives.count(req.name) != 1)) 00342 { 00343 ROS_ERROR("Primitive with that name doesn't exist!"); 00344 return false; 00345 } 00346 00347 primitives[req.name]->setPose(req.pose); 00348 primitives[req.name]->insert(); 00349 imServer->applyChanges(); 00350 00351 ROS_INFO("..... DONE"); 00352 return true; 00353 } 00354 00355 bool changeScale(ChangeScale::Request &req, ChangeScale::Response &res) 00356 { 00357 ROS_INFO("CHANGING SCALE"); 00358 00359 InteractiveMarker tmp; 00360 if ((!imServer->get(req.name, tmp)) || (primitives.count(req.name) != 1)) 00361 { 00362 ROS_ERROR("Primitive with that name doesn't exist!"); 00363 return false; 00364 } 00365 00366 primitives[req.name]->setScale(req.scale); 00367 primitives[req.name]->insert(); 00368 imServer->applyChanges(); 00369 00370 ROS_INFO("..... DONE"); 00371 return true; 00372 } 00373 00374 bool changeColor(ChangeColor::Request &req, ChangeColor::Response &res) 00375 { 00376 ROS_INFO("CHANGING COLOR"); 00377 00378 InteractiveMarker tmp; 00379 if ((!imServer->get(req.name, tmp)) || (primitives.count(req.name) != 1)) 00380 { 00381 ROS_ERROR("Primitive with that name doesn't exist!"); 00382 return false; 00383 } 00384 00385 res.old_color = primitives[req.name]->getColor(); 00386 00387 primitives[req.name]->setColor(req.color); 00388 primitives[req.name]->insert(); 00389 imServer->applyChanges(); 00390 00391 ROS_INFO("..... DONE"); 00392 return true; 00393 } 00394 00395 bool changeDirection(ChangeDirection::Request &req, ChangeDirection::Response &res) 00396 { 00397 ROS_INFO("CHANGING DIRECTION"); 00398 00399 InteractiveMarker tmp; 00400 if ((!imServer->get(req.name, tmp)) || (primitives.count(req.name) != 1)) 00401 { 00402 ROS_ERROR("Primitive with that name doesn't exist!"); 00403 return false; 00404 } 00405 if (primitives[req.name]->getPrimitiveType() != PrimitiveType::BILLBOARD) 00406 { 00407 ROS_WARN("This is object is not a billboard, direction cannot be changed!"); 00408 return false; 00409 } 00410 00411 ((Billboard*)primitives[req.name])->setDirection(req.direction); 00412 primitives[req.name]->insert(); 00413 imServer->applyChanges(); 00414 00415 ROS_INFO("..... DONE"); 00416 return true; 00417 } 00418 00419 bool changeVelocity(ChangeVelocity::Request &req, ChangeVelocity::Response &res) 00420 { 00421 ROS_INFO("CHANGING VELOCITY"); 00422 00423 InteractiveMarker tmp; 00424 if ((!imServer->get(req.name, tmp)) || (primitives.count(req.name) != 1)) 00425 { 00426 ROS_ERROR("Primitive with that name doesn't exist!"); 00427 return false; 00428 } 00429 00430 if (primitives[req.name]->getPrimitiveType() != PrimitiveType::BILLBOARD) 00431 { 00432 ROS_WARN("This is object is not a billboard, velocity cannot be changed!"); 00433 return false; 00434 } 00435 00436 ((Billboard*)primitives[req.name])->setVelocity(req.velocity); 00437 primitives[req.name]->insert(); 00438 imServer->applyChanges(); 00439 00440 ROS_INFO("..... DONE"); 00441 return true; 00442 } 00443 00444 bool setAllowObjectInteraction(SetAllowObjectInteraction::Request &req, SetAllowObjectInteraction::Response &res) 00445 { 00446 ROS_INFO("SETTING OBJECT'S INTERACTION"); 00447 00448 InteractiveMarker tmp; 00449 if ((!imServer->get(req.name, tmp)) || (primitives.count(req.name) != 1)) 00450 { 00451 ROS_ERROR("Primitive with that name doesn't exist!"); 00452 return false; 00453 } 00454 if ( (primitives[req.name]->getPrimitiveType() != PrimitiveType::OBJECT) && (primitives[req.name]->getPrimitiveType() != PrimitiveType::UNKNOWN_OBJECT) ) 00455 { 00456 ROS_ERROR("Primitive is not of type Object"); 00457 return false; 00458 } 00459 00460 00461 if (primitives[req.name]->getPrimitiveType() != PrimitiveType::OBJECT) { 00462 00463 ((Object*)primitives[req.name])->setAllowObjectInteraction(req.allow); 00464 00465 } else 00466 00467 if (primitives[req.name]->getPrimitiveType() != PrimitiveType::UNKNOWN_OBJECT) { 00468 00469 ((UnknownObject*)primitives[req.name])->setAllowObjectInteraction(req.allow); 00470 00471 } 00472 00473 ROS_INFO("..... DONE"); 00474 return true; 00475 } 00476 00477 bool getUpdateTopic(GetUpdateTopic::Request &req, GetUpdateTopic::Response &res) 00478 { 00479 ROS_INFO("GETTING UPDATE TOPIC"); 00480 00481 InteractiveMarker tmp; 00482 if ((!imServer->get(req.name, tmp)) || (primitives.count(req.name) != 1)) 00483 { 00484 ROS_ERROR("Primitive with that name doesn't exist!"); 00485 return false; 00486 } 00487 00488 res.update_topic = primitives[req.name]->getUpdateTopic(req.type); 00489 00490 ROS_INFO("..... DONE"); 00491 return true; 00492 } 00493 00494 bool getAllPrimitivesNames(GetAllPrimitivesNames::Request &req, GetAllPrimitivesNames::Response &res) 00495 { 00496 ROS_INFO("GETTING ALL PRIMITIVE'S NAMES"); 00497 00498 map<string, Primitive*>::iterator i; 00499 for (i = primitives.begin(); i != primitives.end(); i++) 00500 res.primitives_names.push_back(i->second->getName()); 00501 00502 return true; 00503 } 00504 00505 bool getObject(GetObject::Request &req, GetObject::Response &res) 00506 { 00507 ROS_INFO("GETTING OBJECT"); 00508 00509 if (primitives.count(req.name) > 0) 00510 { 00511 Object *obj = (Object*)primitives.at(req.name); 00512 if (obj->getPrimitiveType() == srs_interaction_primitives::PrimitiveType::OBJECT) 00513 { 00514 res.name = req.name; 00515 res.frame_id = obj->getFrameID(); 00516 res.pose_type = obj->getPoseType(); 00517 res.pose = obj->getPose(); 00518 res.bounding_box_lwh = obj->getBoundingBoxLWH(); 00519 res.description = obj->getDescription(); 00520 res.color = obj->getColor(); 00521 res.shape = obj->getShape(); 00522 res.resource = obj->getResource(); 00523 res.use_material = obj->getUseMaterial(); 00524 return true; 00525 } 00526 } 00527 ROS_ERROR("Object with that name doesn't exist!"); 00528 return false; 00529 } 00530 00531 bool getUnknownObject(GetUnknownObject::Request &req, GetUnknownObject::Response &res) 00532 { 00533 ROS_INFO("GETTING OBJECT"); 00534 00535 if (primitives.count(req.name) > 0) 00536 { 00537 UnknownObject *obj = (UnknownObject*)primitives.at(req.name); 00538 if (obj->getPrimitiveType() == srs_interaction_primitives::PrimitiveType::UNKNOWN_OBJECT) 00539 { 00540 res.name = req.name; 00541 res.frame_id = obj->getFrameID(); 00542 res.pose_type = obj->getPoseType(); 00543 res.pose = obj->getPose(); 00544 res.description = obj->getDescription(); 00545 res.scale = obj->getScale(); 00546 return true; 00547 } 00548 } 00549 ROS_ERROR("Unknown Object with that name doesn't exist!"); 00550 return false; 00551 } 00552 00553 bool getBillboard(GetBillboard::Request &req, GetBillboard::Response &res) 00554 { 00555 ROS_INFO("GETTING BILLBOARD"); 00556 00557 if (primitives.count(req.name) > 0) 00558 { 00559 Billboard *obj = (Billboard*)primitives.at(req.name); 00560 if (obj->getPrimitiveType() == srs_interaction_primitives::PrimitiveType::BILLBOARD) 00561 { 00562 res.name = req.name; 00563 res.frame_id = obj->getFrameID(); 00564 res.pose_type = obj->getPoseType(); 00565 res.pose = obj->getPose(); 00566 res.description = obj->getDescription(); 00567 res.scale = obj->getScale(); 00568 res.description = obj->getDescription(); 00569 res.type = obj->getType(); 00570 res.velocity = obj->getVelocity(); 00571 res.direction = obj->getDirection(); 00572 return true; 00573 } 00574 } 00575 ROS_ERROR("Billboard with that name doesn't exist!"); 00576 return false; 00577 } 00578 00579 bool getBoundingBox(GetBoundingBox::Request &req, GetBoundingBox::Response &res) 00580 { 00581 ROS_INFO("GETTING BOUNDING BOX"); 00582 00583 if (primitives.count(req.name) > 0) 00584 { 00585 BoundingBox *obj = (BoundingBox*)primitives.at(req.name); 00586 if (obj->getPrimitiveType() == srs_interaction_primitives::PrimitiveType::BOUNDING_BOX) 00587 { 00588 res.name = req.name; 00589 res.frame_id = obj->getFrameID(); 00590 res.pose_type = obj->getPoseType(); 00591 res.pose = obj->getPose(); 00592 res.description = obj->getDescription(); 00593 res.color = obj->getColor(); 00594 res.scale = obj->getScale(); 00595 res.object_name = obj->getAttachedObjectName(); 00596 return true; 00597 } 00598 } 00599 ROS_ERROR("Bounding box with that name doesn't exist!"); 00600 return false; 00601 } 00602 00603 bool getPlane(GetPlane::Request &req, GetPlane::Response &res) 00604 { 00605 ROS_INFO("GETTING PLANE"); 00606 00607 if (primitives.count(req.name) > 0) 00608 { 00609 Plane *obj = (Plane*)primitives.at(req.name); 00610 if (obj->getPrimitiveType() == srs_interaction_primitives::PrimitiveType::PLANE) 00611 { 00612 res.name = req.name; 00613 res.frame_id = obj->getFrameID(); 00614 res.pose_type = obj->getPoseType(); 00615 res.pose = obj->getPose(); 00616 res.description = obj->getDescription(); 00617 res.color = obj->getColor(); 00618 res.scale = obj->getScale(); 00619 return true; 00620 } 00621 } 00622 ROS_ERROR("Plane with that name doesn't exist!"); 00623 return false; 00624 } 00625 00626 bool clickablePositions(ClickablePositions::Request &req, ClickablePositions::Response &res) 00627 { 00628 ROS_INFO("ADDING CLICK POSITIONS"); 00629 00630 std::vector<geometry_msgs::Point> positions; 00631 for (unsigned int i = 0; i < req.positions.size(); i++) 00632 { 00633 positions.push_back(req.positions.at(i)); 00634 } 00635 ClickablePositionsMarker *clickPositions = new ClickablePositionsMarker(imServer,req.frame_id, req.topic_suffix, req.radius, 00636 req.color, positions); 00637 imServer->insert(clickPositions->getMarker(), 00638 boost::bind(&ClickablePositionsMarker::markerFeedback, clickPositions, _1)); 00639 imServer->applyChanges(); 00640 00641 res.topic = BUT_PositionClicked_TOPIC(req.topic_suffix); 00642 00643 ROS_INFO("DONE"); 00644 return true; 00645 } 00646 00647 bool robotPosePrediction(RobotPosePrediction::Request &req, RobotPosePrediction::Response &res) 00648 { 00649 ROS_INFO("ADDING ROBOT'S PREDICTED POSITIONS"); 00650 00651 /*visualization_msgs::InteractiveMarker predictedPositions; 00652 predictedPositions.header.frame_id = "/map"; 00653 predictedPositions.name = "robot_pose_prediction"; 00654 00655 visualization_msgs::InteractiveMarkerControl control; 00656 control.always_visible = true; 00657 control.independent_marker_orientation = true; 00658 control.interaction_mode = visualization_msgs::InteractiveMarkerControl::NONE;*/ 00659 00660 visualization_msgs::Marker marker; 00661 marker.header.frame_id = "/map"; 00662 marker.ns = "interaction_primitives"; 00663 marker.id = 0; 00664 00665 marker.header.stamp = ros::Time(); 00666 marker.lifetime = (req.ttl <= 0.0) ? ros::Duration(5) : ros::Duration(req.ttl); 00667 marker.color.g = 1; 00668 marker.color.a = 0.5; 00669 marker.type = visualization_msgs::Marker::LINE_STRIP; 00670 marker.scale.x = 0.05; 00671 for (unsigned int i = 0; i < req.positions.size(); i++) 00672 { 00673 marker.points.push_back(req.positions.at(i).position); 00674 } 00675 // control.markers.push_back(marker); 00676 vis_pub.publish(marker); 00677 00678 marker.id = 1; 00679 marker.type = visualization_msgs::Marker::SPHERE_LIST; 00680 marker.color.b = 1; 00681 marker.scale.x = 0.1; 00682 marker.scale.y = 0.1; 00683 marker.scale.z = 0.1; 00684 // control.markers.push_back(marker); 00685 vis_pub.publish(marker); 00686 00687 // predictedPositions.controls.push_back(control); 00688 00689 // imServer->insert(predictedPositions); 00690 // imServer->applyChanges(); 00691 00692 ROS_INFO("DONE"); 00693 return true; 00694 } 00695 00696 } 00697 00701 int main(int argc, char **argv) 00702 { 00703 using namespace srs_interaction_primitives; 00704 00705 // ROS initialization (the last argument is the name of the node) 00706 ros::init(argc, argv, ros::this_node::getName()); 00707 00708 // NodeHandle is the main access point to communications with the ROS system 00709 ros::NodeHandle n; 00710 00711 // Interactive Marker Server initialization 00712 imServer.reset(new InteractiveMarkerServer("interaction_primitives", "", false)); 00713 imServer->clear(); 00714 00715 vis_pub = n.advertise<visualization_msgs::Marker>("interaction_primitives", 0); 00716 00717 // Create and advertise this service over ROS 00718 ros::ServiceServer addBoundingBoxService = n.advertiseService(AddBoundingBox_SRV, addBoundingBox); 00719 ros::ServiceServer addBillboardService = n.advertiseService(AddBillboard_SRV, addBillboard); 00720 ros::ServiceServer addPlaneService = n.advertiseService(AddPlane_SRV, addPlane); 00721 ros::ServiceServer addPlanePolygonService = n.advertiseService(AddPlanePolygon_SRV, addPlanePolygon); 00722 ros::ServiceServer addObjectService = n.advertiseService(AddObject_SRV, addObject); 00723 ros::ServiceServer addUnknownObjectService = n.advertiseService(AddUnknownObject_SRV, addUnknownObject); 00724 00725 ros::ServiceServer removePrimitiveService = n.advertiseService(RemovePrimitive_SRV, removePrimitive); 00726 00727 ros::ServiceServer changeDescriptionService = n.advertiseService(ChangeDescription_SRV, changeDescription); 00728 ros::ServiceServer changePoseService = n.advertiseService(ChangePose_SRV, changePose); 00729 ros::ServiceServer changeScaleService = n.advertiseService(ChangeScale_SRV, changeScale); 00730 ros::ServiceServer changeColorService = n.advertiseService(ChangeColor_SRV, changeColor); 00731 ros::ServiceServer changeDirectionService = n.advertiseService(ChangeDirection_SRV, changeDirection); 00732 ros::ServiceServer changeVelocityService = n.advertiseService(ChangeVelocity_SRV, changeVelocity); 00733 ros::ServiceServer setAllowObjectInteractionService = n.advertiseService(SetAllowObjectInteraction_SRV, 00734 setAllowObjectInteraction); 00735 00736 ros::ServiceServer setGraspingPositionService = n.advertiseService(SetGraspingPosition_SRV, setPreGraspPosition); 00737 ros::ServiceServer removeGraspingPositionService = n.advertiseService(RemoveGraspingPosition_SRV, 00738 removePreGraspPosition); 00739 00740 ros::ServiceServer getUpdateTopicService = n.advertiseService(GetUpdateTopic_SRV, getUpdateTopic); 00741 00742 ros::ServiceServer getAllPrimitivesNamesService = n.advertiseService(GetAllPrimitivesNames_SRV, 00743 getAllPrimitivesNames); 00744 ros::ServiceServer getObjectService = n.advertiseService(GetObject_SRV, getObject); 00745 ros::ServiceServer getUnknownObjectService = n.advertiseService(GetUnknownObject_SRV, getUnknownObject); 00746 ros::ServiceServer getBillboardService = n.advertiseService(GetBillboard_SRV, getBillboard); 00747 ros::ServiceServer getBoundingBoxService = n.advertiseService(GetBoundingBox_SRV, getBoundingBox); 00748 ros::ServiceServer getPlaneService = n.advertiseService(GetPlane_SRV, getPlane); 00749 00750 ros::ServiceServer clickablePositionService = n.advertiseService(ClickablePositions_SRV, clickablePositions); 00751 ros::ServiceServer robotPosePredictionService = n.advertiseService(RobotPosePrediction_SRV, robotPosePrediction); 00752 00753 ROS_INFO("Interaction Primitives Service Server ready!"); 00754 00755 // Enters a loop, calling message callbacks 00756 ros::spin(); 00757 00758 return 0; 00759 } 00760