8#ifndef VisionBall_DEFINED
9#define VisionBall_DEFINED
16#include <SimpleShapes.h>
34 PROPERTY(uint64_t, frameNumber)
40 PROPERTY(
bool, topVisible)
42 PROPERTY(
bool, bottomVisible)
44 PROPERTY(int16_t, pad)
47 VisionBall() : _frameNumber(0), _topBall(), _bottomBall() {
54 _frameNumber = a.frameNumber();
55 _topBall = a.topBall();
56 _bottomBall = a.bottomBall();
57 set_topVisible(a.topVisible());
58 set_bottomVisible(a.bottomVisible());
66 _frameNumber = ball.frameNumber();
67 _topBall = ball.topBall();
68 _bottomBall = ball.bottomBall();
69 set_topVisible(ball.topVisible());
70 set_bottomVisible(ball.bottomVisible());
75 std::bitset<2> objectMask;
76 objectMask[
Top] = _topVisible;
77 objectMask[
Bottom] = _bottomVisible;
87 topBall().set_x(ballInfo.GetCenter().x);
88 topBall().set_y(ballInfo.GetCenter().y);
89 topBall().set_radius(ballInfo.GetRadius());
93 bottomBall().set_x(ballInfo.GetCenter().x);
94 bottomBall().set_y(ballInfo.GetCenter().y);
95 bottomBall().set_radius(ballInfo.GetRadius());
97 set_bottomVisible(
true);
108 topBall().set_x(ballInfo.x());
109 topBall().set_y(ballInfo.y());
110 topBall().set_radius(ballInfo.radius());
111 set_topVisible(
true);
114 bottomBall().set_x(ballInfo.x());
115 bottomBall().set_y(ballInfo.y());
116 bottomBall().set_radius(ballInfo.radius());
117 set_bottomVisible(
true);
126 int16_t
topRadius()
const {
return topBall().radius(); }
132 int16_t
topX()
const {
return topBall().x(); }
138 int16_t
topY()
const {
return topBall().y(); }
150 int16_t
bottomX()
const {
return bottomBall().x(); }
156 int16_t
bottomY()
const {
return bottomBall().y(); }
162 bool visible() {
return topVisible() || bottomVisible(); }
170 return topBall().radius();
171 else if (bottomVisible())
172 return bottomBall().radius();
183 return topBall().x();
184 else if (bottomVisible())
185 return bottomBall().x();
196 return topBall().y();
197 else if (bottomVisible())
198 return bottomBall().y();
207 set_topVisible(
false);
208 set_bottomVisible(
false);
211#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
216#pragma clang diagnostic push
217#pragma clang diagnostic ignored "-Wc++98-compat"
233#pragma clang diagnostic pop
244 std::string command =
"BALL";
245 std::transform(s.begin(), s.end(), s.begin(), ::toupper);
246 while(n!=std::string::npos) {
247 n = s.find(command, n+4);
248 if (n!=std::string::npos && n>=3) {
249 std::string t = s.substr(n+command.length()+1);
250 SimpleCircle ballInfo;
252 if(s.substr(n-3, 3).find(
"TOP") != std::string::npos)
257 ballInfo.setCenter(t.c_str());
259 if (std::string::npos!=found )
260 { std::string strRadious=t.substr (found+1);
261 ballInfo.setRadius(
static_cast<u_int16_t>(::atoi(strRadious.c_str())));
266 std::string fnum =
"FRAMENUMBER";
268 if(n != std::string::npos) {
270 set_frameNumber(atol(s.substr(n+fnum.length()+1).c_str()));
279 std::stringstream result;
281 result <<
"TopBall:(" << topBall().x() <<
"," << topBall().y() <<
")"<<
SEPARATOR_IS_AT << topBall().radius();
284 result <<
"BottomBall:(" << bottomBall().x() <<
"," << bottomBall().y() <<
")"<<
SEPARATOR_IS_AT << bottomBall().radius();
286 result <<
"FrameNumber=" << frameNumber();
Whiteboard Class used by vision to report detect ball Reports balls detected in top or bottom camera,...
static const char SEPARATOR_IS_AT
USED INTERNALLY FOR STRING PARSER.
VisionBall(const char *s)
Const char array constructor.
int16_t bottomY() const
Center Y Position of the bottom ball.
VisionBall(std::string s)
String constructor.
void setBall(wb_ball ballInfo, VisionCamera camera)
Set the ball for this message for a specified camera.
int16_t topRadius() const
Radius of the top ball.
int16_t topY() const
Center Y Position of the top ball.
int16_t bottomRadius() const
Radius of the bottom ball.
int16_t topX() const
Center X Position of the top ball.
void from_string(std::string s)
Parse as string and set this object to the tokenized contents.
void Reset()
Set the top and bottom visible flags to false.
bool visible()
Return true if either the top or bottom ball is visible in this message.
int16_t bottomX() const
Center X Position of the bottom ball.
void setBall(SimpleCircle ballInfo, VisionCamera camera)
Set the ball for this message for a specified camera.
std::string description()
Description of the VisionBall object.
int16_t radius() const
Return the radius one of the balls.
VisionBall & operator=(const VisionBall &a)
Equals Operator sets the frame number as well as contents of top and bottom ball and there visibility...
int16_t y() const
Return the center y coordinate of one of the balls.
VisionBall()
Default Constructor.
VisionBall(const VisionBall &ball)
Const reference constructor, copys contents of passed object.
std::bitset< 2 > getMask() const
DEPRICATED.
int16_t x() const
Return the center x coordinate of one of the balls.
Whiteboard data structure for a ball sighting.
VisionCamera
Enum of available camera's that can be used by vision.
@ Bottom
Bottom Camera on the nao.
@ Top
Top Camera on the nao.