-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathprototypes_al_pupp.h
99 lines (85 loc) · 3.65 KB
/
prototypes_al_pupp.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*************************************************
Jarvis Schultz and Marcus Hammond
5-25-2011
This file simply contains the function prototypes/ declarations
*************************************************/
#ifndef _MOTORS
#define _MOTORS
#include <stddef.h>
/******************************************************************************
* GLOBAL CONSTANTS ***********************************************************
* ***************************************************************************/
#define SYS_FREQ (80000000L)
#define TOGGLES_PER_SEC 1000
#define CORE_TICK_RATE (SYS_FREQ/2/TOGGLES_PER_SEC)
/******************************************************************************
* FUNCTIONS FOR MOTOR CONTROLS ***********************************************
* ***************************************************************************/
// LEFT
void SetStepsLeft(int set_steps);
void SetSpeedLeft(float motor_speed, float dt);
float GetSpeedLeft(void);
int GetStepsLeft(void);
// RIGHT
void SetStepsRight(int set_steps);
void SetSpeedRight(float motor_speed, float dt);
float GetSpeedRight(void);
int GetStepsRight(void);
// TOP LEFT
void SetStepsTopLeft(int set_steps);
void SetSpeedTopLeft(float motor_speed, float dt);
float GetSpeedTopLeft(void);
int GetStepsTopLeft(void);
// TOP RIGHT
void SetStepsTopRight(int set_steps);
void SetSpeedTopRight(float motor_speed, float dt);
float GetSpeedTopRight(void);
int GetStepsTopRight(void);
void stop_all_motors(void);
/******************************************************************************
* FUNCTIONS FOR INITIALIZATIONS **********************************************
* ***************************************************************************/
void InitUART2(int pbClk);
void InitTimer2(void);
void InitTimer4(void);
void InitMotorPWM(void);
void InitMotorPins(void);
void InitEncoder(void);
/******************************************************************************
* FUNCTIONS FOR COMMUNICATION ************************************************
* ***************************************************************************/
void interp_command(void);
void SendDataBuffer(const char *buffer, size_t size);
float interp_number(const unsigned char *data);
int data_checker(unsigned char* buff);
void build_number(unsigned char *destination, float value, short int divisor);
void make_string(unsigned char *dest, char type,
float fval, float sval, float tval, int div);
void create_send_array(unsigned short id, unsigned char *DataString);
/******************************************************************************
* FUNCTIONS FOR ROBOT CONTROL ************************************************
* ***************************************************************************/
// GENERAL
void SetPose(float xdest, float ydest, float thdest);
void RuntimeOperation(void);
void manual_winch_runtime(void);
void reset_robot(void);
void puppeteer_shutdown(void);
// Functions for kinematic controller:
void run_fifo(const float new_val, float *array, const unsigned int size);
void calculate_controller_gains(void);
int calculate_feedforward_values(const float k);
void setup_controller(void);
void run_controller(void);
void setup_winch_controller(void);
void run_winch_controller(int recalc);
void check_safety(void);
/******************************************************************************
* MISCELLANEOUS FUNCTIONS ****************************************************
* ***************************************************************************/
float find_min(float a, float b);
void delay(void);
float clamp_angle(float th);
float find_min_angle(float a, float b);
float sign(float x);
#endif