ETrobocon2017 - 片山研究所モデルベース開発推進事業部
SelfLocalization.h
[詳解]
1 /*****************************
2  * self_localization.h
3  *
4  * Author Hiroki Tachiyama
5  * Katayama Laboratory
6  * Department of Computer Secience and Systems Engineering
7  * Faculty of Engineering, University of Miyazaki
8  *
9  * Created at: Fri Jul 7 23:07:58 JST 2017
10  *
11  * Coryrights (c) 2017 Katayama Laboratory
12  *
13  *****************************/
14 #ifndef __SELF_LOCALIZATION__
15 #define __SELF_LOCALIZATION__
16 
17 #include <cstdio>
18 #include <cstdint>
19 #include <cmath>
20 #include <cerrno>
21 
22 class MotorAngle{
23 public:
24  std::int32_t current_angle;
25  std::int32_t old_angle;
26  std::int32_t rotation_angle;
28  float wheel_across;
29  MotorAngle(std::int32_t degree){
30  rotation_angle = 0;
31  wheel_across = 8.2;
32  moving_distance = 0;
33  old_angle = current_angle = degree;
34  }
35  void update(std::int32_t update_degree){
36  old_angle = current_angle;
37  current_angle = update_degree;
38  rotation_angle = current_angle - old_angle;
39  moving_distance = wheel_across * M_PI * (rotation_angle / 360.0);
40  }
41 };
42 
44 private:
45  MotorAngle left, right;
46  float between_wheels;
47  float moving_distance_mean;
48  float turning_angle;
49  float current_x, current_y, current_angle;
50  bool is_below_of_normal_border;
51  float start_x, start_y, goal_x, goal_y;
52  static FILE* fp;
53  static bool isSave;
54  bool is_below_normal_vector;
55 
56 
57  //member methods
58 public:
60  SelfLocalization (std::int32_t left_motor_sl, std::int32_t right_motor_sl, bool save = true);
61  void update (std::int32_t left_motor_sl, std::int32_t right_motor_sl);
62  void writing_current_coordinates ();
63  bool approached_target_coordinates (float target_x, float target_y, float target_radius);
64  float getPointX();
65  float getPointY();
66  bool is_over_target_line_of_x (float target_x);
67  bool is_over_target_line_of_y (float target_y);
68  bool is_below_target_line_of_x(float target_x);
69  bool is_below_target_line_of_y(float target_y);
70  float calculate_between_ev3_and_border
71  (float _start_x, float _start_y, float _goal_x, float _goal_y, float _current_x, float _current_y);
72  void file_close();
73  void init_normal_vector(float _start_x, float _start_y, float _goal_x, float _goal_y, float _current_x, float _current_y);
74  bool is_over_normal_vector(float _current_x, float _current_y);
75  void calculate_current_angle();
76 private:
77  //残りのメソッドかな?
78 
79 };
80 
81 #endif
std::int32_t rotation_angle
float wheel_across
void update(std::int32_t update_degree)
float moving_distance
std::int32_t old_angle
MotorAngle(std::int32_t degree)
std::int32_t current_angle