Fawkes API  Fawkes Development Version
globvelo.h
1 
2 /***************************************************************************
3  * globvelo.h - A simple velocity model using the global coordinates
4  *
5  * Created: Mon Sep 05 17:06:54 2005
6  * Copyright 2005 Tim Niemueller [www.niemueller.de]
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version. A runtime exception applies to
14  * this software (see LICENSE.GPL_WRE file mentioned below for details).
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Library General Public License for more details.
20  *
21  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22  */
23 
24 #ifndef _FIREVISION_MODELS_VELOCITY_GLOBAL_H_
25 #define _FIREVISION_MODELS_VELOCITY_GLOBAL_H_
26 
27 #include <fvmodels/global_position/globalpositionmodel.h>
28 #include <fvmodels/velocity/velocitymodel.h>
29 #include <sys/time.h>
30 
31 #include <vector>
32 
33 // include <utils/kalman_filter/ckalman_filter_2dim.h>
34 
35 namespace firevision {
36 
37 class VelocityFromGlobal : public VelocityModel
38 {
39 public:
40  VelocityFromGlobal(GlobalPositionModel *model,
41  unsigned int history_length,
42  unsigned int calc_interval);
44 
45  virtual const char *getName() const;
46 
47  virtual void setRobotPosition(float x, float y, float ori, timeval t);
48  virtual void setRobotVelocity(float vel_x, float vel_y, timeval t);
49  virtual void setPanTilt(float pan, float tilt);
50  virtual void setTime(timeval t);
51  virtual void setTimeNow();
52  virtual void getTime(long int *sec, long int *usec);
53 
54  virtual void getVelocity(float *vel_x, float *vel_y);
55 
56  virtual float getVelocityX();
57  virtual float getVelocityY();
58 
59  virtual void calc();
60  virtual void reset();
61 
62  virtual coordsys_type_t getCoordinateSystem();
63 
64 private:
65  GlobalPositionModel *global_pos_model;
66 
67  float robot_pos_x;
68  float robot_pos_y;
69  float robot_pos_ori;
70  float robot_pos_age;
71 
72  timeval now;
73  std::vector<timeval> last_time;
74 
75  unsigned int history_length;
76  unsigned int calc_interval;
77 
78  int diff_sec;
79  int diff_usec;
80 
81  float f_diff_sec;
82 
83  std::vector<float> last_x;
84  std::vector<float> last_y;
85 
86  float current_x;
87  float current_y;
88 
89  float diff_x;
90  float diff_y;
91 
92  float velocity_total_x;
93  float velocity_total_y;
94  float velocity_num;
95 
96  float velocity_x;
97  float velocity_y;
98 
99  /*
100  kalmanFilter2Dim *kalman_filter;
101 
102  void applyKalmanFilter();
103  */
104 };
105 
106 } // end namespace firevision
107 
108 #endif
firevision::VelocityFromGlobal::getVelocity
virtual void getVelocity(float *vel_x, float *vel_y)
Definition: globvelo.cpp:129
firevision::VelocityFromGlobal::getTime
virtual void getTime(long int *sec, long int *usec)
Definition: globvelo.cpp:122
firevision::VelocityFromGlobal::getCoordinateSystem
virtual coordsys_type_t getCoordinateSystem()
Returns the used coordinate system, must be either COORDSYS_ROBOT_CART or COORDSYS_ROBOT_WORLD.
Definition: globvelo.cpp:214
firevision::VelocityFromGlobal::VelocityFromGlobal
VelocityFromGlobal(GlobalPositionModel *model, unsigned int history_length, unsigned int calc_interval)
Constructor.
Definition: globvelo.cpp:48
firevision::VelocityFromGlobal::getName
virtual const char * getName() const
Definition: globvelo.cpp:208
firevision::VelocityFromGlobal::setTimeNow
virtual void setTimeNow()
Definition: globvelo.cpp:116
firevision::GlobalPositionModel
Definition: globalpositionmodel.h:37
firevision::VelocityFromGlobal::setTime
virtual void setTime(timeval t)
Definition: globvelo.cpp:109
firevision::VelocityFromGlobal::setRobotVelocity
virtual void setRobotVelocity(float vel_x, float vel_y, timeval t)
Definition: globvelo.cpp:104
firevision::VelocityFromGlobal::calc
virtual void calc()
Calculate velocity values from given data This method must be called after all relevent data (set*) h...
Definition: globvelo.cpp:152
firevision::VelocityFromGlobal::reset
virtual void reset()
Reset velocity model Must be called if ball is not visible at any time.
Definition: globvelo.cpp:202
firevision::VelocityFromGlobal::getVelocityX
virtual float getVelocityX()
Definition: globvelo.cpp:140
firevision::VelocityFromGlobal::setPanTilt
virtual void setPanTilt(float pan, float tilt)
Definition: globvelo.cpp:88
firevision::VelocityFromGlobal::setRobotPosition
virtual void setRobotPosition(float x, float y, float ori, timeval t)
Definition: globvelo.cpp:93
firevision::VelocityFromGlobal::~VelocityFromGlobal
virtual ~VelocityFromGlobal()
Destructor.
Definition: globvelo.cpp:83
firevision::VelocityFromGlobal::getVelocityY
virtual float getVelocityY()
Definition: globvelo.cpp:146