Fawkes API  Fawkes Development Version
omni_global.cpp
1 
2 /***************************************************************************
3  * omni_relative.cpp - Implementation of the relative ball model
4  * for the omni cam
5  *
6  * Created: Thu Mar 23 22:00:15 2006
7  * Copyright 2006-2008 Tim Niemueller [www.niemueller.de]
8  *
9  ****************************************************************************/
10 
11 /* This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version. A runtime exception applies to
15  * this software (see LICENSE.GPL_WRE file mentioned below for details).
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU Library General Public License for more details.
21  *
22  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
23  */
24 
25 #include <fvmodels/global_position/omni_global.h>
26 #include <fvmodels/mirror/mirrormodel.h>
27 
28 namespace firevision {
29 #if 0 /* just to make Emacs auto-indent happy */
30 }
31 #endif
32 
33 /** @class OmniGlobal <fvmodels/global_position/omni_global.h>
34  * Omni vision global position model.
35  */
36 
37 /** Constructor.
38  * @param mirror_model mirror model
39  */
41 {
42  this->mirror_model = mirror_model;
43 
44  ball_x = ball_y = 0.f;
45 }
46 
47 
48 void
49 OmniGlobal::set_position_in_image(unsigned int x, unsigned int y)
50 {
51  image_x = x;
52  image_y = y;
53 }
54 
55 
56 void
57 OmniGlobal::set_robot_position(float x, float y, float ori)
58 {
59  pose_x = x;
60  pose_y = y;
61  pose_ori = ori;
62 }
63 
64 
65 float
66 OmniGlobal::get_y(void) const
67 {
68  return ball_y;
69 }
70 
71 
72 float
73 OmniGlobal::get_x(void) const
74 {
75  return ball_x;
76 }
77 
78 
79 void
81 {
82  if ( mirror_model->isValidPoint( image_x, image_y ) ) {
83 
84  fawkes::cart_coord_2d_t glob_pos = mirror_model->getWorldPointGlobal( image_x,
85  image_y,
86  pose_x,
87  pose_y,
88  pose_ori);
89 
90  ball_x = glob_pos.x;
91  ball_y = glob_pos.y;
92  }
93 }
94 
95 
96 bool
98 {
99  return mirror_model->isValidPoint( image_x, image_y );
100 }
101 
102 } // end namespace firevision
Cartesian coordinates (2D).
Definition: types.h:59
virtual float get_x() const
Get global x coordinate of object.
Definition: omni_global.cpp:73
virtual void set_position_in_image(unsigned int x, unsigned int y)
Set the position of the object as recognized in the image.
Definition: omni_global.cpp:49
virtual bool is_pos_valid() const
Check if the position is valid.
Definition: omni_global.cpp:97
virtual float get_y() const
Get global y coordinate of object.
Definition: omni_global.cpp:66
virtual void set_robot_position(float x, float y, float ori)
Set the global position of the object.
Definition: omni_global.cpp:57
virtual bool isValidPoint(unsigned int image_x, unsigned int image_y) const =0
Check if the given point is valid.
Mirror model interface.
Definition: mirrormodel.h:34
OmniGlobal(MirrorModel *mirror_model)
Constructor.
Definition: omni_global.cpp:40
virtual fawkes::cart_coord_2d_t getWorldPointGlobal(unsigned int image_x, unsigned int image_y, float pose_x, float pose_y, float pose_ori) const =0
Get global coordinate based on image coordinates.
float y
y coordinate
Definition: types.h:61
virtual void calc()
Calculate position.
Definition: omni_global.cpp:80
float x
x coordinate
Definition: types.h:60