陀螺仪的初级数据获取

This commit is contained in:
bmy
2023-12-22 15:24:39 +08:00
parent 8feb4bab66
commit 2dffcf04f0
7 changed files with 106 additions and 36 deletions

View File

@@ -37,9 +37,10 @@
#include "cw_servo.h"
#include "by_pt_button.h"
#include "by_fan_control.h"
#include "by_imu.h"
uint8 (*Img_Gray)[MT9V03X_W]; // <20><><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD> MT9V03X_W <20>е<EFBFBD> uint8 <20><><EFBFBD>͵Ķ<CDB5>ά<EFBFBD><CEAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>
//uint8 *mt9v03x_image_copy[0]; // <20><><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8> uint8 <20><><EFBFBD>͵<EFBFBD>һά<D2BB><CEAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>
// uint8 *mt9v03x_image_copy[0]; // <20><><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8> uint8 <20><><EFBFBD>͵<EFBFBD>һά<D2BB><CEAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>
sint32 pts_left[PT_MAXLEN][2], pts_right[PT_MAXLEN][2];
sint32 pts_left_count, pts_right_count;
float32 pts_inv_l[PT_MAXLEN][2], pts_inv_r[PT_MAXLEN][2];
@@ -51,8 +52,7 @@ sint32 pts_resample_left_count, pts_resample_right_count;
float32 mid_left[PT_MAXLEN][2], mid_right[PT_MAXLEN][2];
sint32 mid_left_count, mid_right_count;
//<2F><><EFBFBD>ұ<EFBFBD><D2B1>߾ֲ<DFBE><D6B2>Ƕȱ仯<C8B1><E4BBAF>+<2B>Ǽ<EFBFBD><C7BC><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD>
// <20><><EFBFBD>ұ<EFBFBD><D2B1>߾ֲ<DFBE><D6B2>Ƕȱ仯<C8B1><E4BBAF>+<2B>Ǽ<EFBFBD><C7BC><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD>
float angle_new_left[PT_MAXLEN];
float angle_new_right[PT_MAXLEN];
int angle_new_left_num, angle_new_right_num;
@@ -66,7 +66,7 @@ int angle_left_num, angle_right_num;
// L<>ǵ<EFBFBD>
int Lpt0_rpts0s_id, Lpt1_rpts1s_id;
bool Lpt0_found, Lpt1_found;
int Lpt1[2],Lpt0[2];
int Lpt1[2], Lpt0[2];
int Lpt_in0_rpts0s_id, Lpt_in1_rpts1s_id;
bool Lpt_in0_found, Lpt_in1_found;
@@ -85,44 +85,43 @@ float aim_distance;
enum track_type_e track_type = TRACK_RIGHT;
int frame_count = 0;
void img_processing();
void get_corners();
int main(void)
{
clock_init(SYSTEM_CLOCK_120M); // <20><>ʼ<EFBFBD><CABC>оƬʱ<C6AC><CAB1> <20><><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5>Ϊ 120MHz
debug_init(); // <20><><EFBFBD>ر<EFBFBD><D8B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڳ<EFBFBD>ʼ<EFBFBD><CABC>MPU ʱ<><CAB1> <20><><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD>
mt9v03x_init();
ips114_init();
// mt9v03x_init();
ips200_init(IPS200_TYPE_SPI);
by_gpio_init();
by_exit_init();
by_pwm_init();
cw_servo_init();
while (imu660ra_init())
;
while (1) {
//while (frame_count < 20) {
// if (mt9v03x_finish_flag) {
// memcpy(mt9v03x_image_copy[0], mt9v03x_image[0], (sizeof(mt9v03x_image_copy) / sizeof(uint8_t)));
// adaptiveThreshold((uint8_t*)mt9v03x_image_copy, (uint8_t*)mt9v03x_image_copy, 188, 120, 7, 8);
// //threshold((uint8_t*)mt9v03x_image_copy, (uint8_t*)mt9v03x_image_copy, MT9V03X_W, MT9V03X_H, 110);
// ips114_show_gray_image(0, 0, mt9v03x_image_copy[0], MT9V03X_W, MT9V03X_H, MT9V03X_W, MT9V03X_H, 0);
// mt9v03x_finish_flag = 0;
// frame_count++;
// }
// while (frame_count < 20) {
// if (mt9v03x_finish_flag) {
// memcpy(mt9v03x_image_copy[0], mt9v03x_image[0], (sizeof(mt9v03x_image_copy) / sizeof(uint8_t)));
// adaptiveThreshold((uint8_t*)mt9v03x_image_copy, (uint8_t*)mt9v03x_image_copy, 188, 120, 7, 8);
// //threshold((uint8_t*)mt9v03x_image_copy, (uint8_t*)mt9v03x_image_copy, MT9V03X_W, MT9V03X_H, 110);
// ips114_show_gray_image(0, 0, mt9v03x_image_copy[0], MT9V03X_W, MT9V03X_H, MT9V03X_W, MT9V03X_H, 0);
// mt9v03x_finish_flag = 0;
// frame_count++;
// }
//}
if (mt9v03x_finish_flag) {
//ips114_show_gray_image(0, 0, mt9v03x_image[0], 188, 120, 188, 120,0);
memcpy(mt9v03x_image_copy[0], mt9v03x_image[0],(sizeof(mt9v03x_image_copy)/sizeof(uint8_t)));
//Img_Gray = mt9v03x_image;
//mt9v03x_image_copy[0] = Img_Gray[0];
// ips114_show_gray_image(0, 0, mt9v03x_image[0], 188, 120, 188, 120,0);
memcpy(mt9v03x_image_copy[0], mt9v03x_image[0], (sizeof(mt9v03x_image_copy) / sizeof(uint8_t)));
// Img_Gray = mt9v03x_image;
// mt9v03x_image_copy[0] = Img_Gray[0];
mt9v03x_finish_flag = 0;
state_type = COMMON_STATE;
img_processing();
@@ -137,10 +136,9 @@ int main(void)
ElementRun();
MidLineTrack();
}
by_imu_data_get();
by_ips_show();
system_delay_ms(200);
}
}