|
Anti-Sway Capstone 1.0
|
Anti-Sway Control Law Implementation. More...
#include <stdbool.h>#include <pthread.h>#include <stdint.h>#include <stdlib.h>#include <math.h>#include "setup.h"#include "io.h"#include "thread-lib.h"#include "discrete-lib.h"#include "record.h"#include "anti-sway.h"
Data Structures | |
| struct | AntiSwayControlScheme |
| Anti-Sway Mode Feedback Control Block. More... | |
Macros | |
| #define | DATA_LEN 20 |
| The number of entries. | |
| #define | TUNING |
| Tuning Mode. | |
| #define | TUNING_DATA_LEN 10 |
| The number of array entries within the tuning file. | |
| #define | LR_X 250 |
| Learning Rate in X direction. | |
| #define | LR_Y 250 |
| Learning Rate in Y direction. | |
| #define | ZERO_GRAD() |
Functions | |
| static void | SetupScheme (AntiSwayControlScheme *scheme, Proportional K_p, Proportional K_i, Proportional m) |
| Sets up the Anti-Sway Control Law (its feedback path) | |
| static void * | AntiSwayModeThread (void *resource) |
| Runs Anti-Sway. | |
| static int | AntiSwayControlLaw (Velocity vel_ref, Angle angle_input, Velocity vel_input, AntiSwayControlScheme *scheme, int(*SetVoltage)(Voltage voltage)) |
| Executes an iteration of the feedback path for Anti-Sway. | |
| int | AntiSwayFork () |
| Executes Anti-Sway Mode. | |
| int | AntiSwayJoin () |
| Stops Anti-Sway Mode. | |
Variables | |
| pthread_t | anti_sway_thread = NULL |
| Thread ID. | |
| ThreadResource | anti_sway_resource |
| Thread Resources (Shared Resources) | |
| static double | K_ptx = 51.55550206284189 |
| The proportional constant for inner-loop. | |
| static double | K_itx = 33.28586146285062 |
| The integral constant for inner-loop control. | |
| static double | K_pty = 0.8*55.65965893434064 |
| The proportional constant for inner-loop. | |
| static double | K_ity = 0.8*31.59324977878787 |
| The integral constant for inner-loop control. | |
| static AntiSwayControlScheme | x_control |
| The Control Scheme for the X Motor. | |
| static AntiSwayControlScheme | y_control |
| The Control Scheme for the Y Motor. | |
| static int | error |
| Local Error Code. | |
| static FileID_t | file = -1 |
| The file ID. | |
| static char * | data_file_name = "anti-sway.mat" |
| The file Name. | |
| static char * | data_names [DATA_LEN] |
| The data names. | |
| static double | data [DATA_LEN] |
| Buffer for data. | |
| static double * | data_buff = data |
| Pointer to next data point to insert into buffer. | |
| static int | id = 1 |
| ID variable. | |
| static double | t = 0.0 |
| timestamp | |
| static FileID_t | tuning_file = -1 |
| The tuning file. | |
| static char * | tuning_file_name = "anti-sway-tuning.mat" |
| The name of the tuning file. | |
| static char * | tuning_data_names [TUNING_DATA_LEN] |
| The names of the array entries for the tuning file. | |
| static double | dKp [2] |
| static double | dKi [2] |
| static int | total_pts [2] |
| static double | prev_int_Kp [2][550] |
| static double | prev_int_Ki [2][550] |
| static int | prev_int_i = 0 |
| static bool | int_Kp_first = true |
| Indicates (false) if prev_int_Kp has any valid data in it. | |
| static bool | int_Ki_first = true |
| Indicates (false) if prev_int_Ki has any valid data in it. | |
| static double | prev_Kp [2] |
| Stores previous Kp values in both x and y directions. | |
| static double | prev_Ki [2] |
| Stores previous Ki value sin both x and y directions. | |
Anti-Sway Control Law Implementation.
| #define ZERO_GRAD | ( | ) |
|
inlinestatic |
Executes an iteration of the feedback path for Anti-Sway.
Executes 1 timestep for the Anti-Sway Mode Control Law for its input to the plant
| vel_ref | The reference velocity for Anti-Sway Mode |
| angle_input | The measured rope angle for Anti-Sway Mode |
| vel_input | The measured velocity of the motor |
| scheme | A pointer to the AntiSwayControlScheme structure used to execute the control law |
| SetVoltage | The function that sets the voltage of the appropriate motor |

| int AntiSwayFork | ( | ) |
Executes Anti-Sway Mode.
Executes Anti-Sway Mode (concurrently)

| int AntiSwayJoin | ( | ) |
Stops Anti-Sway Mode.
Stops Anti-Sway Mode (concurrent process)

|
static |
Runs Anti-Sway.
The Thread Function for Anti-Sway Mode
| resource | A pointer to a Resource sturcture for Tracking Mode |

|
inlinestatic |
Sets up the Anti-Sway Control Law (its feedback path)
Sets up an AntiSwayControlScheme
| scheme | The scheme to setup |
| K_p | The proportional gain |
| K_i | The integral gain |
| m | The combined masses |

|
static |
The data names.
|
static |
The gradient component of the loss with respect to Ki, for both x and y directions
|
static |
The gradient component of the loss with respect to Kp, for both x and y directions
|
static |
The counter that tells the program where we are along a column within above 2 arrays
|
static |
Previous integral outputs with respect to change in Ki, for both x and y directions
|
static |
Previous integral outputs with respect to change in Kp, for both x and y directions
|
static |
The total number of data points used for dKp and dKi, for both x and y directions
|
static |
The names of the array entries for the tuning file.