gusimplewhiteboard
FilteredArrayOneDimBall.hpp
Go to the documentation of this file.
1
2/*
3 * FilteredArrayOneDimBall.h
4 * gusimplewhiteboard
5 *
6 * Created by Vlad Estivill-Castro on 19/06/2014.
7 * Copyright (c) 2013, 2014 Vlad Estivill-Castro. All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 *
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 *
16 * 2. Redistributions in binary form must reproduce the above
17 * copyright notice, this list of conditions and the following
18 * disclaimer in the documentation and/or other materials
19 * provided with the distribution.
20 *
21 * 3. All advertising materials mentioning features or use of this
22 * software must display the following acknowledgement:
23 *
24 * This product includes software developed by Rene Hexel.
25 *
26 * 4. Neither the name of the author nor the names of contributors
27 * may be used to endorse or promote products derived from this
28 * software without specific prior written permission.
29 *
30 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
31 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
32 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
33 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
34 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
35 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
36 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
37 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
38 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
39 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
40 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41 *
42 * -----------------------------------------------------------------------
43 * This program is free software; you can redistribute it and/or
44 * modify it under the above terms or under the terms of the GNU
45 * General Public License as published by the Free Software Foundation;
46 * either version 2 of the License, or (at your option) any later version.
47 *
48 * This program is distributed in the hope that it will be useful,
49 * but WITHOUT ANY WARRANTY; without even the implied warranty of
50 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
51 * GNU General Public License for more details.
52 *
53 * You should have received a copy of the GNU General Public License
54 * along with this program; if not, see http://www.gnu.org/licenses/
55 * or write to the Free Software Foundation, Inc., 51 Franklin Street,
56 * Fifth Floor, Boston, MA 02110-1301, USA.
57 *
58 */
59
60#ifndef FilteredArrayOneDimBall_DEFINED
61#define FilteredArrayOneDimBall_DEFINED
62
63#include <cstdlib>
64#include <sstream>
65#include <gu_util.h>
68
69namespace guWhiteboard {
70
71
76{
77#define SEPARATOR_IS_COMMA ','
78#define SEPARATOR_IS_COLON ':'
79#define IS_VISIBLE_ID 'I'
80#define TOP_ID 'T'
81#define BOTTM_ID 'B'
82
83public:
86 { /* */ }
87
90 {
91 const FilteredVisionObject *fvo = dynamic_cast<const FilteredVisionObject *>(&obj);
93 }
94
95
96
99 {
100#ifdef DEBUG
101 assert(sizeof(*this) == sizeof(wb_filtered_arrayballsightings));
102#endif
103 memcpy(this, &other, sizeof(other));
104 }
105
108 {
109 memcpy(this, &other, sizeof(other));
110
111 return *this;
112 }
113
115 //class FilteredArrayOneDimSonar *objects() { return _objects; }
116
117
121 void set_objects(const class FilteredArrayOneDimBall *t_objects)
122 {
123 memcpy(wb_filtered_arrayballsightings::objects, t_objects, sizeof(this->objects()));
124 }
125
127 void set_object(const class FilteredOneDimObject &obj, enum FilteredVisionObjectType landmarkType = FVOBallTop)
128 {
130 }
131
134 {
135 return objects(landmarkType);
136 }
137
138#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
139
141 FilteredArrayOneDimBall(const std::string &names) { from_string(names); }
142
144 FilteredArrayOneDimBall(const char *names) { from_string(names); }
145
146
149 std::string description()
150 {
151 std::ostringstream ss;
152 for ( int i =FVOBallTop; i< FVO_NUM_CAMERAS; i++ )
153 {
154 FilteredBallObjectType landmarkType = FilteredBallObjectType(i);
155 switch (landmarkType )
156 {
158 break;
160 break;
161 case FVO_NUM_CAMERAS : mipal_warn( "ERROR:");
162 break;
163 }// switch
164 ss << get_object(landmarkType).description();
165 } //for
166 return ss.str();
167 }
168
170 void from_string(const std::string &str)
171 {
172 std::istringstream iss(str);
173 std::string token;
174
175 std::string top (1,TOP_ID); top+=SEPARATOR_IS_COLON;
176 std::string bottom (1,BOTTM_ID); bottom+=SEPARATOR_IS_COLON;
177
178 std::size_t found = str.find(top);
179 if (std::string::npos!=found )
180 { std::string strFortop=str.substr (found+top.size());
181 FilteredOneDimObject thetop(strFortop);
182 set_object(thetop,FVOBallTop);
183 }
184
185 found = str.find(bottom);
186 if (std::string::npos!=found )
187 { std::string strForbottom=str.substr (found+bottom.size());
188 FilteredOneDimObject thebottom(strForbottom);
189 set_object(thebottom,FVOBallBottom );
190 }
191
192 }
193#endif // WHITEBOARD_POSTER_STRING_CONVERSION
194
195
196
197};
198} // namespace
199
200
201#endif //FilteredArrayOneDimBall
#define BOTTM_ID
#define TOP_ID
#define SEPARATOR_IS_COLON
Provides a C++ wrapper around wb_filtered_arrayballsightings.
const FilteredVisionObject * objects() const
void set_objects(const FilteredVisionObject *t_newValue)
Class for for the array of ball sighthings TOP or Bottom.
void set_objects(const class FilteredArrayOneDimBall *t_objects)
property getter
FilteredArrayOneDimBall & operator=(const FilteredArrayOneDimBall &other)
copy assignment operator
FilteredArrayOneDimBall(const class FilteredOneDimObject &obj, enum FilteredVisionObjectType landmarkType=FVOBallTop)
constructor with one setter
FilteredOneDimObject get_object(enum FilteredVisionObjectType landmarkType=FVOBallTop)
single vision object setter
FilteredArrayOneDimBall(const std::string &names)
string constructor
void from_string(const std::string &str)
build from string
FilteredArrayOneDimBall(const FilteredArrayOneDimBall &other)
copy constructor
FilteredArrayOneDimBall(const char *names)
const char * constructor
void set_object(const class FilteredOneDimObject &obj, enum FilteredVisionObjectType landmarkType=FVOBallTop)
single vision object setter
std::string description()
convert to a string; string serialization
A class to contain objects that have been filtered through localisation.
std::string description() const
convert to a string
Provides a C++ wrapper around wb_filtered_vision_object.
/file APM_Interface.h
The class of landmarks filtered regarding goal sightings.
struct wb_filtered_vision_object objects[2]
the array containing filtered balls on separate cameras reported by vision FVO_NUM_CAMERAS =2
@ FVO_NUM_CAMERAS
number of different cameras
@ FVOBallTop
Filtered information ball on top camera.
@ FVOBallBottom
Filtered information ball on bottom camera.