$search
00001 /********************************************************************* 00002 * 00003 * Software License Agreement (BSD License) 00004 * 00005 * Copyright (c) 2008, Willow Garage, Inc. 00006 * All rights reserved. 00007 * 00008 * Redistribution and use in source and binary forms, with or without 00009 * modification, are permitted provided that the following conditions 00010 * are met: 00011 * 00012 * * Redistributions of source code must retain the above copyright 00013 * notice, this list of conditions and the following disclaimer. 00014 * * Redistributions in binary form must reproduce the above 00015 * copyright notice, this list of conditions and the following 00016 * disclaimer in the documentation and/or other materials provided 00017 * with the distribution. 00018 * * Neither the name of the Willow Garage nor the names of its 00019 * contributors may be used to endorse or promote products derived 00020 * from this software without specific prior written permission. 00021 * 00022 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00023 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00024 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00025 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00026 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00027 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00028 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00029 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00030 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00031 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00032 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00033 * POSSIBILITY OF SUCH DAMAGE. 00034 * 00035 * \author E. Gil Jones 00036 *********************************************************************/ 00037 00038 #include <ros/console.h> 00039 #include <boost/foreach.hpp> 00040 #include <sstream> 00041 00042 #include <move_arm_warehouse/move_arm_warehouse_logger_reader.h> 00043 00044 using namespace move_arm_warehouse; 00045 00046 static const std::string DATABASE_NAME="arm_navigation"; 00047 static const std::string PLANNING_SCENE_TIME_NAME="planning_scene_time"; 00048 static const std::string PLANNING_SCENE_ID_NAME="planning_scene_id"; 00049 static const std::string MOTION_PLAN_REQUEST_ID_NAME="motion_request_id"; 00050 static const std::string TRAJECTORY_ID_NAME="trajectory_id"; 00051 static const std::string TRAJECTORY_MOTION_REQUEST_ID_NAME="trajectory_motion_request_id"; 00052 static const std::string PAUSED_COLLISION_MAP_TIME_NAME="paused_collision_map_time"; 00053 00054 typedef mongo_ros::MessageWithMetadata<arm_navigation_msgs::PlanningScene>::ConstPtr PlanningSceneWithMetadata; 00055 typedef mongo_ros::MessageWithMetadata<arm_navigation_msgs::MotionPlanRequest>::ConstPtr MotionPlanRequestWithMetadata; 00056 typedef mongo_ros::MessageWithMetadata<trajectory_msgs::JointTrajectory>::ConstPtr JointTrajectoryWithMetadata; 00057 typedef mongo_ros::MessageWithMetadata<arm_navigation_msgs::ArmNavigationErrorCodes>::ConstPtr ErrorCodesWithMetadata; 00058 typedef mongo_ros::MessageWithMetadata<head_monitor_msgs::HeadMonitorFeedback>::ConstPtr HeadMonitorFeedbackWithMetadata; 00059 00060 MoveArmWarehouseLoggerReader::MoveArmWarehouseLoggerReader() 00061 { 00062 char hostname[256]; 00063 00064 gethostname(hostname, 256); 00065 00066 hostname_ = hostname; 00067 00068 ROS_DEBUG_STREAM("Hostname is " << hostname_); 00069 00070 00071 planning_scene_collection_ = new mongo_ros::MessageCollection<arm_navigation_msgs::PlanningScene>(DATABASE_NAME, "planning_scene"); 00072 motion_plan_request_collection_ = new mongo_ros::MessageCollection<arm_navigation_msgs::MotionPlanRequest>(DATABASE_NAME, "motion_plan_request"); 00073 trajectory_collection_ = new mongo_ros::MessageCollection<trajectory_msgs::JointTrajectory>(DATABASE_NAME, "trajectory"); 00074 outcome_collection_ = new mongo_ros::MessageCollection<arm_navigation_msgs::ArmNavigationErrorCodes>(DATABASE_NAME, "outcome"); 00075 paused_state_collection_ = new mongo_ros::MessageCollection<head_monitor_msgs::HeadMonitorFeedback>(DATABASE_NAME, "paused_state"); 00076 } 00077 00078 MoveArmWarehouseLoggerReader::~MoveArmWarehouseLoggerReader() { 00079 delete planning_scene_collection_; 00080 delete motion_plan_request_collection_; 00081 delete trajectory_collection_; 00082 delete outcome_collection_; 00083 delete paused_state_collection_; 00084 } 00085 00089 00090 mongo_ros::Metadata MoveArmWarehouseLoggerReader::initializeMetadataWithHostname() 00091 { 00092 return mongo_ros::Metadata("hostname", hostname_); 00093 } 00094 00095 void MoveArmWarehouseLoggerReader::addPlanningSceneIdToMetadata(const unsigned int& id, 00096 mongo_ros::Metadata& metadata) { 00097 metadata.append(PLANNING_SCENE_ID_NAME, id); 00098 } 00099 00100 void MoveArmWarehouseLoggerReader::addPlanningSceneTimeToMetadata(const arm_navigation_msgs::PlanningScene& planning_scene, 00101 mongo_ros::Metadata& metadata) 00102 { 00103 metadata.append(PLANNING_SCENE_TIME_NAME, planning_scene.robot_state.joint_state.header.stamp.toSec()); 00104 } 00105 00106 unsigned int MoveArmWarehouseLoggerReader::determineNextPlanningSceneId() { 00107 mongo_ros::Query q; 00108 std::vector<PlanningSceneWithMetadata> planning_scenes = planning_scene_collection_->pullAllResults(q, true, PLANNING_SCENE_ID_NAME, false); 00109 if(planning_scenes.size() == 0) { 00110 return 0; 00111 } 00112 //should be in reverse order 00113 return planning_scenes.front()->lookupInt(PLANNING_SCENE_ID_NAME)+1; 00114 } 00115 00116 void MoveArmWarehouseLoggerReader::pushPlanningSceneToWarehouseWithoutId(const arm_navigation_msgs::PlanningScene& planning_scene, 00117 unsigned int& id) 00118 { 00119 id = determineNextPlanningSceneId(); 00120 pushPlanningSceneToWarehouse(planning_scene, id); 00121 } 00122 00123 00124 void MoveArmWarehouseLoggerReader::pushPlanningSceneToWarehouse(const arm_navigation_msgs::PlanningScene& planning_scene, 00125 const unsigned int id) 00126 { 00127 mongo_ros::Metadata metadata = initializeMetadataWithHostname(); 00128 addPlanningSceneTimeToMetadata(planning_scene, metadata); 00129 //TODO - check for duplicates? 00130 addPlanningSceneIdToMetadata(id, metadata); 00131 planning_scene_collection_->insert(planning_scene, metadata); 00132 } 00133 00134 void MoveArmWarehouseLoggerReader::pushMotionPlanRequestToWarehouse(const unsigned int planning_scene_id, 00135 const unsigned int mpr_id, 00136 const std::string& stage_name, 00137 const arm_navigation_msgs::MotionPlanRequest& motion_plan_request) 00138 { 00139 mongo_ros::Metadata metadata = initializeMetadataWithHostname(); 00140 addPlanningSceneIdToMetadata(planning_scene_id, metadata); 00141 00142 metadata.append("stage_name", stage_name); 00143 00144 metadata.append(MOTION_PLAN_REQUEST_ID_NAME, mpr_id); 00145 //adding the presence of goal pose constraints to metadata 00146 metadata.append("has_goal_position_constraints", !motion_plan_request.goal_constraints.position_constraints.empty()); 00147 00148 00149 metadata.append("has_path_constraints", 00150 (!motion_plan_request.path_constraints.orientation_constraints.empty() || motion_plan_request.path_constraints.position_constraints.empty())); 00151 00152 motion_plan_request_collection_->insert(motion_plan_request, metadata); 00153 } 00154 00155 void MoveArmWarehouseLoggerReader::pushJointTrajectoryToWarehouse(const unsigned int planning_scene_id, 00156 const std::string& trajectory_source, 00157 const ros::Duration& production_time, 00158 const trajectory_msgs::JointTrajectory& trajectory, 00159 const unsigned int trajectory_id, 00160 const unsigned int motion_request_id, 00161 const arm_navigation_msgs::ArmNavigationErrorCodes& error_code) 00162 { 00163 mongo_ros::Metadata metadata = initializeMetadataWithHostname(); 00164 addPlanningSceneIdToMetadata(planning_scene_id, metadata); 00165 00166 metadata.append("trajectory_source", trajectory_source); 00167 metadata.append("production_time", production_time.toSec()); 00168 metadata.append(TRAJECTORY_ID_NAME, trajectory_id); 00169 metadata.append(TRAJECTORY_MOTION_REQUEST_ID_NAME, motion_request_id); 00170 metadata.append("trajectory_error_code", error_code.val); 00171 trajectory_collection_->insert(trajectory, metadata); 00172 } 00173 00174 void MoveArmWarehouseLoggerReader::pushOutcomeToWarehouse(const unsigned int id, 00175 const std::string& pipeline_stage, 00176 const arm_navigation_msgs::ArmNavigationErrorCodes& error_codes) 00177 { 00178 mongo_ros::Metadata metadata = initializeMetadataWithHostname(); 00179 addPlanningSceneIdToMetadata(id, metadata); 00180 00181 metadata.append("pipeline_stage", pipeline_stage); 00182 outcome_collection_->insert(error_codes, metadata); 00183 } 00184 00185 void MoveArmWarehouseLoggerReader::pushPausedStateToWarehouse(const unsigned int id, 00186 const head_monitor_msgs::HeadMonitorFeedback& feedback) 00187 { 00188 mongo_ros::Metadata metadata = initializeMetadataWithHostname(); 00189 addPlanningSceneIdToMetadata(id, metadata); 00190 metadata.append(PAUSED_COLLISION_MAP_TIME_NAME, feedback.paused_collision_map.header.stamp.toSec()); 00191 paused_state_collection_->insert(feedback, metadata); 00192 } 00193 00197 00198 void MoveArmWarehouseLoggerReader::getAvailablePlanningSceneList(const std::string& hostname, 00199 std::vector<unsigned int>& planning_scene_ids, 00200 std::vector<ros::Time>& creation_times) 00201 { 00202 creation_times.clear(); 00203 planning_scene_ids.clear(); 00204 00205 // std::stringstream fin(planning_scenes[i]->metadata); 00206 // YAML::Parser parser(fin); 00207 // YAML::Node doc; 00208 // while(parser.GetNextDocument(doc)) { } 00209 00210 mongo_ros::Query q; 00211 std::vector<PlanningSceneWithMetadata> planning_scenes = planning_scene_collection_->pullAllResults(q, true, PLANNING_SCENE_TIME_NAME, true); 00212 00213 planning_scene_ids.resize(planning_scenes.size()); 00214 creation_times.resize(planning_scenes.size()); 00215 00216 bool no_ids = false; 00217 for(unsigned int i = 0; i < planning_scenes.size(); i++) { 00218 if(!planning_scenes[i]->metadata.hasField(PLANNING_SCENE_ID_NAME.c_str())) { 00219 no_ids = true; 00220 break; 00221 } 00222 planning_scene_ids[i] = planning_scenes[i]->lookupInt(PLANNING_SCENE_ID_NAME); 00223 ROS_DEBUG_STREAM("Got planning scene id " << planning_scene_ids[i]); 00224 creation_times[i] = ros::Time(planning_scenes[i]->lookupDouble(PLANNING_SCENE_TIME_NAME)); 00225 } 00226 if(no_ids) { 00227 ROS_WARN_STREAM("No planning scene ids, can't load"); 00228 } 00229 } 00230 00231 mongo_ros::Query MoveArmWarehouseLoggerReader::makeQueryForPlanningSceneTime(const ros::Time& time) 00232 { 00233 mongo_ros::Query retq; 00234 retq.append(PLANNING_SCENE_TIME_NAME, time.toSec()); 00235 return retq; 00236 } 00237 00238 mongo_ros::Query MoveArmWarehouseLoggerReader::makeQueryForPlanningSceneId(const unsigned int id) 00239 { 00240 mongo_ros::Query retq; 00241 retq.append(PLANNING_SCENE_ID_NAME, id); 00242 return retq; 00243 } 00244 00245 bool MoveArmWarehouseLoggerReader::getPlanningScene(const std::string& hostname, 00246 const unsigned int& id, 00247 arm_navigation_msgs::PlanningScene& planning_scene, 00248 std::string& hostname_out) 00249 { 00250 mongo_ros::Query q = makeQueryForPlanningSceneId(id); 00251 std::vector<PlanningSceneWithMetadata> planning_scenes = planning_scene_collection_->pullAllResults(q, false); 00252 00253 if(planning_scenes.size() == 0) { 00254 ROS_WARN_STREAM("No scenes with id " << id); 00255 return false; 00256 } else if(planning_scenes.size() > 1) { 00257 ROS_WARN_STREAM("More than one scene with id " << id << " num " << planning_scenes.size()); 00258 } 00259 00260 PlanningSceneWithMetadata& scene = planning_scenes[0]; 00261 planning_scene = *scene; 00262 hostname_out = scene->lookupString("hostname"); 00263 return true; 00264 } 00265 00266 bool MoveArmWarehouseLoggerReader::getAssociatedOutcomes(const std::string& hostname, 00267 const unsigned int id, 00268 std::vector<std::string>& pipeline_names, 00269 std::vector<arm_navigation_msgs::ArmNavigationErrorCodes>& error_codes) 00270 { 00271 mongo_ros::Query q = makeQueryForPlanningSceneId(id); 00272 std::vector<ErrorCodesWithMetadata> meta_error_codes = outcome_collection_->pullAllResults(q, false); 00273 00274 if(meta_error_codes.size() == 0) { 00275 ROS_DEBUG_STREAM("No outcomes associated with id " << id); 00276 return false; 00277 } 00278 error_codes.resize(meta_error_codes.size()); 00279 pipeline_names.resize(meta_error_codes.size()); 00280 for(unsigned int i = 0; i < meta_error_codes.size(); i++) { 00281 pipeline_names[i] = meta_error_codes[i]->lookupString("pipeline_stage"); 00282 error_codes[i] = *meta_error_codes[i]; 00283 } 00284 return true; 00285 } 00286 00287 bool MoveArmWarehouseLoggerReader::getAssociatedMotionPlanRequestsStageNames(const std::string& hostname, 00288 const unsigned int planning_scene_id, 00289 std::vector<std::string>& stage_names) 00290 { 00291 mongo_ros::Query q = makeQueryForPlanningSceneId(planning_scene_id); 00292 std::vector<MotionPlanRequestWithMetadata> motion_plan_requests = motion_plan_request_collection_->pullAllResults(q, true, PLANNING_SCENE_ID_NAME, true); 00293 00294 if(motion_plan_requests.size() == 0) { 00295 ROS_DEBUG_STREAM("No motion plan requests with id" << planning_scene_id); 00296 return false; 00297 } 00298 00299 stage_names.resize(motion_plan_requests.size()); 00300 for(unsigned int i = 0; i < motion_plan_requests.size(); i++) { 00301 stage_names[i] = motion_plan_requests[i]->lookupString("stage_name"); 00302 } 00303 return true; 00304 } 00305 00306 bool MoveArmWarehouseLoggerReader::getAssociatedMotionPlanRequest(const std::string& hostname, 00307 const unsigned int planning_scene_id, 00308 const unsigned int motion_request_id, 00309 arm_navigation_msgs::MotionPlanRequest& request) 00310 { 00311 mongo_ros::Query q = makeQueryForPlanningSceneId(planning_scene_id); 00312 q.append(MOTION_PLAN_REQUEST_ID_NAME, motion_request_id); 00313 std::vector<MotionPlanRequestWithMetadata> motion_plan_requests = motion_plan_request_collection_->pullAllResults(q, false); 00314 00315 if(motion_plan_requests.size() == 0) { 00316 ROS_WARN_STREAM("No motion plan requests with planning scene id " << planning_scene_id 00317 << " and motion plan id " << motion_request_id); 00318 return false; 00319 } else if(motion_plan_requests.size() > 1) { 00320 ROS_WARN_STREAM("More than one motion plan requests with planning scene id " << planning_scene_id 00321 << " and motion plan id " << motion_request_id); 00322 return false; 00323 } 00324 request = *motion_plan_requests[0]; 00325 return true; 00326 } 00327 00328 bool MoveArmWarehouseLoggerReader::getAssociatedMotionPlanRequests(const std::string& hostname, 00329 const unsigned int planning_scene_id, 00330 std::vector<unsigned int>& ids, 00331 std::vector<std::string>& stage_names, 00332 std::vector<arm_navigation_msgs::MotionPlanRequest>& requests) 00333 { 00334 stage_names.clear(); 00335 ids.clear(); 00336 requests.clear(); 00337 mongo_ros::Query q = makeQueryForPlanningSceneId(planning_scene_id); 00338 std::vector<MotionPlanRequestWithMetadata> motion_plan_requests = motion_plan_request_collection_->pullAllResults(q, false); 00339 00340 for(size_t i = 0; i < motion_plan_requests.size(); i++) 00341 { 00342 stage_names.push_back(motion_plan_requests[i]->lookupString("stage_name")); 00343 ids.push_back(motion_plan_requests[i]->lookupInt(MOTION_PLAN_REQUEST_ID_NAME)); 00344 requests.push_back(*motion_plan_requests[i]); 00345 ROS_DEBUG_STREAM("Loading planning scene " << planning_scene_id << " motion plan request " << ids[i] << " from warehouse..."); 00346 } 00347 00348 return true; 00349 } 00350 00351 bool MoveArmWarehouseLoggerReader::getAssociatedJointTrajectorySources(const std::string& hostname, 00352 const unsigned int planning_scene_id, 00353 const unsigned int motion_request_id, 00354 std::vector<unsigned int>& ids, 00355 std::vector<std::string>& trajectory_sources) 00356 { 00357 ids.clear(); 00358 trajectory_sources.clear(); 00359 mongo_ros::Query q = makeQueryForPlanningSceneId(planning_scene_id); 00360 q.append(TRAJECTORY_MOTION_REQUEST_ID_NAME, motion_request_id); 00361 00362 std::vector<JointTrajectoryWithMetadata> joint_trajectories = trajectory_collection_->pullAllResults(q, true, TRAJECTORY_ID_NAME); 00363 00364 if(joint_trajectories.size() == 0) { 00365 ROS_WARN_STREAM("No joint trajectories with planning scene id " << planning_scene_id 00366 << " and motion plan id " << motion_request_id); 00367 return false; 00368 } 00369 ids.resize(joint_trajectories.size()); 00370 trajectory_sources.resize(joint_trajectories.size()); 00371 for(unsigned int i = 0; i < joint_trajectories.size(); i++) { 00372 trajectory_sources[i] = joint_trajectories[i]->lookupString("trajectory_source"); 00373 } 00374 return true; 00375 } 00376 00377 bool MoveArmWarehouseLoggerReader::getAssociatedJointTrajectory(const std::string& hostname, 00378 const unsigned int planning_scene_id, 00379 const unsigned int motion_request_id, 00380 const unsigned int trajectory_id, 00381 ros::Duration& duration, 00382 trajectory_msgs::JointTrajectory& joint_trajectory) 00383 { 00384 mongo_ros::Query q = makeQueryForPlanningSceneId(planning_scene_id); 00385 q.append(TRAJECTORY_MOTION_REQUEST_ID_NAME, motion_request_id); 00386 q.append(TRAJECTORY_ID_NAME, trajectory_id); 00387 std::vector<JointTrajectoryWithMetadata> joint_trajectories = trajectory_collection_->pullAllResults(q, false); 00388 00389 if(joint_trajectories.size() == 0) { 00390 ROS_WARN_STREAM("No joint trajectories with with planning scene id " << planning_scene_id 00391 << " and motion plan id " << motion_request_id 00392 << " and trajectory id " << trajectory_id); 00393 return false; 00394 } else if(joint_trajectories.size() > 1) { 00395 ROS_WARN_STREAM("Multiple trajectories in db with same ids"); 00396 return false; 00397 } 00398 00399 duration = ros::Duration(joint_trajectories[0]->lookupDouble("production_time")); 00400 joint_trajectory = *joint_trajectories[0]; 00401 return true; 00402 } 00403 00404 bool MoveArmWarehouseLoggerReader::getAssociatedJointTrajectories(const std::string& hostname, 00405 const unsigned int planning_scene_id, 00406 const unsigned int motion_request_id, 00407 std::vector<trajectory_msgs::JointTrajectory>& trajectories, 00408 std::vector<std::string>& sources, 00409 std::vector<unsigned int>& ids, 00410 std::vector<ros::Duration>& durations, 00411 std::vector<int32_t>& error_codes) 00412 { 00413 trajectories.clear(); 00414 sources.clear(); 00415 ids.clear(); 00416 durations.clear(); 00417 error_codes.clear(); 00418 mongo_ros::Query q = makeQueryForPlanningSceneId(planning_scene_id); 00419 q.append(TRAJECTORY_MOTION_REQUEST_ID_NAME, motion_request_id); 00420 std::vector<JointTrajectoryWithMetadata> joint_trajectories = trajectory_collection_->pullAllResults(q, false); 00421 00422 for(size_t i = 0; i < joint_trajectories.size(); i++) 00423 { 00424 trajectories.push_back(*joint_trajectories[i]); 00425 sources.push_back(joint_trajectories[i]->lookupString("trajectory_source")); 00426 ids.push_back(joint_trajectories[i]->lookupInt(TRAJECTORY_ID_NAME)); 00427 ROS_DEBUG_STREAM("Loading mpr id " << motion_request_id << " trajectory " << ids[i] << " from warehouse..."); 00428 durations.push_back(ros::Duration(joint_trajectories[i]->lookupDouble("production_time"))); 00429 error_codes.push_back(joint_trajectories[i]->lookupInt("trajectory_error_code")); 00430 } 00431 00432 return true; 00433 } 00434 00435 bool MoveArmWarehouseLoggerReader::getAssociatedPausedStates(const std::string& hostname, 00436 const unsigned int id, 00437 std::vector<ros::Time>& paused_times) 00438 { 00439 paused_times.clear(); 00440 mongo_ros::Query q = makeQueryForPlanningSceneId(id); 00441 std::vector<HeadMonitorFeedbackWithMetadata> paused_states = paused_state_collection_->pullAllResults(q, true, PLANNING_SCENE_ID_NAME); 00442 00443 if(paused_states.size() == 0) { 00444 return false; 00445 } 00446 paused_times.resize(paused_states.size()); 00447 for(unsigned int i = 0; i < paused_states.size(); i++) { 00448 paused_times[i] = ros::Time(paused_states[i]->lookupDouble("paused_collision_map_stamp")); 00449 } 00450 return true; 00451 } 00452 00453 bool MoveArmWarehouseLoggerReader::getAssociatedPausedState(const std::string& hostname, 00454 const unsigned int id, 00455 const ros::Time& paused_time, 00456 head_monitor_msgs::HeadMonitorFeedback& paused_state) 00457 { 00458 mongo_ros::Query q = makeQueryForPlanningSceneId(id); 00459 q.append(PAUSED_COLLISION_MAP_TIME_NAME, paused_time.toSec()); 00460 00461 std::vector<HeadMonitorFeedbackWithMetadata> paused_states = paused_state_collection_->pullAllResults(q, false); 00462 00463 if(paused_states.size() == 0) { 00464 ROS_WARN_STREAM("No paused states with that time"); 00465 return false; 00466 } else if(paused_states.size() > 1) { 00467 ROS_WARN_STREAM("Multiple paused states with time"); 00468 return false; 00469 } 00470 paused_state = *paused_states[0]; 00471 return true; 00472 } 00473 00474 bool MoveArmWarehouseLoggerReader::hasPlanningScene(const std::string& hostname, 00475 const unsigned int id) { 00476 mongo_ros::Query q = makeQueryForPlanningSceneId(id); 00477 q.append("hostname", hostname); 00478 00479 std::vector<PlanningSceneWithMetadata> planning_scenes = planning_scene_collection_->pullAllResults(q, true); 00480 if(planning_scenes.size() > 0) return true; 00481 return false; 00482 } 00483 00484 bool MoveArmWarehouseLoggerReader::removePlanningSceneAndAssociatedDataFromWarehouse(const std::string& hostname, 00485 const unsigned int id) { 00486 mongo_ros::Query q = makeQueryForPlanningSceneId(id); 00487 q.append("hostname", hostname); 00488 00489 unsigned int rem = planning_scene_collection_->removeMessages(q); 00490 ROS_DEBUG_STREAM("Removed " << rem << " planning scenes"); 00491 00492 bool has_planning_scene = (rem > 0); 00493 00494 rem = motion_plan_request_collection_->removeMessages(q); 00495 ROS_DEBUG_STREAM("Removed " << rem << " motion plan requests"); 00496 00497 rem = trajectory_collection_->removeMessages(q); 00498 ROS_DEBUG_STREAM("Removed " << rem << " trajectories"); 00499 00500 rem = outcome_collection_->removeMessages(q); 00501 ROS_DEBUG_STREAM("Removed " << rem << " outcomes"); 00502 00503 rem = paused_state_collection_->removeMessages(q); 00504 ROS_DEBUG_STREAM("Removed " << rem << " paused states"); 00505 00506 return has_planning_scene; 00507 } 00508 00509 // void MoveArmWarehouseLoggerReader::deleteMotionPlanRequestFromWarehouse(const arm_navigation_msgs::PlanningScene& planning_scene, 00510 // const std::string& stage_name, 00511 // const std::string& ID) 00512 // { 00513 // mongo_ros::Query q = makeQueryForPlanningSceneTime(time); 00514 // q.append("stage_name", stage_name); 00515 // q.append("motion_request_id", ID); 00516 // std::vector<MotionPlanRequestWithMetadata> motion_plan_requests = motion_plan_request_collection_->pullAllResults(q, false); 00517 // coll.removeMessages(q); 00518 // std::vector<MotionPlanRequestWithMetadata> motion_plan_requests_after = motion_plan_request_collection_->pullAllResults(q, false); 00519 // ROS_DEBUG_STREAM("Removing " << motion_plan_requests.size()-motion_plan_requests_after.size() << " motion plan requests"); 00520 // }