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 
30 /** @class OmniGlobal <fvmodels/global_position/omni_global.h>
31  * Omni vision global position model.
32  */
33 
34 /** Constructor.
35  * @param mirror_model mirror model
36  */
37 OmniGlobal::OmniGlobal(MirrorModel *mirror_model)
38 {
39  this->mirror_model = mirror_model;
40 
41  ball_x = ball_y = 0.f;
42 }
43 
44 void
45 OmniGlobal::set_position_in_image(unsigned int x, unsigned int y)
46 {
47  image_x = x;
48  image_y = y;
49 }
50 
51 void
52 OmniGlobal::set_robot_position(float x, float y, float ori)
53 {
54  pose_x = x;
55  pose_y = y;
56  pose_ori = ori;
57 }
58 
59 float
60 OmniGlobal::get_y(void) const
61 {
62  return ball_y;
63 }
64 
65 float
66 OmniGlobal::get_x(void) const
67 {
68  return ball_x;
69 }
70 
71 void
73 {
74  if (mirror_model->isValidPoint(image_x, image_y)) {
75  fawkes::cart_coord_2d_t glob_pos =
76  mirror_model->getWorldPointGlobal(image_x, image_y, pose_x, pose_y, pose_ori);
77 
78  ball_x = glob_pos.x;
79  ball_y = glob_pos.y;
80  }
81 }
82 
83 bool
85 {
86  return mirror_model->isValidPoint(image_x, image_y);
87 }
88 
89 } // end namespace firevision
firevision::OmniGlobal::OmniGlobal
OmniGlobal(MirrorModel *mirror_model)
Constructor.
Definition: omni_global.cpp:42
fawkes::cart_coord_2d_struct::y
float y
y coordinate
Definition: types.h:66
firevision::OmniGlobal::set_robot_position
virtual void set_robot_position(float x, float y, float ori)
Definition: omni_global.cpp:57
firevision::OmniGlobal::calc
virtual void calc()
Definition: omni_global.cpp:77
fawkes::cart_coord_2d_struct
Cartesian coordinates (2D).
Definition: types.h:63
fawkes::cart_coord_2d_struct::x
float x
x coordinate
Definition: types.h:65
firevision::OmniGlobal::get_y
virtual float get_y() const
Definition: omni_global.cpp:65
firevision::OmniGlobal::set_position_in_image
virtual void set_position_in_image(unsigned int x, unsigned int y)
Definition: omni_global.cpp:50
firevision::MirrorModel::isValidPoint
virtual bool isValidPoint(unsigned int image_x, unsigned int image_y) const =0
firevision::OmniGlobal::is_pos_valid
virtual bool is_pos_valid() const
Definition: omni_global.cpp:89
firevision::MirrorModel::getWorldPointGlobal
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
firevision::OmniGlobal::get_x
virtual float get_x() const
Definition: omni_global.cpp:71