-
Notifications
You must be signed in to change notification settings - Fork 3
/
mouse.h
55 lines (52 loc) · 1.65 KB
/
mouse.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#ifndef _M5_MOUSE_H_
#define _M5_MOUSE_H_
#include <common/geometry.h>
#include <drivers/gyro.h>
#include <drivers/encoder.h>
#include <drivers/motor.h>
#include <drivers/sensor.h>
#include <drivers/wall_sensor.h>
#include <controllers/pid.h>
#include <controllers/motion.h>
#define M5_PULSE_PER_ROTATE (4096 * 4 * 5)
#define M5_BODY_WIDTH 54
#define M5_WALL_ADJUST_GAIN (0.02f)
#define M5_WALL_ERROR_UPDATE_GAIN (0.01f)
typedef struct {
m5Motion motion;
m5Odometry odometry;
m5MotionQueue motion_queue;
m5Velocity current_velocity;
m5Velocity target_velocity;
m5Velocity cap_velocity;
m5Accel cap_accel;
m5Position position;
m5Gyro gyro;
m5Encoder encoder_l;
m5Encoder encoder_r;
m5Motor motor_l;
m5Motor motor_r;
m5WallSensor sensor;
m5WallInfo wall;
m5PIDController controller_l;
m5PIDController controller_r;
m5PIDController controller_wall;
uint8_t is_wall_adjust_enabled;
uint8_t active;
uint8_t count;
float wall_error;
m5TrackTarget track_target;
} m5MouseRecord, *m5Mouse;
m5Mouse m5mouse(void);
void m5mouse_start(m5Mouse mouse);
void m5mouse_update(m5Mouse mouse);
void m5mouse_update_wallinfo(m5Mouse mouse);
void m5mouse_update_position(m5Mouse mouse);
void m5mouse_update_target_velocity(m5Mouse mouse);
void m5mouse_update_velocity(m5Mouse mouse);
void m5mouse_apply_velocity(m5Mouse mouse);
void m5mouse_set_operation(m5Mouse mouse);
void m5mouse_straight(m5Mouse mouse, float distance, float start_velocity, float max_velocity, float end_velocity);
void m5mouse_slalom(m5Mouse mouse, float degrees, float d, float const_velocity, float ang_accel, float max_omega);
void m5mouse_spin(m5Mouse mouse, float degrees);
#endif