omni_global.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include <models/global_position/omni_global.h>
00026 #include <models/mirror/mirrormodel.h>
00027
00028
00029
00030
00031
00032
00033
00034
00035 OmniGlobal::OmniGlobal(MirrorModel *mirror_model)
00036 {
00037 this->mirror_model = mirror_model;
00038
00039 ball_x = ball_y = 0.f;
00040 }
00041
00042
00043 void
00044 OmniGlobal::set_position_in_image(unsigned int x, unsigned int y)
00045 {
00046 image_x = x;
00047 image_y = y;
00048 }
00049
00050
00051 void
00052 OmniGlobal::set_robot_position(float x, float y, float ori)
00053 {
00054 pose_x = x;
00055 pose_y = y;
00056 pose_ori = ori;
00057 }
00058
00059
00060 float
00061 OmniGlobal::get_y(void) const
00062 {
00063 return ball_y;
00064 }
00065
00066
00067 float
00068 OmniGlobal::get_x(void) const
00069 {
00070 return ball_x;
00071 }
00072
00073
00074 void
00075 OmniGlobal::calc()
00076 {
00077 if ( mirror_model->isValidPoint( image_x, image_y ) ) {
00078
00079 fawkes::cart_coord_2d_t glob_pos = mirror_model->getWorldPointGlobal( image_x,
00080 image_y,
00081 pose_x,
00082 pose_y,
00083 pose_ori);
00084
00085 ball_x = glob_pos.x;
00086 ball_y = glob_pos.y;
00087 }
00088 }
00089
00090
00091 bool
00092 OmniGlobal::is_pos_valid() const
00093 {
00094 return mirror_model->isValidPoint( image_x, image_y );
00095 }