25 #include <gazebo/gazebo.hh> 42 public:
friend std::ostream &
operator<<(std::ostream &_out,
45 _out <<
"<tray_score " << _obj.
trayID <<
">" << std::endl;
46 _out <<
"Total score: [" << _obj.
total() <<
"]" << std::endl;
47 _out <<
"Complete: [" << (_obj.
isComplete ?
"true" :
"false") <<
"]" << std::endl;
48 _out <<
"Part presence score: [" << _obj.
partPresence <<
"]" << std::endl;
49 _out <<
"All parts bonus: [" << _obj.
allPartsBonus <<
"]" << std::endl;
50 _out <<
"Part pose score: [" << _obj.
partPose <<
"]" << std::endl;
51 _out <<
"</tray_score>" << std::endl;
55 double partPresence = 0.0;
56 double allPartsBonus = 0.0;
57 double partPose = 0.0;
58 bool isComplete =
false;
63 return partPresence + allPartsBonus + partPose;
74 public:
friend std::ostream &
operator<<(std::ostream &_out,
77 _out <<
"<goal_score " << _obj.
goalID <<
">" << std::endl;
78 _out <<
"Total score: [" << _obj.
total() <<
"]" << std::endl;
79 _out <<
"Time taken: [" << _obj.
timeTaken <<
"]" << std::endl;
80 _out <<
"Complete: [" << (_obj.
isComplete() ?
"true" :
"false") <<
"]" << std::endl;
83 _out << item.second << std::endl;
85 _out <<
"</goal_score>" << std::endl;
96 double timeTaken = 0.0;
103 bool isGoalComplete = !this->trayScores.empty();
104 for (
const auto & item : this->trayScores)
106 isGoalComplete &= item.second.isComplete;
112 return isGoalComplete;
119 for (
const auto & item : this->trayScores)
121 total += item.second.total();
137 _out <<
"<game_score>" << std::endl;
138 _out <<
"Total score: [" << _obj.
total() <<
"]" << std::endl;
139 _out <<
"Total process time: [" << _obj.
totalProcessTime <<
"]" << std::endl;
140 _out <<
"Part travel time: [" << _obj.
partTravelTime <<
"]" << std::endl;
143 _out << item.second << std::endl;
145 _out <<
"</game_score>" << std::endl;
149 public:
double totalProcessTime = 0.0;
150 double partTravelTime = 0.0;
151 double planningTime = 0.0;
152 double partTravelDistance = 0.0;
153 double manipulatorTravelDistance = 0.0;
162 total += totalProcessTime;
163 total += partTravelTime;
164 total += planningTime;
165 total += partTravelDistance;
166 total += manipulatorTravelDistance;
168 for (
const auto & item : this->goalScores)
170 total += item.second.total();
200 return !(sp1 == sp2);
203 public:
double objectPresence = 1.0;
204 public:
double objectPosition = 0.0;
205 public:
double objectOrientation = 1.0;
208 public:
double allObjectsBonusFactor = 1.0;
213 public:
double distanceThresh = 0.03;
218 public:
double orientationThresh = 0.1;
224 TrayID_t modelType(modelName);
227 size_t index = modelType.find_last_of(
'|');
228 modelType = modelType.substr(index + 1);
231 index = modelType.find_last_not_of(
"0123456789");
232 if (modelType[index] ==
'_' && index > 1)
234 modelType = modelType.substr(0, index);
250 _out <<
"<object>" << std::endl;
251 _out <<
"Type: [" << _obj.
type <<
"]" << std::endl;
252 _out <<
"Pose: [" << _obj.
pose <<
"]" << std::endl;
253 _out <<
"</object>" << std::endl;
275 _out <<
"<kit type='" << _kit.
kitType <<
"'>";
276 for (
const auto & obj : _kit.
objects)
277 _out << std::endl << obj;
278 _out << std::endl <<
"</kit>" << std::endl;
298 return this->startTime < _goal.
startTime;
308 _out <<
"<Goal>" << std::endl;
309 _out <<
"Start time: [" << _goal.
startTime <<
"]" << std::endl;
310 _out <<
"Allowed time: [" << _goal.
allowedTime <<
"]" << std::endl;
311 _out <<
"Kits:" << std::endl;
312 for (
const auto & item : _goal.
kits)
314 _out << item.second << std::endl;
316 _out <<
"</goal>" << std::endl;
332 public: std::map<KitType_t, Kit>
kits;
std::vector< KitObject > objects
A kit is composed of multiple objects.
Class to store information about a goal.
double total() const
Calculate the total score.
friend std::ostream & operator<<(std::ostream &_out, const GameScore &_obj)
Stream insertion operator.
std::map< TrayID_t, TrayScore > trayScores
Mapping between tray IDs and scores.
double timeTaken
Simulation time in seconds spent on this goal.
std::string type
Object type.
double total() const
Calculate the total score.
math::Pose pose
Pose in which the object should be placed.
friend std::ostream & operator<<(std::ostream &_out, const GoalScore &_obj)
Stream insertion operator.
Class to store information about each object contained in a kit.
The parameters used for scoring the competition.
double allowedTime
Simulation time in seconds permitted for the goal to be completed before cancelling it...
std::map< KitType_t, Kit > kits
A goal is composed of multiple kits of different types.
bool isComplete() const
Calculate if the goal is complete.
The score of a competition run.
double timeTaken
Time in seconds spend on the goal.
friend std::ostream & operator<<(std::ostream &_out, const KitObject &_obj)
Stream insertion operator.
bool operator<(const Goal &_goal) const
Less than operator.
std::map< GoalID_t, GoalScore > goalScores
friend std::ostream & operator<<(std::ostream &_out, const Kit &_kit)
Stream insertion operator.
double total() const
Calculate the total score.
GoalID_t goalID
The ID of this goal.
friend std::ostream & operator<<(std::ostream &_out, const Goal &_goal)
Stream insertion operator.
friend bool operator==(const ScoringParameters &sp1, const ScoringParameters &sp2)
Equality comparison operator.
double allObjectsBonusFactor
double startTime
Simulation time in which the goal should be triggered.
GoalID_t goalID
ID of the goal being scored.
TrayID_t DetermineModelType(const std::string &modelName)
Determine the type of a gazebo model from its name.
friend bool operator!=(const ScoringParameters &sp1, const ScoringParameters &sp2)
Inequality comparison operator.
Class to store information about a kit.
KitType_t kitType
The type of the kit.
friend std::ostream & operator<<(std::ostream &_out, const TrayScore &_obj)
Stream insertion operator.