etrobocon2018 feat.KatLab  770af34cce41ae9c30c41303275e1add2daae0c3 (with uncommitted changes)
 全て クラス 名前空間 ファイル 関数 変数 列挙型 列挙値 フレンド マクロ定義 ページ
公開メンバ関数 | 公開変数類 | 全メンバ一覧
SelfLocalization クラス

#include <SelfLocalization.h>

SelfLocalization 連携図
Collaboration graph

公開メンバ関数

 SelfLocalization (std::int32_t left_motor_sl, std::int32_t right_motor_sl, bool save=true)
 
void update (std::int32_t left_motor_sl, std::int32_t right_motor_sl)
 
void writing_current_coordinates ()
 
bool approached_target_coordinates (float target_x, float target_y, float target_radius)
 
float getPointX ()
 
float getPointY ()
 
bool is_over_target_line_of_x (float target_x)
 
bool is_over_target_line_of_y (float target_y)
 
bool is_below_target_line_of_x (float target_x)
 
bool is_below_target_line_of_y (float target_y)
 
float calculate_between_ev3_and_border (float _start_x, float _start_y, float _goal_x, float _goal_y, float _current_x, float _current_y)
 
void file_close ()
 
void init_normal_vector (float _start_x, float _start_y, float _goal_x, float _goal_y, float _current_x, float _current_y)
 
bool is_over_normal_vector (float _current_x, float _current_y)
 
void calculate_current_angle ()
 

公開変数類

int current_angle_degree
 

詳解

SelfLocalization.h45 行目に定義があります。

構築子と解体子

SelfLocalization::SelfLocalization ( std::int32_t  left_motor_sl,
std::int32_t  right_motor_sl,
bool  save = true 
)

SelfLocalization.cpp19 行目に定義があります。

21  : left(left_motor_sl), right(right_motor_sl)
22 {
23  //メンバ変数の初期化 基本的に0
24  between_wheels = 12.7;
25  moving_distance_mean = 0;
26  turning_angle = 0;
27  current_x = current_y = current_angle = 0;
28  errno = 0;
29  isSave = save;
30 }

関数詳解

bool SelfLocalization::approached_target_coordinates ( float  target_x,
float  target_y,
float  target_radius 
)

SelfLocalization.cpp72 行目に定義があります。

74 {
75  float distance = std::sqrt((target_x - current_x) * (target_x - current_x)
76  + (target_y - current_y) * (target_y - current_y));
77  if(distance < target_radius) return true;
78  return false;
79 }
float SelfLocalization::calculate_between_ev3_and_border ( float  _start_x,
float  _start_y,
float  _goal_x,
float  _goal_y,
float  _current_x,
float  _current_y 
)

SelfLocalization.cpp84 行目に定義があります。

87 {
88  float a, b, c;
89 
90  a = _goal_y - _start_y;
91  b = -(_goal_x - _start_x);
92  c = -b * _start_y - a * _start_x;
93 
94  return (a * _current_x + b * _current_y + c) / std::sqrt(a * a + b * b);
95 }

被呼び出し関係図:

void SelfLocalization::calculate_current_angle ( )

SelfLocalization.cpp97 行目に定義があります。

98 {
99  current_angle_degree = int(current_angle * 180 / 3.14);
100 }

被呼び出し関係図:

void SelfLocalization::file_close ( )

SelfLocalization.cpp145 行目に定義があります。

146 {
147  fclose(fp);
148 }
float SelfLocalization::getPointX ( )

SelfLocalization.cpp55 行目に定義があります。

56 {
57  return current_x;
58 }

被呼び出し関係図:

float SelfLocalization::getPointY ( )

SelfLocalization.cpp60 行目に定義があります。

61 {
62  return current_y;
63 }

被呼び出し関係図:

void SelfLocalization::init_normal_vector ( float  _start_x,
float  _start_y,
float  _goal_x,
float  _goal_y,
float  _current_x,
float  _current_y 
)

SelfLocalization.cpp121 行目に定義があります。

123 {
124  start_x = _start_x;
125  start_y = _start_y;
126  goal_x = _goal_x;
127  goal_y = _goal_y;
128 
129  is_below_normal_vector = (start_y < goal_y);
130 }

被呼び出し関係図:

bool SelfLocalization::is_below_target_line_of_x ( float  target_x)

SelfLocalization.cpp111 行目に定義があります。

112 {
113  return target_x > current_x;
114 }
bool SelfLocalization::is_below_target_line_of_y ( float  target_y)

SelfLocalization.cpp115 行目に定義があります。

116 {
117  return target_y > current_y;
118 }
bool SelfLocalization::is_over_normal_vector ( float  _current_x,
float  _current_y 
)

SelfLocalization.cpp133 行目に定義があります。

134 {
135  float k = (start_x - goal_x) / (goal_y - start_y);
136  float border_y = k * _current_x + goal_y - k * goal_x;
137 
138  if(is_below_normal_vector) { // init時に機体が法線より下の場合
139  return _current_y >= border_y;
140  } else { // init時に機体が法線以上にある場合
141  return _current_y < border_y;
142  }
143 }

被呼び出し関係図:

bool SelfLocalization::is_over_target_line_of_x ( float  target_x)

SelfLocalization.cpp102 行目に定義があります。

103 {
104  return target_x < current_x;
105 }
bool SelfLocalization::is_over_target_line_of_y ( float  target_y)

SelfLocalization.cpp106 行目に定義があります。

107 {
108  return target_y < current_y;
109 }
void SelfLocalization::update ( std::int32_t  left_motor_sl,
std::int32_t  right_motor_sl 
)

SelfLocalization.cpp32 行目に定義があります。

33 {
34  //左車輪の回転角
35  left.update(left_motor_sl);
36 
37  //右車輪の回転角
38  right.update(right_motor_sl);
39 
40  //移動距離と、車体の回転角
41  moving_distance_mean = (right.moving_distance + left.moving_distance) / 2.0;
42  turning_angle = (right.moving_distance - left.moving_distance) / between_wheels;
43 
44  //座標
45  current_x += (moving_distance_mean * std::cos(current_angle + (turning_angle / 2.0)));
46  current_y += (moving_distance_mean * std::sin(current_angle + (turning_angle / 2.0)));
47  current_angle += turning_angle;
48 
49  //保存
50  if(isSave == true) {
52  }
53 }
void writing_current_coordinates()
float moving_distance
void update(std::int32_t left_motor, std::int32_t right_motor)
左右モータ角度の過去値を現在値へ更新する
Definition: MotorAngle.cpp:14

呼び出し関係図:

被呼び出し関係図:

void SelfLocalization::writing_current_coordinates ( )

SelfLocalization.cpp65 行目に定義があります。

66 {
67  fprintf(fp, "%f %f\n", current_x, current_y);
68 
69  return;
70 }

被呼び出し関係図:

メンバ詳解

int SelfLocalization::current_angle_degree

SelfLocalization.h60 行目に定義があります。


このクラス詳解は次のファイルから抽出されました: