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
28namespace 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 */
38{
39 this->mirror_model = mirror_model;
40
41 ball_x = ball_y = 0.f;
42}
43
44void
45OmniGlobal::set_position_in_image(unsigned int x, unsigned int y)
46{
47 image_x = x;
48 image_y = y;
49}
50
51void
52OmniGlobal::set_robot_position(float x, float y, float ori)
53{
54 pose_x = x;
55 pose_y = y;
56 pose_ori = ori;
57}
58
59float
61{
62 return ball_y;
63}
64
65float
67{
68 return ball_x;
69}
70
71void
73{
74 if (mirror_model->isValidPoint(image_x, image_y)) {
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
83bool
85{
86 return mirror_model->isValidPoint(image_x, image_y);
87}
88
89} // end namespace firevision
Mirror model interface.
Definition: mirrormodel.h:32
virtual bool isValidPoint(unsigned int image_x, unsigned int image_y) const =0
Check if the given point is valid.
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.
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:45
virtual void calc()
Calculate position.
Definition: omni_global.cpp:72
virtual bool is_pos_valid() const
Check if the position is valid.
Definition: omni_global.cpp:84
virtual void set_robot_position(float x, float y, float ori)
Set the global position of the object.
Definition: omni_global.cpp:52
virtual float get_x() const
Get global x coordinate of object.
Definition: omni_global.cpp:66
virtual float get_y() const
Get global y coordinate of object.
Definition: omni_global.cpp:60
OmniGlobal(MirrorModel *mirror_model)
Constructor.
Definition: omni_global.cpp:37
Cartesian coordinates (2D).
Definition: types.h:65
float y
y coordinate
Definition: types.h:67
float x
x coordinate
Definition: types.h:66