move_arm_warehouse_logger_reader.h
Go to the documentation of this file.
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 #ifndef MOVE_ARM_WAREHOUSE_LOGGER_H_
00039 #define MOVE_ARM_WAREHOUSE_LOGGER_H_
00040 
00041 #include <mongo_ros/message_collection.h>
00042 
00043 #include <arm_navigation_msgs/PlanningScene.h>
00044 #include <arm_navigation_msgs/MotionPlanRequest.h>
00045 #include <arm_navigation_msgs/ArmNavigationErrorCodes.h>
00046 #include <trajectory_msgs/JointTrajectory.h>
00047 #include <head_monitor_msgs/HeadMonitorFeedback.h>
00048 
00049 namespace move_arm_warehouse
00050 {
00051 
00052 class MoveArmWarehouseLoggerReader {
00053   
00054 public:
00055 
00056   MoveArmWarehouseLoggerReader();
00057 
00058   ~MoveArmWarehouseLoggerReader();
00059 
00060   const std::string& getHostname() const {
00061     return hostname_;
00062   }
00063 
00067 
00068   void pushPlanningSceneToWarehouseWithoutId(const arm_navigation_msgs::PlanningScene& planning_scene,
00069                                     unsigned int& id); 
00070 
00071   void pushPlanningSceneToWarehouse(const arm_navigation_msgs::PlanningScene& planning_scene,
00072                                     const unsigned int ID);
00073   
00074   void pushMotionPlanRequestToWarehouse(const unsigned int planning_id, 
00075                                         const unsigned int mpr_id, 
00076                                         const std::string& stage_name,
00077                                         const arm_navigation_msgs::MotionPlanRequest& motion_plan_request);
00078     
00079   void pushJointTrajectoryToWarehouse(const unsigned int id,
00080                                       const std::string& trajectory_source,
00081                                       const ros::Duration& production_time, 
00082                                       const trajectory_msgs::JointTrajectory& trajectory,
00083                                       const trajectory_msgs::JointTrajectory& trajectory_control_error,
00084                                       const unsigned int ID,
00085                                       const unsigned int motion_plan_ID,
00086                                       const arm_navigation_msgs::ArmNavigationErrorCodes& error_code);
00087     
00088   void pushOutcomeToWarehouse(const unsigned int id,
00089                               const std::string& pipeline_stage,
00090                               const arm_navigation_msgs::ArmNavigationErrorCodes& error_codes);
00091   
00092   void pushPausedStateToWarehouse(const unsigned int id,
00093                                   const head_monitor_msgs::HeadMonitorFeedback& feedback);
00094 
00098 
00099   void getAvailablePlanningSceneList(const std::string& hostname, 
00100                                      std::vector<unsigned int>& planning_scene_ids_,
00101                                      std::vector<ros::Time>& creation_times);
00102 
00103   bool getPlanningScene(const std::string& hostname,
00104                         const unsigned int& id,
00105                         arm_navigation_msgs::PlanningScene& planning_scene,
00106                         std::string& hostname_out);
00107 
00108   bool getAssociatedOutcomes(const std::string& hostname,
00109                              const unsigned int planning_scene_id,
00110                              std::vector<std::string>& pipeline_names,
00111                              std::vector<arm_navigation_msgs::ArmNavigationErrorCodes>& error_codes);
00112 
00113   bool getAssociatedMotionPlanRequestsStageNames(const std::string& hostname, 
00114                                                  const unsigned int id, 
00115                                                  std::vector<std::string>& stage_names);
00116 
00117   bool getAssociatedMotionPlanRequest(const std::string& hostname, 
00118                                       const unsigned int planning_scene_id, 
00119                                       const unsigned int motion_plan_id, 
00120                                       arm_navigation_msgs::MotionPlanRequest& request);
00121 
00122   bool getAssociatedMotionPlanRequests(const std::string& hostname,
00123                                        const unsigned int planning_scene_id,
00124                                        std::vector<unsigned int>& IDs,
00125                                        std::vector<std::string>& stage_names,
00126                                        std::vector<arm_navigation_msgs::MotionPlanRequest>& requests);
00127 
00128   bool getAssociatedJointTrajectorySources(const std::string& hostname, 
00129                                            const unsigned int planning_scene_id,
00130                                            const unsigned int motion_request_id,
00131                                            std::vector<unsigned int>& ids,
00132                                            std::vector<std::string>& trajectory_sources);
00133 
00134   bool getAssociatedJointTrajectory(const std::string& hostname, 
00135                                     const unsigned int planning_scene_id,
00136                                     const unsigned int motion_plan_id,
00137                                     const unsigned int trajectory_id,
00138                                     ros::Duration& processing_time, 
00139                                     trajectory_msgs::JointTrajectory& joint_trajectory,
00140                                     trajectory_msgs::JointTrajectory& trajectory_control_error);
00141 
00142   bool getAssociatedJointTrajectories(const std::string& hostname,
00143                                       const unsigned int planning_scene_id,
00144                                       const unsigned int motion_plan_id,
00145                                       std::vector<trajectory_msgs::JointTrajectory>& trajectories,
00146                                       std::vector<trajectory_msgs::JointTrajectory>& trajectory_control_errors,
00147                                       std::vector<std::string>& sources,
00148                                       std::vector<unsigned int>& IDs,
00149                                       std::vector<ros::Duration>& durations,
00150                                       std::vector<int32_t>& error_codes);
00151 
00152   bool getAssociatedPausedStates(const std::string& hostname, 
00153                                  const unsigned int planning_scene_id,
00154                                  std::vector<ros::Time>& paused_times);
00155 
00156   bool getAssociatedPausedState(const std::string& hostname, 
00157                                 const unsigned int planning_scene_id,
00158                                 const ros::Time& paused_time,
00159                                 head_monitor_msgs::HeadMonitorFeedback& paused_state);
00160 
00161   bool hasPlanningScene(const std::string& hostname,
00162                         const unsigned int id);
00163 
00164   bool removePlanningSceneAndAssociatedDataFromWarehouse(const std::string& hostname,
00165                                                          const unsigned int id);
00166 
00167   unsigned int determineNextPlanningSceneId();
00168 
00169 protected:
00170   
00171   mongo_ros::Metadata initializeMetadataWithHostname();
00172 
00173   void addPlanningSceneTimeToMetadata(const arm_navigation_msgs::PlanningScene& planning_scene, mongo_ros::Metadata& metadata);
00174   void addPlanningSceneIdToMetadata(const unsigned int& id,
00175                                     mongo_ros::Metadata& metadata);
00176 
00177 
00178   mongo_ros::Query makeQueryForPlanningSceneTime(const ros::Time& time);
00179   mongo_ros::Query makeQueryForPlanningSceneId(const unsigned int id);
00180 
00181   // convenience functions for converting control error data
00182   std::string jointTrajectoryToString(const trajectory_msgs::JointTrajectory& trajectory);
00183   void stringToJointTrajectory(const std::string& trajectory, trajectory_msgs::JointTrajectory& joint_trajectory);
00184 
00185   mongo_ros::MessageCollection<arm_navigation_msgs::PlanningScene>* planning_scene_collection_;
00186   mongo_ros::MessageCollection<arm_navigation_msgs::MotionPlanRequest>* motion_plan_request_collection_;
00187   mongo_ros::MessageCollection<trajectory_msgs::JointTrajectory>* trajectory_collection_;
00188   mongo_ros::MessageCollection<arm_navigation_msgs::ArmNavigationErrorCodes>* outcome_collection_;
00189   mongo_ros::MessageCollection<head_monitor_msgs::HeadMonitorFeedback>* paused_state_collection_;
00190   
00191   std::string hostname_;
00192   
00193 };
00194 
00195 }
00196 #endif


move_arm_warehouse
Author(s): Ioan Sucan, Sachin Chitta(sachinc@willowgarage.com)
autogenerated on Thu Dec 12 2013 11:09:11