00001 /* 00002 * Copyright (C) 2012-2016 Open Source Robotics Foundation 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 * 00016 */ 00017 /* 00018 * Desc: ARIAC scorer. 00019 * Author: Deanna Hood 00020 */ 00021 #ifndef _ROS_ARIAC_SCORER_HH_ 00022 #define _ROS_ARIAC_SCORER_HH_ 00023 00024 #include <map> 00025 #include <string> 00026 00027 #include <ros/ros.h> 00028 00029 #include "osrf_gear/ARIAC.hh" 00030 #include "osrf_gear/AriacKitTray.h" 00031 #include <osrf_gear/Goal.h> 00032 #include <osrf_gear/KitTray.h> 00033 #include "osrf_gear/VacuumGripperState.h" 00034 00036 class AriacScorer 00037 { 00039 public: AriacScorer(); 00040 00042 public: virtual ~AriacScorer(); 00043 00045 public: void Update(double timeStep = 0.0); 00046 00050 public: ariac::GameScore GetGameScore(); 00051 00054 public: bool IsCurrentGoalComplete(); 00055 00058 public: ariac::GoalScore GetCurrentGoalScore(); 00059 00062 public: void AssignGoal(const ariac::Goal & goal); 00063 00067 public: ariac::GoalScore UnassignCurrentGoal(double timeTaken = 0.0); 00068 00073 public: bool GetTrayById(const ariac::TrayID_t & trayID, ariac::KitTray & kitTray); 00074 00076 public: ariac::TrayScore SubmitTray(const ariac::KitTray & tray); 00077 00079 protected: ariac::TrayScore ScoreTray(const ariac::KitTray & tray); 00080 00082 protected: void ScoreCurrentState(); 00083 00085 public: static void FillKitFromMsg(const osrf_gear::Kit & kitMsg, ariac::Kit & kit); 00086 00088 public: void OnGoalReceived(const osrf_gear::Goal::ConstPtr & goalMsg); 00089 00091 public: void OnTrayInfoReceived(const osrf_gear::KitTray::ConstPtr & trayMsg); 00092 00094 public: void OnGripperStateReceived(const osrf_gear::VacuumGripperState &stateMsg); 00095 00097 protected: std::map<ariac::TrayID_t, ariac::KitTray> kitTrays; 00098 00100 protected: mutable boost::mutex kitTraysMutex; 00101 00103 protected: ariac::Goal currentGoal; 00104 00106 protected: bool newTrayInfoReceived; 00107 00109 protected: bool newGoalReceived; 00110 00112 protected: bool isPartTravelling = false; 00113 00115 protected: ariac::Goal newGoal; 00116 00118 protected: ariac::ScoringParameters scoringParameters; 00119 00121 protected: ariac::GoalScore* goalScore; 00122 00124 protected: ariac::GameScore gameScore; 00125 00126 }; 00127 #endif 00128