Fawkes API  Fawkes Development Version
ball_trigo.h
00001 
00002 /****************************************************************************
00003  *  ball_trigo.h - Ball relpos for pan/tilt camera using basic trigonometry
00004  *
00005  *  Created: Mon Mar 23 09:39:26 2009
00006  *  Copyright  2009  Tim Niemueller [www.niemueller.de]
00007  *
00008  ****************************************************************************/
00009 
00010 /*  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version. A runtime exception applies to
00014  *  this software (see LICENSE.GPL_WRE file mentioned below for details).
00015  *
00016  *  This program is distributed in the hope that it will be useful,
00017  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  *  GNU Library General Public License for more details.
00020  *
00021  *  Read the full text in the LICENSE.GPL_WRE file in the doc directory.
00022  */
00023 
00024 #ifndef __FIREVISION_MODELS_RELATIVE_POSITION_BALL_TRIGO_H_
00025 #define __FIREVISION_MODELS_RELATIVE_POSITION_BALL_TRIGO_H_
00026 
00027 #include <fvmodels/relative_position/relativepositionmodel.h>
00028 
00029 namespace firevision {
00030 #if 0 /* just to make Emacs auto-indent happy */
00031 }
00032 #endif
00033 
00034 class BallTrigoRelativePos : public RelativePositionModel
00035 {
00036  public:
00037   BallTrigoRelativePos(unsigned int image_width,
00038                        unsigned int image_height,
00039                        float camera_height,
00040                        float camera_offset_x,
00041                        float camera_offset_y,
00042                        float camera_base_pan,
00043                        float camera_base_tilt,
00044                        float horizontal_angle,
00045                        float vertical_angle,
00046                        float ball_circumference);
00047 
00048   virtual const char *  get_name() const;
00049   virtual void          set_radius(float r);
00050   virtual void          set_center(float x, float y);
00051   virtual void          set_center(const center_in_roi_t& c);
00052 
00053   virtual void          set_pan_tilt(float pan = 0.0f, float tilt = 0.0f);
00054   virtual void          get_pan_tilt(float *pan, float *tilt) const;
00055 
00056   virtual float         get_distance() const;
00057   virtual float         get_x() const;
00058   virtual float         get_y() const;
00059   virtual float         get_bearing() const;
00060   virtual float         get_slope() const;
00061 
00062   virtual void          calc();
00063   virtual void          calc_unfiltered() { calc(); }
00064   virtual void          reset();
00065 
00066   virtual bool          is_pos_valid() const;
00067 
00068 private:
00069   center_in_roi_t       __cirt_center;
00070   float                 __pan;
00071   float                 __tilt;
00072 
00073   float                 __horizontal_angle;
00074   float                 __vertical_angle;
00075   float                 __pan_rad_per_pixel;
00076   float                 __tilt_rad_per_pixel;
00077 
00078   unsigned int          __image_width;
00079   unsigned int          __image_width_2;  // image_width / 2
00080   unsigned int          __image_height;
00081   unsigned int          __image_height_2; // image_height / 2
00082 
00083   float                 __camera_height;
00084   float                 __camera_offset_x;
00085   float                 __camera_offset_y;
00086   float                 __camera_base_pan;
00087   float                 __camera_base_tilt;
00088 
00089   float                 __ball_circumference;
00090   float                 __ball_radius;
00091   float                 __ball_x;
00092   float                 __ball_y;
00093   float                 __bearing;
00094   float                 __slope;
00095   float                 __distance;
00096 };
00097 
00098 } // end namespace firevision
00099 
00100 #endif