-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0d60e7d
commit d9362e4
Showing
11 changed files
with
326 additions
and
218 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
Application_Library/Best_System_Robot/Include/motor_control.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#ifndef MOTOR_CONTROL_H | ||
#define MOTOR_CONTROL_H | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
#include "motor_types.h" | ||
#include "motor_shield.h" | ||
|
||
extern const MotorThresholds WHEEL_THRESHOLDS[]; | ||
|
||
// Function prototypes | ||
void adjust_thresholds(DC_Motor_TypeDef *motor, bool success); | ||
void soft_motor_control(void *motor_shield, Motor_Shield_Type type, uint8_t dc_motor_number, int target_speed); | ||
void adjust_motor_parameters(DC_Motor_TypeDef *motor, MovementMode mode); | ||
void set_wheel_modes(MovementMode mode); | ||
void set_wheel_speeds(int m1, int m2, int m3, int m4); | ||
void set_wheel_speeds_with_mode(int m1, int m2, int m3, int m4, MovementMode mode); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* MOTOR_CONTROL_H */ |
46 changes: 0 additions & 46 deletions
46
Application_Library/Best_System_Robot/Include/motor_controller.h
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
Application_Library/Best_System_Robot/Include/motor_types.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#ifndef MOTOR_TYPES_H | ||
#define MOTOR_TYPES_H | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
#include <stdbool.h> | ||
#include <stdint.h> | ||
|
||
typedef enum { | ||
MOVE, | ||
TURN, | ||
STRAFE, | ||
DIAGONAL | ||
} MovementMode; | ||
|
||
typedef enum { | ||
MS_V1, | ||
MS_L29XX | ||
} Motor_Shield_Type; | ||
|
||
typedef enum { | ||
M1, | ||
M2, | ||
M3, | ||
M4 | ||
} Motor_Shield_Motor; | ||
|
||
typedef struct { | ||
int static_friction_threshold; | ||
int low_speed_threshold; | ||
int success_count; | ||
int failure_count; | ||
float kp; | ||
float ki; | ||
float kd; | ||
float k_back_emf; // Added this from your original code | ||
} MotorThresholds; | ||
|
||
typedef struct { | ||
int target_speed; | ||
int current_speed; | ||
bool static_friction_overcome; | ||
float integral_error; | ||
float previous_error; | ||
uint32_t last_update_time; | ||
MotorThresholds thresholds; | ||
MovementMode mode; | ||
} MotorController; | ||
|
||
// // Forward declarations | ||
// typedef struct My_GPIO_TypeDef My_GPIO_TypeDef; | ||
// typedef struct PWM_TypeDef PWM_TypeDef; | ||
// typedef struct DC_Motor_TypeDef DC_Motor_TypeDef; | ||
// typedef struct Motor_Shield_V1 Motor_Shield_V1; | ||
// typedef struct Motor_Shield_L29XX Motor_Shield_L29XX; | ||
// typedef struct NonBlockingDelay_TypeDef NonBlockingDelay_TypeDef; | ||
// typedef struct HC595 HC595; | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* MOTOR_TYPES_H */ |
Oops, something went wrong.