8#ifndef VisionGoals_DEFINED
9#define VisionGoals_DEFINED
11#include <SimpleShapes.h>
47 VisionGoals() : topLeft(), topRight(), bottomLeft(), bottomRight(), _frameNumber(0) {
66 size_t n =
static_cast<size_t>(-8);
67 std::string command =
"LEFTPOST";
68 std::transform(s.begin(), s.end(), s.begin(), ::toupper);
69 while(n!=std::string::npos) {
70 n = s.find(command, n+8);
71 if (n!=std::string::npos) {
72 std::string t = s.substr(n+command.length()+1);
75 if(s.substr(n-3, 3).find(
"TOP") != std::string::npos)
80 std::vector<std::string> com = components_of_string_separated(t,
'(');
81 GUPoint<int16_t> _bottomLeft(com.at(1).c_str());
82 GUPoint<int16_t> _topLeft(com.at(2).c_str());
83 GUPoint<int16_t> _bottomRight(com.at(3).c_str());
84 GUPoint<int16_t> _topRight(com.at(4).c_str());
86 postInfo.set_bottomLeft_X(_bottomLeft.x);
87 postInfo.set_bottomLeft_Y(_bottomLeft.y);
89 postInfo.set_topLeft_X(_topLeft.x);
90 postInfo.set_topLeft_Y(_topLeft.y);
92 postInfo.set_bottomRight_X(_bottomRight.x);
93 postInfo.set_bottomRight_Y(_bottomRight.y);
95 postInfo.set_topRight_X(_topRight.x);
96 postInfo.set_topRight_X(_topRight.y);
102 n =
static_cast<size_t>(-8);
103 command =
"RIGHTPOST";
104 std::transform(s.begin(), s.end(), s.begin(), ::toupper);
105 while(n!=std::string::npos) {
106 n = s.find(command, n+8);
107 if (n!=std::string::npos) {
108 std::string t = s.substr(n+command.length()+1);
111 if(s.substr(n-3, 3).find(
"TOP") != std::string::npos)
116 std::vector<std::string> com = components_of_string_separated(t,
'(');
117 GUPoint<int16_t> _bottomLeft(com.at(1).c_str());
118 GUPoint<int16_t> _topLeft(com.at(2).c_str());
119 GUPoint<int16_t> _bottomRight(com.at(3).c_str());
120 GUPoint<int16_t> _topRight(com.at(4).c_str());
122 postInfo.set_bottomLeft_X(_bottomLeft.x);
123 postInfo.set_bottomLeft_Y(_bottomLeft.y);
125 postInfo.set_topLeft_X(_topLeft.x);
126 postInfo.set_topLeft_Y(_topLeft.y);
128 postInfo.set_bottomRight_X(_bottomRight.x);
129 postInfo.set_bottomRight_Y(_bottomRight.y);
131 postInfo.set_topRight_X(_topRight.x);
132 postInfo.set_topRight_Y(_topRight.y);
146 topLeft.set_visible(
true);
149 bottomLeft = postInfo;
150 bottomLeft.set_visible(
true);
162 topRight.set_visible(
true);
165 bottomRight = postInfo;
166 bottomRight.set_visible(
true);
177 topGeneric = postInfo;
178 topGeneric.set_visible(
true);
181 bottomGeneric = postInfo;
182 bottomGeneric.set_visible(
true);
222 return bottomGeneric;
261 return bottomGeneric;
268 topLeft.set_visible(
false);
269 topRight.set_visible(
false);
270 topGeneric.set_visible(
false);
271 bottomLeft.set_visible(
false);
272 bottomRight.set_visible(
false);
273 bottomGeneric.set_visible(
false);
297 std::stringstream result;
299 if(bottomLeft.visible())
300 result <<
"BottomLeftPost:(" << bottomLeft.bottomLeft_X() <<
"," << bottomLeft.bottomLeft_Y() <<
")("
301 << bottomLeft.topLeft_X() <<
"," << bottomLeft.topLeft_Y() <<
")("
302 << bottomLeft.bottomRight_X() <<
"," << bottomLeft.bottomRight_Y() <<
")("
303 << bottomLeft.topRight_X() <<
"," << bottomLeft.topRight_Y() <<
") ";
304 if(topLeft.visible())
305 result <<
"TopLeftPost:(" << topLeft.bottomLeft_X() <<
"," << topLeft.bottomLeft_Y() <<
")("
306 << topLeft.topLeft_X() <<
"," << topLeft.topLeft_Y() <<
")("
307 << topLeft.bottomRight_X() <<
"," << topLeft.bottomRight_Y() <<
")("
308 << topLeft.topRight_X() <<
"," << topLeft.topRight_Y() <<
") ";
309 if(topGeneric.visible())
310 result <<
"TopGenericPost:(" << topGeneric.bottomLeft_X() <<
"," << topGeneric.bottomLeft_Y() <<
")("
311 << topGeneric.topLeft_X() <<
"," << topGeneric.topLeft_Y() <<
")("
312 << topGeneric.bottomRight_X() <<
"," << topGeneric.bottomRight_Y() <<
")("
313 << topGeneric.topRight_X() <<
"," << topGeneric.topRight_Y() <<
") ";
314 if(bottomRight.visible())
315 result <<
"BottomRightPost:(" << bottomRight.bottomLeft_X() <<
"," << bottomRight.bottomLeft_Y() <<
")("
316 << bottomRight.topLeft_X() <<
"," << bottomRight.topLeft_Y() <<
")("
317 << bottomRight.bottomRight_X() <<
"," << bottomRight.bottomRight_Y() <<
")("
318 << bottomRight.topRight_X() <<
"," << bottomRight.topRight_Y() <<
") ";
319 if(topRight.visible())
320 result <<
"TopRightPost:(" << topRight.bottomLeft_X() <<
"," << topRight.bottomLeft_Y() <<
")("
321 << topRight.topLeft_X() <<
"," << topRight.topLeft_Y() <<
")("
322 << topRight.bottomRight_X() <<
"," << topRight.bottomRight_Y() <<
")("
323 << topRight.topRight_X() <<
"," << topRight.topRight_Y() <<
") ";
324 if(bottomGeneric.visible())
325 result <<
"BottomGenericPost:(" << bottomGeneric.bottomLeft_X() <<
"," << bottomGeneric.bottomLeft_Y() <<
")("
326 << bottomGeneric.topLeft_X() <<
"," << bottomGeneric.topLeft_Y() <<
")("
327 << bottomGeneric.bottomRight_X() <<
"," << bottomGeneric.bottomRight_Y() <<
")("
328 << bottomGeneric.topRight_X() <<
"," << bottomGeneric.topRight_Y() <<
") ";
Class to post information about goal posts detected from vision This class contains information the d...
void setRightGoalPost(wb_goal postInfo, VisionCamera camera)
Set the right goal post for this VisionGoal message.
wb_goal & leftPost(VisionCamera camera)
Get the current left goal post for this message.
const wb_goal & rightPost(VisionCamera camera) const
Get the current right goal post for this message.
void from_string(std::string &s)
void setGenericGoalPost(wb_goal postInfo, VisionCamera camera)
Set the generic goal post for this VisionGoal message.
std::string description()
Converts this message into a serialized string.
void setLeftGoalPost(wb_goal postInfo, VisionCamera camera)
Set the left goal post for this VisionGoal message.
VisionGoals()
Default Constructor.
void Reset()
Reset the visible flag for all four different posts to false.
VisionGoals(std::string s)
String Constructor Converts a serialized string to a VisionGoal object.
void setFrameNumber(size_t fn)
Sets the frame number this information in this message was observed.
size_t frameNumber() const
Get the frame number the information in this message was observed.
wb_goal & genericPost(VisionCamera camera)
Get the current generic goal post for this message.
wb_goal & rightPost(VisionCamera camera)
Get the current right goal post for this message.
const wb_goal & leftPost(VisionCamera camera) const
Get the current left goal post for this message.
const wb_goal & genericPost(VisionCamera camera) const
Get the current generic goal post for this message.
Whiteboard structure for goal coordinates X and Y coordinates are posted as seen in the image X range...
VisionCamera
Enum of available camera's that can be used by vision.
@ Bottom
Bottom Camera on the nao.
@ Top
Top Camera on the nao.