#include <SelfLocalization.h>
|
| 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 () |
|
SelfLocalization::SelfLocalization |
( |
std::int32_t |
left_motor_sl, |
|
|
std::int32_t |
right_motor_sl, |
|
|
bool |
save = true |
|
) |
| |
SelfLocalization.cpp の 19 行目に定義があります。
21 : left(left_motor_sl), right(right_motor_sl)
24 between_wheels = 12.7;
25 moving_distance_mean = 0;
27 current_x = current_y = current_angle = 0;
bool SelfLocalization::approached_target_coordinates |
( |
float |
target_x, |
|
|
float |
target_y, |
|
|
float |
target_radius |
|
) |
| |
SelfLocalization.cpp の 72 行目に定義があります。
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;
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.cpp の 84 行目に定義があります。
90 a = _goal_y - _start_y;
91 b = -(_goal_x - _start_x);
92 c = -b * _start_y - a * _start_x;
94 return (a * _current_x + b * _current_y + c) / std::sqrt(a * a + b * b);
void SelfLocalization::calculate_current_angle |
( |
| ) |
|
void SelfLocalization::file_close |
( |
| ) |
|
float SelfLocalization::getPointX |
( |
| ) |
|
float SelfLocalization::getPointY |
( |
| ) |
|
void SelfLocalization::init_normal_vector |
( |
float |
_start_x, |
|
|
float |
_start_y, |
|
|
float |
_goal_x, |
|
|
float |
_goal_y, |
|
|
float |
_current_x, |
|
|
float |
_current_y |
|
) |
| |
bool SelfLocalization::is_below_target_line_of_x |
( |
float |
target_x | ) |
|
bool SelfLocalization::is_below_target_line_of_y |
( |
float |
target_y | ) |
|
bool SelfLocalization::is_over_normal_vector |
( |
float |
_current_x, |
|
|
float |
_current_y |
|
) |
| |
SelfLocalization.cpp の 133 行目に定義があります。
135 float k = (start_x - goal_x) / (goal_y - start_y);
136 float border_y = k * _current_x + goal_y - k * goal_x;
138 if(is_below_normal_vector) {
139 return _current_y >= border_y;
141 return _current_y < border_y;
bool SelfLocalization::is_over_target_line_of_x |
( |
float |
target_x | ) |
|
bool SelfLocalization::is_over_target_line_of_y |
( |
float |
target_y | ) |
|
void SelfLocalization::update |
( |
std::int32_t |
left_motor_sl, |
|
|
std::int32_t |
right_motor_sl |
|
) |
| |
SelfLocalization.cpp の 32 行目に定義があります。
35 left.
update(left_motor_sl);
38 right.
update(right_motor_sl);
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;
void writing_current_coordinates()
void update(std::int32_t left_motor, std::int32_t right_motor)
左右モータ角度の過去値を現在値へ更新する
void SelfLocalization::writing_current_coordinates |
( |
| ) |
|
int SelfLocalization::current_angle_degree |
このクラス詳解は次のファイルから抽出されました: